From 77c85a690729dadef81a1f012d9b43125dd6a2bf Mon Sep 17 00:00:00 2001 From: yoichi Date: Sun, 14 Sep 2003 10:35:40 +0000 Subject: [PATCH] * wl-draft.el (wl-draft-previous-history-element): New function. (wl-draft-next-history-element): Ditto. * wl-e21.el, wl-xmas.el, wl-mule.el (wl-draft-key-setup): Bind them to M-p and M-n. --- wl/ChangeLog | 7 ++++++ wl/wl-draft.el | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ wl/wl-e21.el | 4 ++- wl/wl-mule.el | 4 ++- wl/wl-xmas.el | 4 ++- 5 files changed, 90 insertions(+), 3 deletions(-) diff --git a/wl/ChangeLog b/wl/ChangeLog index 9043e57..1088233 100644 --- a/wl/ChangeLog +++ b/wl/ChangeLog @@ -1,3 +1,10 @@ +2003-09-14 Yoichi NAKAYAMA + + * wl-draft.el (wl-draft-previous-history-element): New function. + (wl-draft-next-history-element): Ditto. + * wl-e21.el, wl-xmas.el, wl-mule.el (wl-draft-key-setup): Bind + them to M-p and M-n. + 2003-09-14 Hiroya Murata * Version number is increased to 2.11.12. diff --git a/wl/wl-draft.el b/wl/wl-draft.el index 752229b..6df2d19 100644 --- a/wl/wl-draft.el +++ b/wl/wl-draft.el @@ -2435,6 +2435,80 @@ Automatically applied in draft sending time." (set-buffer-modified-p modified)))) (recenter n)) +;; insert element from history +(defvar wl-draft-current-history-position nil) +(defvar wl-draft-history-backup-word "") + +(defun wl-draft-previous-history-element (n) + (interactive "p") + (let (bol history) + (when (and (not (wl-draft-on-field-p)) + (< (point) + (save-excursion + (goto-char (point-min)) + (search-forward (concat "\n" mail-header-separator "\n") nil 0) + (point))) + (save-excursion + (beginning-of-line) + (while (and (looking-at "^[ \t]") + (not (= (point) (point-min)))) + (forward-line -1)) + (cond + ((looking-at wl-folder-complete-header-regexp) + (and (boundp 'wl-read-folder-hist) + (setq history wl-read-folder-hist))) + ;; ((looking-at wl-address-complete-header-regexp) + ;; (setq history .....)) + (t + nil))) + (eolp)) + (setq bol (save-excursion (beginning-of-line) (point))) + (cond ((and (or (eq last-command 'wl-draft-previous-history-element) + (eq last-command 'wl-draft-next-history-element)) + wl-draft-current-history-position) + (setq end (point)) + (or (search-backward-regexp ",[ \t]*\\(.*\\)" bol t) + (search-backward-regexp "^[ \t]\\(.*\\)" bol t) + (search-backward-regexp "^[^ \t]*: \\(.*\\)" bol t)) + (setq prev (match-string 1)) + (goto-char (match-beginning 1)) + (setq beg (point)) + (if (cond ((< n 0) + (>= (+ n wl-draft-current-history-position) 0)) + ((> n 0) + (<= (+ n wl-draft-current-history-position) + (length history)))) + (progn + (setq wl-draft-current-history-position + (+ n wl-draft-current-history-position)) + (setq new + (nth wl-draft-current-history-position + (append (list wl-draft-history-backup-word) + history))) + (delete-region beg end) + (insert new)) + (goto-char end) + (cond ((< n 0) + (message "End of history; no next item")) + ((> n 0) + (message "Beginning of history; no preceding item"))))) + ((and (> n 0) + (save-excursion + (or (search-backward-regexp ",[ \t]*\\(.*\\)" bol t) + (search-backward-regexp "^[ \t]\\(.*\\)" bol t) + (search-backward-regexp "^[^ \t]*: \\(.*\\)" bol t))) + (car history)) + (setq wl-draft-current-history-position 1) + (setq wl-draft-history-backup-word (match-string 1)) + (delete-region (match-beginning 1) (match-end 1)) + (insert (car history))) + (t + (setq wl-draft-current-history-position nil))))))) + +(defun wl-draft-next-history-element (n) + (interactive "p") + (wl-draft-previous-history-element (- n))) + ;;;; user-agent support by Sen Nagata ;; this appears to be necessarily global... diff --git a/wl/wl-e21.el b/wl/wl-e21.el index 3bdd11a..e71b290 100644 --- a/wl/wl-e21.el +++ b/wl/wl-e21.el @@ -630,7 +630,9 @@ Special commands: ;; (define-key wl-draft-mode-map "\C-x\C-s" 'wl-draft-save) (define-key wl-draft-mode-map "\C-xk" 'wl-draft-mimic-kill-buffer) (define-key wl-draft-mode-map "\C-c\C-d" 'wl-draft-elide-region) - (define-key wl-draft-mode-map "\C-a" 'wl-draft-beginning-of-line)) + (define-key wl-draft-mode-map "\C-a" 'wl-draft-beginning-of-line) + (define-key wl-draft-mode-map "\M-p" 'wl-draft-previous-history-element) + (define-key wl-draft-mode-map "\M-n" 'wl-draft-next-history-element)) (defun wl-draft-overload-functions () (wl-mode-line-buffer-identification) diff --git a/wl/wl-mule.el b/wl/wl-mule.el index 8f3e799..7cc59ca 100644 --- a/wl/wl-mule.el +++ b/wl/wl-mule.el @@ -165,7 +165,9 @@ Special commands: (define-key wl-draft-mode-map "\C-c\C-a" 'wl-addrmgr) (define-key wl-draft-mode-map "\C-xk" 'wl-draft-mimic-kill-buffer) (define-key wl-draft-mode-map "\C-c\C-d" 'wl-draft-elide-region) - (define-key wl-draft-mode-map "\C-a" 'wl-draft-beginning-of-line)) + (define-key wl-draft-mode-map "\C-a" 'wl-draft-beginning-of-line) + (define-key wl-draft-mode-map "\M-p" 'wl-draft-previous-history-element) + (define-key wl-draft-mode-map "\M-n" 'wl-draft-next-history-element)) (defun wl-draft-overload-menubar () (let ((keymap (current-local-map))) diff --git a/wl/wl-xmas.el b/wl/wl-xmas.el index b0bd02c..5b9a447 100644 --- a/wl/wl-xmas.el +++ b/wl/wl-xmas.el @@ -537,7 +537,9 @@ Special commands: (define-key wl-draft-mode-map "\C-c\C-a" 'wl-addrmgr) (define-key wl-draft-mode-map "\C-xk" 'wl-draft-mimic-kill-buffer) (define-key wl-draft-mode-map "\C-c\C-d" 'wl-draft-elide-region) - (define-key wl-draft-mode-map "\C-a" 'wl-draft-beginning-of-line)) + (define-key wl-draft-mode-map "\C-a" 'wl-draft-beginning-of-line) + (define-key wl-draft-mode-map "\M-p" 'wl-draft-previous-history-element) + (define-key wl-draft-mode-map "\M-n" 'wl-draft-next-history-element)) (defun wl-draft-overload-functions () (wl-mode-line-buffer-identification) -- 1.7.10.4