[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Moving between headers in message-mode
From: |
Emanuel Berg |
Subject: |
Moving between headers in message-mode |
Date: |
Sat, 15 Jun 2013 06:00:44 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) |
Hello all. I wrote this tonight. The purpose is defined in the
docstring. It is supposed to be used in message-mode. I haven't
done much testing but it seems to work. If you have any
suggestions how to make it better, please tell me. Cheers.
;; separator
(setq mail-header-separator "---")
(set-face-attribute 'message-separator nil :foreground "black")
(defun do-nothing () "Do nothing." () )
(defun iterate-header (back)
"Unless BACK, go to the next header input field:
either on the same line as the present point,
or the next header below.
If the field has a string, put point to the string's right;
if the field is empty, put point so that typing will set the header,
without any prior cursor movement.
If you move from a header which has data, that data is expanded if
found to be an `abbrev-mode' abbreviation (possibly setup in
~/.mailrc), without need for a whitespace.
If there are no headers left, `message-goto-body';
if already in the body, goto the topmost header.
If BACK, do the same, only in reverse direction."
(interactive)
(let ((position (point)))
(goto-char (point-min))
(search-forward mail-header-separator)
(let ((separator-pos (point))
(search-fun)
(start-pos)
(end-pos)
(chars-forward-after-hit)
(maybe-beginning-of-line))
(if back
(progn
(setq search-fun 'search-backward)
(setq start-pos separator-pos)
(setq end-pos (point-min))
(setq chars-forward-after-hit 2)
(setq maybe-beginning-of-line 'beginning-of-line) )
(progn
(setq search-fun 'search-forward)
(setq start-pos (point-min))
(setq end-pos separator-pos)
(setq chars-forward-after-hit 1)
(setq maybe-beginning-of-line 'do-nothing) ))
(if (< position separator-pos)
(progn
(goto-char position)
(expand-abbrev) )
(goto-char start-pos) )
(funcall maybe-beginning-of-line)
(if (not (funcall search-fun ":" end-pos t))
(message-goto-body)
(progn
(forward-char chars-forward-after-hit)
(end-of-line) )))))
(defun iterate-header-back ()
"See `iterate-header'."
(interactive)
(iterate-header t) ) ; t = back (or up)
(defun iterate-header-next ()
"See `iterate-header'."
(interactive)
(iterate-header nil) ) ; nil = forward (or down)
(define-key message-mode-map (kbd "TAB") 'iterate-header-next)
(define-key message-mode-map (kbd "<backtab>") 'iterate-header-back)
--
Emanuel Berg - programmer (hire me! CV below)
computer projects: http://user.it.uu.se/~embe8573
internet activity: http://home.student.uu.se/embe8573
- Moving between headers in message-mode,
Emanuel Berg <=
Re: Moving between headers in message-mode, Stefan Monnier, 2013/06/19