Mercurial > emacs
diff lisp/mh-e/mh-seq.el @ 67758:6b063593fdad
Follow Emacs coding conventions. Use default setting of
emacs-lisp-docstring-fill-column which is 65.
author | Bill Wohler <wohler@newt.com> |
---|---|
date | Fri, 23 Dec 2005 07:40:40 +0000 |
parents | 3a8785724cca |
children | 9c3504ae6060 |
line wrap: on
line diff
--- a/lisp/mh-e/mh-seq.el Fri Dec 23 05:40:21 2005 +0000 +++ b/lisp/mh-e/mh-seq.el Fri Dec 23 07:40:40 2005 +0000 @@ -122,16 +122,18 @@ "Map of message index to various parts of the scan line.") (defvar mh-thread-scan-line-map-stack nil "Old map of message index to various parts of the scan line. -This is the original map that is stored when the folder is narrowed.") +This is the original map that is stored when the folder is +narrowed.") (defvar mh-thread-subject-container-hash nil "Hashtable used to group messages by subject.") (defvar mh-thread-duplicates nil "Hashtable used to associate messages with the same message identifier.") (defvar mh-thread-history () "Variable to remember the transformations to the thread tree. -When new messages are added, these transformations are rewound, then the -links are added from the newly seen messages. Finally the transformations are -redone to get the new thread tree. This makes incremental threading easier.") +When new messages are added, these transformations are rewound, +then the links are added from the newly seen messages. Finally +the transformations are redone to get the new thread tree. This +makes incremental threading easier.") (defvar mh-thread-body-width nil "Width of scan substring that contains subject and body of message.") @@ -150,9 +152,10 @@ (defun mh-delete-seq (sequence) "Delete SEQUENCE. -You are prompted for the sequence to delete. Note that this deletes only the -sequence, not the messages in the sequence. If you want to delete the -messages, use \"\\[universal-argument] \\[mh-delete-msg]\"." +You are prompted for the sequence to delete. Note that this +deletes only the sequence, not the messages in the sequence. If +you want to delete the messages, use \"\\[universal-argument] +\\[mh-delete-msg]\"." (interactive (list (mh-read-seq-default "Delete" t))) (let ((msg-list (mh-seq-to-msgs sequence)) (internal-flag (mh-internal-seq sequence)) @@ -216,8 +219,8 @@ ;;;###mh-autoload (defun mh-msg-is-in-seq (message) "Display the sequences in which the current message appears. -Use a prefix argument to display the sequences in which another MESSAGE -appears." +Use a prefix argument to display the sequences in which another +MESSAGE appears." (interactive "P") (if (not message) (setq message (mh-get-msg-num t))) @@ -243,11 +246,13 @@ (defun mh-narrow-to-seq (sequence) "Restrict display to messages in SEQUENCE. -You are prompted for the name of the sequence. What this command does is show -only those messages that are in the selected sequence in the MH-Folder buffer. -In addition, it limits further MH-E searches to just those messages. +You are prompted for the name of the sequence. What this command +does is show only those messages that are in the selected +sequence in the MH-Folder buffer. In addition, it limits further +MH-E searches to just those messages. -When you want to widen the view to all your messages again, use \\[mh-widen]." +When you want to widen the view to all your messages again, use +\\[mh-widen]." (interactive (list (mh-read-seq "Narrow to" t))) (with-mh-folder-updating (t) (cond ((mh-seq-to-msgs sequence) @@ -283,14 +288,17 @@ (defun mh-put-msg-in-seq (range sequence) "Add RANGE to SEQUENCE\\<mh-folder-mode-map>. -To place a message in a sequence, use this command to do it manually, or use -the MH command \"pick\" or the MH-E version of \"pick\", \\[mh-search-folder], -which create a sequence automatically. +To place a message in a sequence, use this command to do it +manually, or use the MH command \"pick\" or the MH-E version of +\"pick\", \\[mh-search-folder], which create a sequence +automatically. -Give this command a RANGE and you can add all the messages in a sequence to -another sequence (for example, \"\\[universal-argument] \\[mh-put-msg-in-seq] -SourceSequence RET DestSequence RET\"). Check the documentation of -`mh-interactive-range' to see how RANGE is read in interactive use." +Give this command a RANGE and you can add all the messages in a +sequence to another sequence (for example, +\"\\[universal-argument] \\[mh-put-msg-in-seq] SourceSequence RET +DestSequence RET\"). Check the documentation of +`mh-interactive-range' to see how RANGE is read in interactive +use." (interactive (list (mh-interactive-range "Add messages from") (mh-read-seq-default "Add to" nil))) (unless (mh-valid-seq-p sequence) @@ -321,7 +329,8 @@ ;;;###mh-autoload (defun mh-widen (&optional all-flag) "Remove last restriction. -If optional prefix argument ALL-FLAG is non-nil, remove all limits." +If optional prefix argument ALL-FLAG is non-nil, remove all +limits." (interactive "P") (let ((msg (mh-get-msg-num nil))) (when mh-folder-view-stack @@ -368,8 +377,8 @@ ;;;###mh-autoload (defun mh-notate-deleted-and-refiled () "Notate messages marked for deletion or refiling. -Messages to be deleted are given by `mh-delete-list' while messages to be -refiled are present in `mh-refile-list'." +Messages to be deleted are given by `mh-delete-list' while +messages to be refiled are present in `mh-refile-list'." (let ((refiled-hash (make-hash-table)) (deleted-hash (make-hash-table))) (dolist (msg mh-delete-list) @@ -395,17 +404,18 @@ ;;;###mh-autoload (defun mh-read-seq-default (prompt not-empty) "Read and return sequence name with default narrowed or previous sequence. -PROMPT is the prompt to use when reading. If NOT-EMPTY is non-nil then a -non-empty sequence is read." +PROMPT is the prompt to use when reading. If NOT-EMPTY is non-nil +then a non-empty sequence is read." (mh-read-seq prompt not-empty (or mh-last-seq-used (car (mh-seq-containing-msg (mh-get-msg-num nil) nil))))) (defun mh-read-seq (prompt not-empty &optional default) "Read and return a sequence name. -Prompt with PROMPT, raise an error if the sequence is empty and the NOT-EMPTY -flag is non-nil, and supply an optional DEFAULT sequence. A reply of '%' -defaults to the first sequence containing the current message." +Prompt with PROMPT, raise an error if the sequence is empty and +the NOT-EMPTY flag is non-nil, and supply an optional DEFAULT +sequence. A reply of '%' defaults to the first sequence +containing the current message." (let* ((input (completing-read (format "%s %s %s" prompt "sequence:" (if default (format "[%s] " default) @@ -459,35 +469,40 @@ expand-flag ask-flag number-as-range-flag) "Read a message range with PROMPT. -If FOLDER is non-nil then a range is read from that folder, otherwise use -`mh-current-folder'. +If FOLDER is non-nil then a range is read from that folder, otherwise +use `mh-current-folder'. -If DEFAULT is a string then use that as default range to return. If DEFAULT is -nil then ask user with default answer a range based on the sequences that seem -relevant. Finally if DEFAULT is t, try to avoid prompting the user. Unseen -messages, if present, are returned. If the folder has fewer than -`mh-large-folder' messages then \"all\" messages are returned. Finally as a -last resort prompt the user. +If DEFAULT is a string then use that as default range to return. If +DEFAULT is nil then ask user with default answer a range based on the +sequences that seem relevant. Finally if DEFAULT is t, try to avoid +prompting the user. Unseen messages, if present, are returned. If the +folder has fewer than `mh-large-folder' messages then \"all\" messages +are returned. Finally as a last resort prompt the user. -If EXPAND-FLAG is non-nil then a list of message numbers corresponding to the -input is returned. If this list is empty then an error is raised. If -EXPAND-FLAG is nil just return the input string. In this case we don't check -if the range is empty. +If EXPAND-FLAG is non-nil then a list of message numbers corresponding +to the input is returned. If this list is empty then an error is +raised. If EXPAND-FLAG is nil just return the input string. In this +case we don't check if the range is empty. If ASK-FLAG is non-nil, then the user is always queried for a range of -messages. If ASK-FLAG is nil, then the function checks if the unseen sequence -is non-empty. If that is the case, `mh-unseen-seq', or the list of messages in -it depending on the value of EXPAND, is returned. Otherwise if the folder has -fewer than `mh-large-folder' messages then the list of messages corresponding -to \"all\" is returned. If neither of the above holds then as a last resort -the user is queried for a range of messages. +messages. If ASK-FLAG is nil, then the function checks if the unseen +sequence is non-empty. If that is the case, `mh-unseen-seq', or the +list of messages in it depending on the value of EXPAND, is returned. +Otherwise if the folder has fewer than `mh-large-folder' messages then +the list of messages corresponding to \"all\" is returned. If neither +of the above holds then as a last resort the user is queried for a +range of messages. -If NUMBER-AS-RANGE-FLAG is non-nil, then if a number, N is read as input, it -is interpreted as the range \"last:N\". +If NUMBER-AS-RANGE-FLAG is non-nil, then if a number, N is read as +input, it is interpreted as the range \"last:N\". -This function replaces the existing function `mh-read-msg-range'. Calls to: +This function replaces the existing function `mh-read-msg-range'. +Calls to: + (mh-read-msg-range folder flag) + should be replaced with: + (mh-read-range \"Suitable prompt\" folder t nil flag mh-interpret-number-as-range-flag)" (setq default (or default mh-last-seq-used @@ -565,8 +580,9 @@ ;;;###mh-autoload (defun mh-notate-cur () "Mark the MH sequence cur. -In addition to notating the current message with `mh-note-cur' the function -uses `overlay-arrow-position' to put a marker in the fringe." +In addition to notating the current message with `mh-note-cur' +the function uses `overlay-arrow-position' to put a marker in the +fringe." (let ((cur (car (mh-seq-to-msgs 'cur)))) (when (and cur (mh-goto-msg cur t t)) (beginning-of-line) @@ -617,8 +633,9 @@ ;;;###mh-autoload (defmacro mh-iterate-on-messages-in-region (var begin end &rest body) "Iterate over region. -VAR is bound to the message on the current line as we loop starting from BEGIN -till END. In each step BODY is executed. + +VAR is bound to the message on the current line as we loop +starting from BEGIN till END. In each step BODY is executed. If VAR is nil then the loop is executed without any binding." (unless (symbolp var) @@ -639,13 +656,14 @@ (defmacro mh-iterate-on-range (var range &rest body) "Iterate an operation over a region or sequence. -VAR is bound to each message in turn in a loop over RANGE, which can be a -message number, a list of message numbers, a sequence, a region in a cons -cell, or a MH range (something like last:20) in a string. In each iteration, -BODY is executed. +VAR is bound to each message in turn in a loop over RANGE, which +can be a message number, a list of message numbers, a sequence, a +region in a cons cell, or a MH range (something like last:20) in +a string. In each iteration, BODY is executed. -The parameter RANGE is usually created with `mh-interactive-range' -in order to provide a uniform interface to MH-E functions." +The parameter RANGE is usually created with +`mh-interactive-range' in order to provide a uniform interface to +MH-E functions." (unless (symbolp var) (error "Can not bind the non-symbol %s" var)) (let ((binding-needed-flag var) @@ -680,8 +698,8 @@ (defun mh-range-to-msg-list (range) "Return a list of messages for RANGE. -Check the documentation of `mh-interactive-range' to see how RANGE is read in -interactive use." +Check the documentation of `mh-interactive-range' to see how +RANGE is read in interactive use." (let (msg-list) (mh-iterate-on-range msg range (push msg msg-list)) @@ -692,21 +710,21 @@ "Return interactive specification for message, sequence, range or region. By convention, the name of this argument is RANGE. -If variable `transient-mark-mode' is non-nil and the mark is active, then this -function returns a cons-cell of the region. +If variable `transient-mark-mode' is non-nil and the mark is active, +then this function returns a cons-cell of the region. -If optional prefix argument is provided, then prompt for message range with -RANGE-PROMPT. A list of messages in that range is returned. +If optional prefix argument is provided, then prompt for message range +with RANGE-PROMPT. A list of messages in that range is returned. -If a MH range is given, say something like last:20, then a list containing -the messages in that range is returned. +If a MH range is given, say something like last:20, then a list +containing the messages in that range is returned. If DEFAULT non-nil then it is returned. Otherwise, the message number at point is returned. -This function is usually used with `mh-iterate-on-range' in order to provide -a uniform interface to MH-E functions." +This function is usually used with `mh-iterate-on-range' in order to +provide a uniform interface to MH-E functions." (cond ((mh-mark-active-p t) (cons (region-beginning) (region-end))) (current-prefix-arg (mh-read-range range-prompt nil nil t t)) (default default) @@ -720,13 +738,17 @@ ;; 41 for the max size of the subject part. Avoiding this would be desirable. (defun mh-subject-to-sequence (all) "Put all following messages with same subject in sequence 'subject. -If arg ALL is t, move to beginning of folder buffer to collect all messages. +If arg ALL is t, move to beginning of folder buffer to collect all +messages. If arg ALL is nil, collect only messages fron current one on forward. Return number of messages put in the sequence: nil -> there was no subject line. - 0 -> there were no later messages with the same subject (sequence not made) + + 0 -> there were no later messages with the same + subject (sequence not made) + >1 -> the total number of messages including current one." (if (memq 'unthread mh-view-ops) (mh-subject-to-sequence-threaded all) @@ -734,14 +756,17 @@ (defun mh-subject-to-sequence-unthreaded (all) "Put all following messages with same subject in sequence 'subject. -This function only works with an unthreaded folder. If arg ALL is t, move to -beginning of folder buffer to collect all messages. If arg ALL is nil, collect -only messages fron current one on forward. + +This function only works with an unthreaded folder. If arg ALL is +t, move to beginning of folder buffer to collect all messages. If +arg ALL is nil, collect only messages fron current one on +forward. Return number of messages put in the sequence: nil -> there was no subject line. - 0 -> there were no later messages with the same subject (sequence not made) + 0 -> there were no later messages with the same + subject (sequence not made) >1 -> the total number of messages including current one." (if (not (eq major-mode 'mh-folder-mode)) (error "Not in a folder buffer")) @@ -782,12 +807,14 @@ (defun mh-subject-to-sequence-threaded (all) "Put all messages with the same subject in the 'subject sequence. -This function works when the folder is threaded. In this situation the subject -could get truncated and so the normal matching doesn't work. -The parameter ALL is non-nil then all the messages in the buffer are -considered, otherwise only the messages after the current one are taken into -account." +This function works when the folder is threaded. In this +situation the subject could get truncated and so the normal +matching doesn't work. + +The parameter ALL is non-nil then all the messages in the buffer +are considered, otherwise only the messages after the current one +are taken into account." (let* ((cur (mh-get-msg-num nil)) (subject (mh-thread-find-msg-subject cur)) region msgs) @@ -824,9 +851,9 @@ (defun mh-pick-args-list (s) "Form list by grouping elements in string S suitable for pick arguments. -For example, the string \"-subject a b c -from Joe User <user@domain.com>\" -is converted to (\"-subject\" \"a b c\" \"-from\" -\"Joe User <user@domain.com>\"" +For example, the string \"-subject a b c -from Joe User +<user@domain.com>\" is converted to (\"-subject\" \"a b c\" +\"-from\" \"Joe User <user@domain.com>\"" (let ((full-list (split-string s)) current-arg collection arg-list) (while full-list @@ -935,8 +962,8 @@ (defun mh-narrow-to-range (range) "Limit to RANGE. -Check the documentation of `mh-interactive-range' to see how RANGE is read in -interactive use. +Check the documentation of `mh-interactive-range' to see how +RANGE is read in interactive use. Use \\<mh-folder-mode-map>\\[mh-widen] to undo this command." (interactive (list (mh-interactive-range "Narrow to"))) @@ -949,10 +976,11 @@ (defun mh-delete-subject () "Delete messages with same subject\\<mh-folder-mode-map>. -To delete messages faster, you can use this command to delete all the messages -with the same subject as the current message. This command puts these messages -in a sequence named \"subject\". You can undo this action by using \\[mh-undo] -with a prefix argument and then specifying the \"subject\" sequence." +To delete messages faster, you can use this command to delete all +the messages with the same subject as the current message. This +command puts these messages in a sequence named \"subject\". You +can undo this action by using \\[mh-undo] with a prefix argument +and then specifying the \"subject\" sequence." (interactive) (let ((count (mh-subject-to-sequence nil))) (cond @@ -969,13 +997,14 @@ (defun mh-delete-subject-or-thread () "Delete messages with same subject or thread\\<mh-folder-mode-map>. -To delete messages faster, you can use this command to delete all the messages -with the same subject as the current message. This command puts these messages -in a sequence named \"subject\". You can undo this action by using \\[mh-undo] -with a prefix argument and then specifying the \"subject\" sequence. +To delete messages faster, you can use this command to delete all +the messages with the same subject as the current message. This +command puts these messages in a sequence named \"subject\". You +can undo this action by using \\[mh-undo] with a prefix argument +and then specifying the \"subject\" sequence. -However, if the buffer is displaying a threaded view of the folder then this -command behaves like \\[mh-thread-delete]." +However, if the buffer is displaying a threaded view of the +folder then this command behaves like \\[mh-thread-delete]." (interactive) (if (memq 'unthread mh-view-ops) (mh-thread-delete) @@ -1005,8 +1034,8 @@ (defsubst mh-thread-id-container (id) "Given ID, return the corresponding container in `mh-thread-id-table'. -If no container exists then a suitable container is created and the id-table -is updated." +If no container exists then a suitable container is created and +the id-table is updated." (when (not id) (error "1")) (or (gethash id mh-thread-id-table) @@ -1027,9 +1056,9 @@ (defsubst mh-thread-add-link (parent child &optional at-end-p) "Add links so that PARENT becomes a parent of CHILD. -Doesn't make any changes if CHILD is already an ancestor of PARENT. If -optional argument AT-END-P is non-nil, the CHILD is added to the end of the -children list of PARENT." +Doesn't make any changes if CHILD is already an ancestor of +PARENT. If optional argument AT-END-P is non-nil, the CHILD is +added to the end of the children list of PARENT." (let ((parent-container (cond ((null parent) nil) ((mh-thread-container-p parent) parent) (t (mh-thread-id-container parent)))) @@ -1053,8 +1082,8 @@ (defun mh-thread-ancestor-p (ancestor successor) "Return t if ANCESTOR is really an ancestor of SUCCESSOR and nil otherwise. -In the limit, the function returns t if ANCESTOR and SUCCESSOR are the same -containers." +In the limit, the function returns t if ANCESTOR and SUCCESSOR +are the same containers." (block nil (while successor (when (eq ancestor successor) (return t)) @@ -1063,7 +1092,8 @@ (defsubst mh-thread-get-message-container (message) "Return container which has MESSAGE in it. -If there is no container present then a new container is allocated." +If there is no container present then a new container is +allocated." (let* ((id (mh-message-id message)) (container (gethash id mh-thread-id-table))) (cond (container (setf (mh-container-message container) message) @@ -1073,8 +1103,8 @@ (defsubst mh-thread-get-message (id subject-re-p subject refs) "Return appropriate message. -Otherwise update message already present to have the proper ID, SUBJECT-RE-P, -SUBJECT and REFS fields." +Otherwise update message already present to have the proper ID, +SUBJECT-RE-P, SUBJECT and REFS fields." (let* ((container (gethash id mh-thread-id-table)) (message (if container (mh-container-message container) nil))) (cond (message @@ -1103,9 +1133,10 @@ (defsubst mh-thread-prune-subject (subject) "Prune leading Re:'s, Fwd:'s etc. and trailing (fwd)'s from SUBJECT. -If the result after pruning is not the empty string then it is canonicalized -so that subjects can be tested for equality with eq. This is done so that all -the messages without a subject are not put into a single thread." +If the result after pruning is not the empty string then it is +canonicalized so that subjects can be tested for equality with +eq. This is done so that all the messages without a subject are +not put into a single thread." (let ((case-fold-search t) (subject-pruned-flag nil)) ;; Prune subject leader @@ -1128,7 +1159,8 @@ (defun mh-thread-container-subject (container) "Return the subject of CONTAINER. -If CONTAINER is empty return the subject info of one of its children." +If CONTAINER is empty return the subject info of one of its +children." (cond ((and (mh-container-message container) (mh-message-id (mh-container-message container))) (mh-message-subject (mh-container-message container))) @@ -1233,8 +1265,8 @@ (defsubst mh-thread-group-by-subject (roots) "Group the set of message containers, ROOTS based on subject. -Bug: Check for and make sure that something without Re: is made the parent in -preference to something that has it." +Bug: Check for and make sure that something without Re: is made +the parent in preference to something that has it." (clrhash mh-thread-subject-container-hash) (let ((results ())) (dolist (root roots) @@ -1251,9 +1283,9 @@ (defun mh-thread-process-in-reply-to (reply-to-header) "Extract message id's from REPLY-TO-HEADER. -Ideally this should have some regexp which will try to guess if a string -between < and > is a message id and not an email address. For now it will -take the last string inside angles." +Ideally this should have some regexp which will try to guess if a +string between < and > is a message id and not an email address. +For now it will take the last string inside angles." (let ((end (mh-search-from-end ?> reply-to-header))) (when (numberp end) (let ((begin (mh-search-from-end ?< (substring reply-to-header 0 end)))) @@ -1279,9 +1311,9 @@ (defsubst mh-thread-update-id-index-maps (id index) "Message with id, ID is the message in INDEX. -The function also checks for duplicate messages (that is multiple messages -with the same ID). These messages are put in the `mh-thread-duplicates' hash -table." +The function also checks for duplicate messages (that is multiple +messages with the same ID). These messages are put in the +`mh-thread-duplicates' hash table." (let ((old-index (gethash id mh-thread-id-index-map))) (when old-index (push old-index (gethash id mh-thread-duplicates))) (setf (gethash id mh-thread-id-index-map) index) @@ -1383,9 +1415,9 @@ (defun mh-thread-generate-scan-lines (tree level) "Generate scan lines. -TREE is the hierarchical tree of messages, SCAN-LINE-MAP maps message indices -to the corresponding scan lines and LEVEL used to determine indentation of -the message." +TREE is the hierarchical tree of messages, SCAN-LINE-MAP maps +message indices to the corresponding scan lines and LEVEL used to +determine indentation of the message." (cond ((null tree) nil) ((mh-thread-container-p tree) (let* ((message (mh-container-message tree)) @@ -1436,8 +1468,9 @@ ;; the scan which generates the threading info. For now this will have to do. (defun mh-thread-parse-scan-line (&optional string) "Parse a scan line. -If optional argument STRING is given then that is assumed to be the scan line. -Otherwise uses the line at point as the scan line to parse." +If optional argument STRING is given then that is assumed to be +the scan line. Otherwise uses the line at point as the scan line +to parse." (let* ((string (or string (buffer-substring-no-properties (line-beginning-position) (line-end-position)))) @@ -1583,7 +1616,8 @@ (defun mh-thread-next-sibling (&optional previous-flag) "Display next sibling. -With non-nil optional argument PREVIOUS-FLAG jump to the previous sibling." +With non-nil optional argument PREVIOUS-FLAG jump to the previous +sibling." (interactive) (cond ((not (memq 'unthread mh-view-ops)) (error "Folder isn't threaded")) @@ -1632,9 +1666,10 @@ (defun mh-thread-ancestor (&optional thread-root-flag) "Display ancestor of current message. -If you do not care for the way a particular thread has turned, you can move up -the chain of messages with this command. This command can also take a prefix -argument THREAD-ROOT-FLAG to jump to the message that started everything." +If you do not care for the way a particular thread has turned, +you can move up the chain of messages with this command. This +command can also take a prefix argument THREAD-ROOT-FLAG to jump +to the message that started everything." (interactive "P") (beginning-of-line) (cond ((not (memq 'unthread mh-view-ops)) @@ -1652,8 +1687,9 @@ (defun mh-thread-find-children () "Return a region containing the current message and its children. -The result is returned as a list of two elements. The first is the point at the -start of the region and the second is the point at the end." +The result is returned as a list of two elements. The first is +the point at the start of the region and the second is the point +at the end." (beginning-of-line) (if (eobp) nil @@ -1744,10 +1780,11 @@ (defun mh-narrow-to-tick () "Limit to ticked messages. -What this command does is show only those messages that are in the \"tick\" -sequence (which you can customize via the `mh-tick-seq' option) in the -MH-Folder buffer. In addition, it limits further MH-E searches to just those -messages. When you want to widen the view to all your messages again, use +What this command does is show only those messages that are in +the \"tick\" sequence (which you can customize via the +`mh-tick-seq' option) in the MH-Folder buffer. In addition, it +limits further MH-E searches to just those messages. When you +want to widen the view to all your messages again, use \\[mh-widen]." (interactive) (cond ((not mh-tick-seq)