M-x sort-lines
複数行の式を適切に処理できるバリアントを探しています。例えば:
this is the first line
this is the second lien
this is the (third
line
spanning multiple lines because of parens)
何か案は?
M-x sort-lines
複数行の式を適切に処理できるバリアントを探しています。例えば:
this is the first line
this is the second lien
this is the (third
line
spanning multiple lines because of parens)
何か案は?
これは、同様の方法で解決された同様の質問です
(defun end-of-chunk ()
"forward line or to ends of mid-expression."
(interactive)
(goto-char (point-at-eol))
(let ((limit (point-at-bol))
temp
expr-beg)
(while (and (setq temp (nth 1 (syntax-ppss)))
(<= limit temp))
(goto-char temp)
(setq expr-beg (point)))
(when expr-beg
(goto-char expr-beg)
(forward-sexp))))
(defun sort-lines-as-exprs (reverse beg end)
"sort lines, or whole expression if line ends mid-expression."
(interactive "P\nr")
(save-excursion
(save-restriction
(narrow-to-region beg end)
(goto-char (point-min))
(sort-subr reverse
'forward-line
'end-of-chunk))))