You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

136 lines
4.1 KiB
EmacsLisp

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

(defun org-format ()
"Correct formatting in an org file"
(interactive)
(goto-char (point-min))
(while (re-search-forward " -" nil t)
(replace-match " "))
(goto-char (point-min))
(while (re-search-forward " " nil t)
(replace-match " "))
(goto-char (point-min))
(while (re-search-forward "/ " nil t)
(replace-match " /"))
(goto-char (point-min))
(while (re-search-forward "\\.\\.\\." nil t)
(replace-match ""))
(goto-char (point-min))
(while (re-search-forward "" nil t)
(replace-match " … "))
(goto-char (point-min))
(while (re-search-forward "  …" nil t)
(replace-match " …"))
(goto-char (point-min))
(while (re-search-forward "  +…" nil t)
(replace-match " …"))
(goto-char (point-min))
(while (re-search-forward "'" nil t)
(replace-match ""))
(goto-char (point-min))
(while (re-search-forward " +" nil t)
(replace-match " "))
(goto-char (point-min))
(while (re-search-forward " \n" nil t)
(replace-match "\n"))
(goto-char (point-min))
(while (re-search-forward "\n\"" nil t)
(replace-match "\n"))
(goto-char (point-min))
(while (re-search-forward " \"" nil t)
(replace-match ""))
(goto-char (point-min))
(while (re-search-forward "\"" nil t)
(replace-match ""))
(goto-char (point-min))
(while (re-search-forward "“/" nil t)
(replace-match "/“"))
(goto-char (point-min))
(while (re-search-forward "/”" nil t)
(replace-match "”/"))
(goto-char (point-min))
(while (re-search-forward "=”" nil t)
(replace-match "=\""))
(goto-char (point-min))
(while (re-search-forward "”>" nil t)
(replace-match "\">"))
(goto-char (point-min))
(while (re-search-forward "”/>" nil t)
(replace-match "\"/>"))
(goto-char (point-min))
(while (re-search-forward "=\"\\([^>]*\\)”" nil t)
(replace-match "=\"\\1\"")))
(defun org-format-fr ()
"Correct formatting in a French org file"
(interactive)
(org-format)
(goto-char (point-min))
(let ((case-fold-search nil))
(while (re-search-forward "oe" nil t)
(replace-match "œ")))
(goto-char (point-min))
(while (re-search-forward " …" nil t)
(replace-match ""))
(goto-char (point-min))
(while (re-search-forward "" nil t)
(replace-match "«"))
(goto-char (point-min))
(while (re-search-forward "« " nil t)
(replace-match "«"))
(goto-char (point-min))
(while (re-search-forward "«" nil t)
(replace-match "« "))
(goto-char (point-min))
(while (re-search-forward "«  " nil t)
(replace-match "« "))
(goto-char (point-min))
(while (re-search-forward "" nil t)
(replace-match "»"))
(goto-char (point-min))
(while (re-search-forward " »" nil t)
(replace-match "»"))
(goto-char (point-min))
(while (re-search-forward "»" nil t)
(replace-match " »"))
(goto-char (point-min))
(while (re-search-forward "  »" nil t)
(replace-match " »"))
(goto-char (point-min))
(while (re-search-forward " ;" nil t)
(replace-match ";"))
(goto-char (point-min))
(while (re-search-forward ";" nil t)
(replace-match " ;"))
(goto-char (point-min))
(while (re-search-forward "  ;" nil t)
(replace-match " ;"))
(goto-char (point-min))
(while (re-search-forward " :" nil t)
(replace-match ":"))
(goto-char (point-min))
(while (re-search-forward ":" nil t)
(replace-match " :"))
(goto-char (point-min))
(while (re-search-forward "  :" nil t)
(replace-match " :"))
(goto-char (point-min))
(while (re-search-forward " !" nil t)
(replace-match "!"))
(goto-char (point-min))
(while (re-search-forward "!" nil t)
(replace-match " !"))
(goto-char (point-min))
(while (re-search-forward "  !" nil t)
(replace-match " !"))
(goto-char (point-min))
(while (re-search-forward " \\?" nil t)
(replace-match "\?"))
(goto-char (point-min))
(while (re-search-forward "\\?" nil t)
(replace-match " \?"))
(goto-char (point-min))
(while (re-search-forward "  \\?" nil t)
(replace-match " \?"))
(goto-char (point-min))
(while (re-search-forward "\n- " nil t)
(replace-match "\n ")))