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.

151 lines
4.6 KiB
EmacsLisp

(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 "\\([a-z]\\)" nil t)
(replace-match "\\1"))
(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))
2 years ago
(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)
2 years ago
(replace-match ""))
(goto-char (point-min))
2 years ago
(while (re-search-forward "“/" nil t)
(replace-match "/“"))
(goto-char (point-min))
2 years ago
(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 "#+TITLE :" nil t)
(replace-match "#+TITLE:"))
(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 ")))