Skip to content
Snippets Groups Projects
Commit e389b558 authored by Philippe Dosch's avatar Philippe Dosch
Browse files

odj-orj ajouté, création phil-macros & refactoring

parent c747494c
No related branches found
No related tags found
No related merge requests found
...@@ -1058,74 +1058,18 @@ ...@@ -1058,74 +1058,18 @@
;; (ce qui permet d'ouvrir le nouveau folder à la place de l'ancien) ;; (ce qui permet d'ouvrir le nouveau folder à la place de l'ancien)
(put 'dired-find-alternate-file 'disabled nil) (put 'dired-find-alternate-file 'disabled nil)
;; Pour les quotes de mail trop longues (via insert-kbd-macro) (use-package phil-macros)
(defun mailcut ()
"Format lines from quoted mails."
(interactive)
(end-of-line)
(kill-line)
(when (re-search-forward "[ >]*" nil t)
(replace-match " " nil t))
(just-one-space)
(end-of-line)
(gin-do-auto-fill))
;; Au niveau du mapping, c'est un peu tricky. Je n'ai pas trouvé le ;; Au niveau du mapping, c'est un peu tricky. Je n'ai pas trouvé le
;; moyen d'ajouter la touche contrôle, l'idée initiale étant de binder ;; moyen d'ajouter la touche contrôle, l'idée initiale étant de binder
;; ça sur la touche µ. J'ai récupéré le code dans un buffer dans lequel ;; ça sur la touche µ. J'ai récupéré le code dans un buffer dans lequel
;; j'ai exécuté toggle-enable-multibyte-characters (il faut utiliser ;; j'ai exécuté toggle-enable-multibyte-characters (il faut utiliser
;; le code décimal) ;; le code décimal)
(global-set-key [181] 'mailcut) (global-set-key [181] 'mailcut)
(defvar scissors ">8 --------------------------------------------------------------- 8<"
"String to insert in \\[scissors].")
(defun scissors()
"Insert a line of SCISSORS in the buffer."
(interactive)
(insert scissors)
(forward-line 1))
(global-set-key (kbd "M-s c") 'scissors) (global-set-key (kbd "M-s c") 'scissors)
(defun snip-lines-mail ()
"Delete all lines except the first three in the current buffer selection.
For the first and last remaining lines, remove all characters after the prefix
composed of spaces and '>'. For the middle line, remove all characters after
the prefix and insert '[snip]' after the remaining prefix."
(interactive)
(save-excursion
(let ((begin (region-beginning))
(end (region-end)))
(goto-char end)
(forward-line -1)
(setq end (point))
(goto-char begin)
(forward-line 2)
(setq begin (point))
(delete-region begin end)
(goto-char begin)
(forward-line -2)
(if (re-search-forward "^\\([ >]*\\)\\(.*\\)$" nil t)
(replace-match "" nil nil nil 2))
(forward-line 1)
(if (re-search-forward "^\\([ >]*\\)\\(.*\\)$" nil t)
(replace-match "[snip]" nil nil nil 2))
(forward-line 1)
(if (re-search-forward "^\\([ >]*\\)\\(.*\\)$" nil t)
(replace-match "" nil nil nil 2))
(forward-line 1))))
(global-set-key (kbd "M-s s") 'snip-lines-mail) (global-set-key (kbd "M-s s") 'snip-lines-mail)
(defun cite-mail-part ()
"Prefix each line in the region with '> '."
(interactive)
(save-excursion
(let ((begin (region-beginning))
(end (region-end)))
(goto-char begin)
(while (< (point) end)
(beginning-of-line)
(insert "> ")
(forward-line 1)))))
(global-set-key (kbd "M-s t") 'cite-mail-part) (global-set-key (kbd "M-s t") 'cite-mail-part)
(global-set-key (kbd "M-s o") 'odj-org)
;;; .emacs ends here ;;; .emacs ends here
(provide '.emacs) (provide '.emacs)
......
;;; phil-macros.el -- Phil's Macros
;;; Commentary:
;;; Code:
(require 'gin-mode)
;; Pour les quotes de mail trop longues (via insert-kbd-macro)
(defun mailcut ()
"Format lines from quoted mails."
(interactive)
(end-of-line)
(kill-line)
(when (re-search-forward "[ >]*" nil t)
(replace-match " " nil t))
(just-one-space)
(end-of-line)
(gin-do-auto-fill))
(defvar phil-scissors ">8 --------------------------------------------------------------- 8<"
"String to insert in \\[scissors].")
(defun scissors()
"Insert a line of SCISSORS in the buffer."
(interactive)
(insert phil-scissors)
(forward-line 1))
(defun snip-lines-mail ()
"Delete all lines except the first three in the current buffer selection.
For the first and last remaining lines, remove all characters after the prefix
composed of spaces and '>'. For the middle line, remove all characters after
the prefix and insert '[snip]' after the remaining prefix."
(interactive)
(save-excursion
(let ((begin (region-beginning))
(end (region-end)))
(goto-char end)
(forward-line -1)
(setq end (point))
(goto-char begin)
(forward-line 2)
(setq begin (point))
(delete-region begin end)
(goto-char begin)
(forward-line -2)
(if (re-search-forward "^\\([ >]*\\)\\(.*\\)$" nil t)
(replace-match "" nil nil nil 2))
(forward-line 1)
(if (re-search-forward "^\\([ >]*\\)\\(.*\\)$" nil t)
(replace-match "[snip]" nil nil nil 2))
(forward-line 1)
(if (re-search-forward "^\\([ >]*\\)\\(.*\\)$" nil t)
(replace-match "" nil nil nil 2))
(forward-line 1))))
(defun cite-mail-part ()
"Prefix each line in the region with '> '."
(interactive)
(save-excursion
(let ((begin (region-beginning))
(end (region-end)))
(goto-char begin)
(while (< (point) end)
(beginning-of-line)
(insert "> ")
(forward-line 1)))))
(defun odj-org()
"Translate a text-based agenda to an org structure."
(interactive)
(save-excursion
(let ((begin (region-beginning))
(end (region-end)))
(goto-char begin)
(while (< (point) end)
(beginning-of-line)
(if (re-search-forward "^\\([0-9]+[^ ]?\\) " nil t)
(replace-match "***" nil nil nil 1))
(forward-line 1)))))
(provide 'phil-macros)
;;; phil-macros.el ends here
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment