all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Emanuel Berg <embe8573@student.uu.se>
To: help-gnu-emacs@gnu.org
Subject: Re: Moving between headers in message-mode
Date: Wed, 19 Jun 2013 00:17:44 +0200	[thread overview]
Message-ID: <87sj0fhxmf.fsf@VLAN-3434.student.uu.se> (raw)
In-Reply-To: 87hagzfd4k.fsf@kuiper.lan.informatimago.com

Did I correctly boil it down to:

1) Don't use setq
2) Don't use let let unless you complete the name-value
association (i.e., don't set it up to be assigned later)

(As for style, I haven't got around to that, will do. I *think* I
picked up mine mostly from a book called "The Land of Lisp".)

What do you think of:

;; separator
(set-variable 'mail-header-separator "---")
(set-face-attribute 'message-separator nil :foreground "black")

(defun do-nothing () "Do nothing." () )
(defun iterate-header (separator-pos
                       search-fun
                       start-pos end-pos
                       chars-forward-after-hit
                       maybe-beginning-of-line)
  "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."
  (interactive)
  (let ((position (point)))
    (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 get-separator-pos ()
  "Get the position of `mail-header-separator'."
  (save-excursion
    (goto-char (point-min))
    (search-forward mail-header-separator)
    (point) ))

(defun iterate-header-back ()
  "See `iterate-header'."
  (interactive)
  (let ((separator-pos (get-separator-pos)))
    (iterate-header
     separator-pos
     'search-backward
     separator-pos (point-min)
     2
     'beginning-of-line) ))
(defun iterate-header-next ()
  "See `iterate-header'."
  (interactive)
  (let ((separator-pos (get-separator-pos)))
    (iterate-header
     separator-pos
     'search-forward
     (point-min) separator-pos
     1
     'do-nothing) ))

(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


  reply	other threads:[~2013-06-18 22:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-15  4:00 Moving between headers in message-mode Emanuel Berg
2013-06-15 12:58 ` Pascal J. Bourguignon
2013-06-15 17:02   ` Emanuel Berg
2013-06-15 18:22     ` Pascal J. Bourguignon
2013-06-18 22:17       ` Emanuel Berg [this message]
2013-06-19  0:30         ` Emanuel Berg
2013-06-19 15:02 ` Stefan Monnier
2013-06-20  9:32   ` Emanuel Berg
2013-06-20 13:16     ` Stefan Monnier
     [not found]     ` <mailman.2075.1371734198.22516.help-gnu-emacs@gnu.org>
2013-06-20 18:17       ` Emanuel Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sj0fhxmf.fsf@VLAN-3434.student.uu.se \
    --to=embe8573@student.uu.se \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.