{"action":"opened","issue":{"url":"https://api.github.com/repos/zenspider/enhanced-ruby-mode/issues/79","labels_url":"https://api.github.com/repos/zenspider/enhanced-ruby-mode/issues/79/labels{/name}","comments_url":"https://api.github.com/repos/zenspider/enhanced-ruby-mode/issues/79/comments","events_url":"https://api.github.com/repos/zenspider/enhanced-ruby-mode/issues/79/events","html_url":"https://github.com/zenspider/enhanced-ruby-mode/issues/79","id":81261383,"number":79,"title":"(up-list -1)  and (forward-sexp) not worked for enh-ruby-mode","user":{"login":"zw963","id":549126,"avatar_url":"https://avatars.githubusercontent.com/u/549126?v=3","gravatar_id":"","url":"https://api.github.com/users/zw963","html_url":"https://github.com/zw963","followers_url":"https://api.github.com/users/zw963/followers","following_url":"https://api.github.com/users/zw963/following{/other_user}","gists_url":"https://api.github.com/users/zw963/gists{/gist_id}","starred_url":"https://api.github.com/users/zw963/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zw963/subscriptions","organizations_url":"https://api.github.com/users/zw963/orgs","repos_url":"https://api.github.com/users/zw963/repos","events_url":"https://api.github.com/users/zw963/events{/privacy}","received_events_url":"https://api.github.com/users/zw963/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-05-27T04:05:14Z","updated_at":"2015-05-27T04:05:14Z","closed_at":null,"body":"Here is a function I stolen from yasnippets, It function is change { ... } to do ... end.\r\nIn this function, we use (up-list -1) and (forward-sexp) function, But those not\r\nworked in enh-ruby-mode (it worked very good at ruby-mode)\r\n\r\nSo I change to above to (enh-ruby-up-sexp 1) and (enh-ruby-forward-sexp) respectively, \r\nit can worked, but not work fine with this function,  into deep loop and skip to \r\nbeginning of buffer.\r\n\r\nhow does make `up-list` and (forward-sexp)  still worked in this function?\r\n\r\nOr, enh-ruby-mode exist a similar function?\r\n\r\nThanks.\r\n\r\nfollowing is the function definition:\r\n\r\n```cl\r\n(defun yas-ruby-toggle-single-multi-line-block ()\r\n  \"Toggle \\\"do .. end\\\" blocks into  \\\"{ .. }\\\" blocks back and forth.\"\r\n  ;;\r\n  ;; TODO: Some code to be refactored here.\r\n  ;;\r\n  ;; FIXME: correctly detect statements in { .. } block, split-string(\";\") is no good\r\n  ;;\r\n  (interactive)\r\n  (let* ((do-block-bounds (save-excursion\r\n                            (when (or (save-excursion (beginning-of-line)\r\n                                                      (looking-at yas-ruby-block-start-regexp))\r\n                                      (save-excursion (ruby-beginning-of-block)\r\n                                                      (looking-at yas-ruby-block-start-regexp)))\r\n                              (cons (match-beginning 1)\r\n                                    (progn (goto-char (match-beginning 1))\r\n                                           (ruby-end-of-block) (point))))))\r\n         (brace-block-bounds (condition-case nil\r\n                                 (let ((syntax-info (syntax-ppss)))\r\n                                   (if (fourth syntax-info)\r\n                                       (goto-char (ninth syntax-info)))\r\n\r\n                                      ;; (up-list -1) change to (enh-ruby-up-sexp 1)\r\n                                   (while (progn (up-list -1) (not (eq (char-after) ?{))))\r\n                                   (cons (point)\r\n                                        ;; (forward-sexp) change to (enh-ruby-forward-sexp)\r\n                                         (progn (forward-sexp) (point))))\r\n                               (error nil)))\r\n         (block-region)\r\n         (statements))\r\n    (if (and do-block-bounds brace-block-bounds)\r\n        (if (< (car do-block-bounds) (car brace-block-bounds))\r\n            (setq do-block-bounds nil)\r\n          (setq brace-block-bounds nil)))\r\n    (cond (do-block-bounds\r\n           (goto-char (car do-block-bounds))\r\n           (setq block-region (buffer-substring-no-properties (+ 2 (car do-block-bounds)) (cdr do-block-bounds)))\r\n           (delete-region (car do-block-bounds) (+ 3 (cdr do-block-bounds)))\r\n           (insert \"{\")\r\n           (when (string-match \"\\\\(|.*|\\\\).*\" block-region)\r\n             (insert \" \" (match-string 1 block-region))\r\n             (setq block-region (substring block-region (match-end 1))))\r\n           (setq statements (remove nil (mapcar #'yas-ruby-chomp\r\n                                                (split-string block-region \"\\n\"))))\r\n           (mapc #'(lambda (string)\r\n                     (insert \" \" string)\r\n                     (if (member (aref string (1- (length string))) '(?;\r\n                                                                      ?|))\r\n                         (insert \" \")\r\n                       (insert \";\")))\r\n                 statements)\r\n           (when statements (delete-backward-char 1))\r\n           (save-excursion\r\n             (insert \" }\")))\r\n          (brace-block-bounds\r\n           ;; (message \"found a brace block\")\r\n           (goto-char (car brace-block-bounds))\r\n           (setq block-region (buffer-substring (1+ (car brace-block-bounds)) (1- (cdr brace-block-bounds))))\r\n           (delete-region (car brace-block-bounds) (+ 1 (cdr brace-block-bounds)))\r\n           (insert \"do\")\r\n           (when (string-match \"\\\\(|.*|\\\\).*\" block-region)\r\n             (insert \" \" (match-string 1 block-region))\r\n             (setq block-region (substring block-region (match-end 1))))\r\n           (setq statements (remove nil (mapcar #'yas-ruby-chomp\r\n                                                (split-string block-region \";\"))))\r\n           (mapc #'(lambda (string)\r\n                     (insert \"\\n\" string)\r\n                     (indent-according-to-mode))\r\n                 statements)\r\n           (unless statements (insert \"\\n\") (indent-according-to-mode))\r\n           (save-excursion\r\n             (insert \"\\nend\")\r\n             (indent-according-to-mode)))\r\n          (t (newline-and-indent)))))\r\n```"}}