Mercurial > emacs
comparison lisp/mh-e/mh-letter.el @ 68477:0f44616074ba
* mh-comp.el (mh-letter-hide-all-skipped-fields)
(mh-get-header-field): Move to mh-utils.el so that you can read
messages without having to load mh-comp.el and mh-letter.el.
* mh-letter.el (mh-hidden-header-keymap)
(mh-letter-toggle-header-field-display)
(mh-letter-skipped-header-field-p)
(mh-letter-skip-leading-whitespace-in-header-field)
(mh-letter-truncate-header-field): Move to mh-utils.el so that you can
read messages without having to load mh-comp.el and mh-letter.el.
* mh-utils.el (mh-get-header-field)
(mh-letter-hide-all-skipped-fields)
(mh-letter-skipped-header-field-p, mh-hidden-header-keymap)
(mh-letter-toggle-header-field-display)
(mh-letter-skip-leading-whitespace-in-header-field)
(mh-letter-truncate-header-field): Move here from mh-comp.el and
mh-letter.el so that you can read messages without having to load
mh-comp.el and mh-letter.el.
author | Bill Wohler <wohler@newt.com> |
---|---|
date | Mon, 30 Jan 2006 01:32:17 +0000 |
parents | e238dd02cdad |
children | bf46ace1ce4e |
comparison
equal
deleted
inserted
replaced
68476:a58223a143bc | 68477:0f44616074ba |
---|---|
58 (mail-followup-to . mh-alias-letter-expand-alias) | 58 (mail-followup-to . mh-alias-letter-expand-alias) |
59 (mail-reply-to . mh-alias-letter-expand-alias) | 59 (mail-reply-to . mh-alias-letter-expand-alias) |
60 (reply-to . mh-alias-letter-expand-alias) | 60 (reply-to . mh-alias-letter-expand-alias) |
61 (to . mh-alias-letter-expand-alias)) | 61 (to . mh-alias-letter-expand-alias)) |
62 "Alist of header fields and completion functions to use.") | 62 "Alist of header fields and completion functions to use.") |
63 | |
64 (defvar mh-hidden-header-keymap | |
65 (let ((map (make-sparse-keymap))) | |
66 (mh-do-in-gnu-emacs | |
67 (define-key map [mouse-2] 'mh-letter-toggle-header-field-display-button)) | |
68 (mh-do-in-xemacs | |
69 (define-key map '(button2) | |
70 'mh-letter-toggle-header-field-display-button)) | |
71 map)) | |
72 | 63 |
73 (defvar mh-yank-hooks nil | 64 (defvar mh-yank-hooks nil |
74 "Obsolete hook for modifying a citation just inserted in the mail buffer. | 65 "Obsolete hook for modifying a citation just inserted in the mail buffer. |
75 | 66 |
76 Each hook function can find the citation between point and mark. | 67 Each hook function can find the citation between point and mark. |
590 (mh-letter-previous-header-field) | 581 (mh-letter-previous-header-field) |
591 (goto-char (match-end 0)) | 582 (goto-char (match-end 0)) |
592 (mh-letter-skip-leading-whitespace-in-header-field))) | 583 (mh-letter-skip-leading-whitespace-in-header-field))) |
593 (t (goto-char header-end) | 584 (t (goto-char header-end) |
594 (forward-line))))) | 585 (forward-line))))) |
595 | |
596 ;;;###mh-autoload | |
597 (defun mh-letter-toggle-header-field-display (arg) | |
598 "Toggle display of header field at point. | |
599 | |
600 Use this command to display truncated header fields. This command | |
601 is a toggle so entering it again will hide the field. This | |
602 command takes a prefix argument ARG: if negative then the field | |
603 is hidden, if positive then the field is displayed." | |
604 (interactive (list nil)) | |
605 (when (and (mh-in-header-p) | |
606 (progn | |
607 (end-of-line) | |
608 (re-search-backward mh-letter-header-field-regexp nil t))) | |
609 (let ((buffer-read-only nil) | |
610 (modified-flag (buffer-modified-p)) | |
611 (begin (point)) | |
612 end) | |
613 (end-of-line) | |
614 (setq end (1- (if (re-search-forward "^[^ \t]" nil t) | |
615 (match-beginning 0) | |
616 (point-max)))) | |
617 (goto-char begin) | |
618 ;; Make it clickable... | |
619 (add-text-properties begin end `(keymap ,mh-hidden-header-keymap | |
620 mouse-face highlight)) | |
621 (unwind-protect | |
622 (cond ((or (and (not arg) | |
623 (text-property-any begin end 'invisible 'vanish)) | |
624 (and (numberp arg) (>= arg 0)) | |
625 (and (eq arg 'long) (> (line-beginning-position 5) end))) | |
626 (remove-text-properties begin end '(invisible nil)) | |
627 (search-forward ":" (line-end-position) t) | |
628 (mh-letter-skip-leading-whitespace-in-header-field)) | |
629 ;; XXX Redesign to make usable by user. Perhaps use a positive | |
630 ;; numeric prefix to make that many lines visible. | |
631 ((eq arg 'long) | |
632 (end-of-line 4) | |
633 (mh-letter-truncate-header-field end) | |
634 (beginning-of-line)) | |
635 (t (end-of-line) | |
636 (mh-letter-truncate-header-field end) | |
637 (beginning-of-line))) | |
638 (set-buffer-modified-p modified-flag))))) | |
639 | 586 |
640 (defun mh-open-line () | 587 (defun mh-open-line () |
641 "Insert a newline and leave point before it. | 588 "Insert a newline and leave point before it. |
642 | 589 |
643 This command is similar to the command \\[open-line] in that it | 590 This command is similar to the command \\[open-line] in that it |
891 (mh-letter-skip-leading-whitespace-in-header-field))) | 838 (mh-letter-skip-leading-whitespace-in-header-field))) |
892 (t (goto-char header-end) | 839 (t (goto-char header-end) |
893 (forward-line))))) | 840 (forward-line))))) |
894 | 841 |
895 ;;;###mh-autoload | 842 ;;;###mh-autoload |
896 (defun mh-letter-skipped-header-field-p (field) | |
897 "Check if FIELD is to be skipped." | |
898 (let ((field (downcase field))) | |
899 (loop for x in mh-compose-skipped-header-fields | |
900 when (equal (downcase x) field) return t | |
901 finally return nil))) | |
902 | |
903 (defun mh-letter-skip-leading-whitespace-in-header-field () | |
904 "Skip leading whitespace in a header field. | |
905 If the header field doesn't have at least one space after the | |
906 colon then a space character is added." | |
907 (let ((need-space t)) | |
908 (while (memq (char-after) '(?\t ?\ )) | |
909 (forward-char) | |
910 (setq need-space nil)) | |
911 (when need-space (insert " ")))) | |
912 | |
913 ;;;###mh-autoload | |
914 (defun mh-position-on-field (field &optional ignored) | 843 (defun mh-position-on-field (field &optional ignored) |
915 "Move to the end of the FIELD in the header. | 844 "Move to the end of the FIELD in the header. |
916 Move to end of entire header if FIELD not found. | 845 Move to end of entire header if FIELD not found. |
917 Returns non-nil iff FIELD was found. | 846 Returns non-nil iff FIELD was found. |
918 The optional second arg is for pre-version 4 compatibility and is | 847 The optional second arg is for pre-version 4 compatibility and is |
978 (file-exists-p file) | 907 (file-exists-p file) |
979 (or (and (not (mh-have-file-command)) | 908 (or (and (not (mh-have-file-command)) |
980 (not (null (string-match "\.vcf$" file)))) | 909 (not (null (string-match "\.vcf$" file)))) |
981 (string-equal "text/x-vcard" (mh-file-mime-type file)))))) | 910 (string-equal "text/x-vcard" (mh-file-mime-type file)))))) |
982 | 911 |
912 ;;;###mh-autoload | |
983 (defun mh-letter-toggle-header-field-display-button (event) | 913 (defun mh-letter-toggle-header-field-display-button (event) |
984 "Toggle header field display at location of EVENT. | 914 "Toggle header field display at location of EVENT. |
985 This function does the same thing as | 915 This function does the same thing as |
986 `mh-letter-toggle-header-field-display' except that it is | 916 `mh-letter-toggle-header-field-display' except that it is |
987 callable from a mouse button." | 917 callable from a mouse button." |
988 (interactive "e") | 918 (interactive "e") |
989 (mh-do-at-event-location event | 919 (mh-do-at-event-location event |
990 (mh-letter-toggle-header-field-display nil))) | 920 (mh-letter-toggle-header-field-display nil))) |
991 | |
992 (defun mh-letter-truncate-header-field (end) | |
993 "Replace text from current line till END with an ellipsis. | |
994 If the current line is too long truncate a part of it as well." | |
995 (let ((max-len (min (window-width) 62))) | |
996 (when (> (+ (current-column) 4) max-len) | |
997 (backward-char (- (+ (current-column) 5) max-len))) | |
998 (when (> end (point)) | |
999 (add-text-properties (point) end '(invisible vanish))))) | |
1000 | 921 |
1001 (defun mh-extract-from-attribution () | 922 (defun mh-extract-from-attribution () |
1002 "Extract phrase or comment from From header field." | 923 "Extract phrase or comment from From header field." |
1003 (save-excursion | 924 (save-excursion |
1004 (if (not (mh-goto-header-field "From: ")) | 925 (if (not (mh-goto-header-field "From: ")) |