带重音字符的行排序


9

sort-lines开头的行对行进行排序时,以开头ä的行之后z。如果可以像在字典中那样忽略重音符号,Umlauts等来对行进行排序,那就太好了。理想情况下,以开头的行ändern应该在以开头的行之后anderen

有一个简单的解决方案,用于搜索https://superuser.com/a/675172/中提到的带重音符号,但不能在此处使用。我想知道这种解决方案是否可以适应这种情况。


1
FYI,基于扩展字符的折叠和分组已在emacs的下一个版本中isearch以及query-replace在下一个版本中实现。
Emacs用户

Answers:


5

我为此使用此功能

(defun my-sort-lines ()
    (interactive)
    (shell-command-on-region (point-min) (point-max) "LC_COLLATE=en_US.UTF-8 sort" (buffer-name) t ))

编辑:排序区域或缓冲区:

  (defun my-sort-lines-buffer ()
    (interactive)
    (shell-command-on-region (point-min) (point-max) "LC_COLLATE=en_US.UTF-8 sort" (buffer-name) t ))
  (defun my-sort-lines-region (start end) 
    (interactive "r") 
    (shell-command-on-region start end "LC_COLLATE=en_US.UTF-8 sort" (buffer-name) t))
  (defun my-sort-lines-region-or-buffer ()
    (interactive)
    (save-excursion
      (if (region-active-p)
          (progn
            (my-sort-lines-region (region-beginning) (region-end))
            (message "Sorted selected region"))
        (progn
          (my-sort-lines-buffer)
          (message "Sorted buffer")))))

感谢分享!重命名my-sort-lines-buffer为什么呢?还是重写为(defun my-sort-lines (start end) (interactive "r") (shell-command-on-region start end "LC_COLLATE=en_US.UTF-8 sort" (buffer-name) t))
Marco Wahl 2015年

@Marco Wahl:我根据您的主张编辑我的帖子。
djangoliv

运行此程序时,我得到错误“ LC_COLLATE”,未被识别为内部或外部命令,也不是可执行程序。
名称

@Name也许您在Windows上。抱歉,此功能仅适用于linux ...
djangoliv
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.