From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Emanuel Berg Newsgroups: gmane.emacs.help Subject: Re: Moving between headers in message-mode Date: Wed, 19 Jun 2013 00:17:44 +0200 Organization: Aioe.org NNTP Server Message-ID: <87sj0fhxmf.fsf@VLAN-3434.student.uu.se> References: <87wqpwgh03.fsf@VLAN-3434.student.uu.se> <87vc5ffs49.fsf@kuiper.lan.informatimago.com> <87r4g3mhnz.fsf@VLAN-3434.student.uu.se> <87hagzfd4k.fsf@kuiper.lan.informatimago.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1371595324 20656 80.91.229.3 (18 Jun 2013 22:42:04 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 18 Jun 2013 22:42:04 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jun 19 00:42:06 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Up4bF-0001nL-F1 for geh-help-gnu-emacs@m.gmane.org; Wed, 19 Jun 2013 00:42:05 +0200 Original-Received: from localhost ([::1]:43834 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Up4bF-0007ZO-3x for geh-help-gnu-emacs@m.gmane.org; Tue, 18 Jun 2013 18:42:05 -0400 Original-Path: usenet.stanford.edu!news.kjsl.com!feeder.erje.net!eu.feeder.erje.net!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!aioe.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 81 Original-NNTP-Posting-Host: aSzd8IlIZf25OwctEXl60Q.user.speranza.aioe.org Original-X-Complaints-To: abuse@aioe.org User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) X-Notice: Filtered by postfilter v. 0.8.2 Cancel-Lock: sha1:7Njm18AW+ywQNcaYRxv4ZR2gVGE= Original-Xref: usenet.stanford.edu gnu.emacs.help:199332 X-Mailman-Approved-At: Tue, 18 Jun 2013 18:41:54 -0400 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:91596 Archived-At: 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 "") '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