* mh-comp.el (mh-annotate-msg): Use new variable

mh-scan-field-destination-offset rather than hard-coding 1.

* mh-customize.el (mh-interpret-number-as-range-flag): Add * to
docstring.
(mh-adaptive-cmd-note-flag-check, mh-scan-format-file-check): New
functions to check input for mh-adaptive-cmd-note-flag and
mh-scan-format-file respectively.
(mh-adaptive-cmd-note-flag, mh-scan-format-file): Docstring fixes, add
:set.

* mh-e.el: (mh-scan-field-destination-offset): New variable. The
destination is the -, t, b, c, or n character for Replied, To, cc,
Bcc, or Newsgroups respectively. (mh-make-folder,
mh-regenerate-headers, mh-generate-new-cmd-note) Call new function
mh-msg-num-width-to-column to make leap between width and column more
explicit.
(mh-msg-num-width-to-column): New function that steals logic from old
mh-set-cmd-note. Also, throw error if mh-scan-format-file isn't t
since we can't adapt the scan lines in this case.
(mh-set-cmd-note): Now just simply sets mh-cmd-note which will make
the documentation more clear.
(mh-generate-new-cmd-note): Docstring fix--mh-cmd-note is a column,
not a width.
(mh-add-sequence-notation, mh-remove-sequence-notation): Use new
variable mh-scan-field-destination-offset rather than hard-coding 1.

* mh-utils.el (mh-cmd-note) Synced docstring with manual.
(mh-notate): Use new variable mh-scan-field-destination-offset rather
than hard-coding 1.
(mh-message-number-width): Rename to mh-msg-num-width to be consistent
with mh-get-msg-num and mh-msg-num-width-to-column.
This commit is contained in:
Bill Wohler 2005-10-29 05:09:05 +00:00
parent ec397a34fb
commit 50df64d63f
5 changed files with 114 additions and 41 deletions

View file

@ -1,5 +1,39 @@
2005-10-28 Bill Wohler <wohler@newt.com>
* mh-comp.el (mh-annotate-msg): Use new variable
mh-scan-field-destination-offset rather than hard-coding 1.
* mh-customize.el (mh-interpret-number-as-range-flag): Add * to
docstring.
(mh-adaptive-cmd-note-flag-check, mh-scan-format-file-check): New
functions to check input for mh-adaptive-cmd-note-flag and
mh-scan-format-file respectively.
(mh-adaptive-cmd-note-flag, mh-scan-format-file): Docstring fixes,
add :set.
* mh-e.el: (mh-scan-field-destination-offset): New variable. The
destination is the -, t, b, c, or n character for Replied, To, cc,
Bcc, or Newsgroups respectively.
(mh-make-folder, mh-regenerate-headers, mh-generate-new-cmd-note)
Call new function mh-msg-num-width-to-column to make leap between
width and column more explicit.
(mh-msg-num-width-to-column): New function that steals logic from
old mh-set-cmd-note. Also, throw error if mh-scan-format-file
isn't t since we can't adapt the scan lines in this case.
(mh-set-cmd-note): Now just simply sets mh-cmd-note which will
make the documentation more clear.
(mh-generate-new-cmd-note): Docstring fix--mh-cmd-note is a
column, not a width.
(mh-add-sequence-notation, mh-remove-sequence-notation): Use new
variable mh-scan-field-destination-offset rather than hard-coding
1.
* mh-utils.el (mh-cmd-note) Synced docstring with manual.
(mh-notate): Use new variable mh-scan-field-destination-offset
rather than hard-coding 1.
(mh-message-number-width): Rename to mh-msg-num-width to be
consistent with mh-get-msg-num and mh-msg-num-width-to-column.
* mh-customize.el (mh-x-face-file, mh-show-use-xface-flag)
(mail-citation-hook): Quote URLs in docstrings and precede with
`URL'. The former will suppress checkdoc warnings, the latter will

View file

@ -698,7 +698,8 @@ MSG can be a message number, a list of message numbers, or a sequence."
(cond ((get-buffer buffer) ; Buffer may be deleted
(set-buffer buffer)
(mh-iterate-on-range nil msg
(mh-notate nil note (1+ mh-cmd-note)))))))
(mh-notate nil note
(+ mh-cmd-note mh-scan-field-destination-offset)))))))
(defun mh-insert-fields (&rest name-values)
"Insert the NAME-VALUES pairs in the current buffer.

View file

@ -948,7 +948,7 @@ is added to the yanked region."
;;; Ranges (:group 'mh-ranges)
(defcustom mh-interpret-number-as-range-flag t
"On means interpret a number as a range.
"*On means interpret a number as a range.
Since one of the most frequent ranges used is \"last:N\", MH-E will interpret
input such as \"200\" as \"last:200\" if this option is on (which is the
default). If you need to scan just the message 200, then use the range
@ -960,18 +960,44 @@ default). If you need to scan just the message 200, then use the range
;;; Scan Line Formats (:group 'mh-scan-line-formats)
;;; Forward definition to avoid compiler and runtime error.
(defvar mh-scan-format-file t)
(defun mh-adaptive-cmd-note-flag-check (symbol value)
"Check if desired setting is legal.
Throw an error if user tries to turn on `mh-adaptive-cmd-note-flag' when
`mh-scan-format-file' isn't t. Otherwise, set SYMBOL to VALUE."
(if (and value
(not (eq mh-scan-format-file t)))
(error "%s %s" "Can't turn on unless mh-scan-format-file"
"is set to \"Use MH-E scan Format\"")
(set-default symbol value)))
(defun mh-scan-format-file-check (symbol value)
"Check if desired setting is legal.
Throw an error if user tries to set `mh-scan-format-file' to anything but t
when `mh-adaptive-cmd-note-flag' is on. Otherwise, set SYMBOL to VALUE."
(if (and (not (eq value t))
(eq mh-adaptive-cmd-note-flag t))
(error "%s %s" "You must turn off mh-adaptive-cmd-note-flag"
"unless you use \"Use MH-E scan Format\"")
(set-default symbol value)))
(defcustom mh-adaptive-cmd-note-flag t
"*On means that the message number width is determined dynamically.
If you've created your own format to handle long message numbers, you'll be
pleased to know you no longer need it since MH-E adapts its internal format
based upon the largest message number if this option is on (the default).
This option may only be turned on when `mh-scan-format-file' is set to \"Use
MH-E scan Format\".
If you prefer fixed-width message numbers, turn off this option and call
`mh-set-cmd-note' with the width specified by your format file (see
`mh-scan-format-file'). For example, the default width is 4, so you would use
\"(mh-set-cmd-note 4)\"."
`mh-set-cmd-note' with the width specified by your format file
\(see `mh-scan-format-file'). For example, the default width is 4, so you would
use \"(mh-set-cmd-note 4)\"."
:type 'boolean
:group 'mh-scan-line-formats)
:group 'mh-scan-line-formats
:set 'mh-adaptive-cmd-note-flag-check)
(defcustom mh-scan-format-file t
"Specifies the format file to pass to the scan program.
@ -979,7 +1005,10 @@ If you prefer fixed-width message numbers, turn off this option and call
The default setting for this option is \"Use MH-E scan Format\". This means
that the format string will be taken from the either `mh-scan-format-mh' or
`mh-scan-format-nmh' depending on whether MH or nmh (or GNU mailutils) is in
use. You can also set this option to \"Use Default scan Format\" to get the
use. This setting also enables you to turn on the `mh-adaptive-cmd-note-flag'
option.
You can also set this option to \"Use Default scan Format\" to get the
same output as you would get if you ran \"scan\" from the shell. If you have a
format file that you want MH-E to use but not MH, you can set this option to
\"Specify a scan Format File\" and enter the name of your format file.
@ -987,15 +1016,13 @@ format file that you want MH-E to use but not MH, you can set this option to
If you change the format of the scan lines you'll need to tell MH-E how to
parse the new format. As you will see, quite a lot of variables are involved
to do that. Use \"\\[apropos] RET mh-scan.*regexp\" to obtain a list of these
variables. You may also have to call `mh-set-cmd-note' to modify `mh-cmd-note'
with the column for your notations if you turn off
`mh-adaptive-cmd-note-flag'. However, you will need to set the `mh-cmd-note'
variable manually with `setq' if `mh-scan-format-file' is set to anything
other than \"Use MH-E scan Format\"."
variables. You will also have to call `mh-set-cmd-note' if your notations are
not in column 4 (columns in Emacs start with 0)."
:type '(choice (const :tag "Use MH-E scan Format" t)
(const :tag "Use Default scan Format" nil)
(file :tag "Specify a scan Format File"))
:group 'mh-scan-line-formats)
:group 'mh-scan-line-formats
:set 'mh-scan-format-file-check)
(defcustom mh-scan-prog "scan"
"*Program used to scan messages.

View file

@ -114,7 +114,7 @@ The string is displayed after the folder's name. nil for no annotation.")
;; The following scan formats are passed to the scan program if the setting of
;; `mh-scan-format-file' is t. They are identical except the later one makes
;; use of the nmh `decode' function to decode RFC 2047 encodings. If you just
;; want to change the width of the msg number, use the `mh-set-cmd-note'
;; want to change the column of the notations, use the `mh-set-cmd-note'
;; function.
(defvar mh-scan-format-mh
@ -338,6 +338,10 @@ originator, or a \"To: address\" for outgoing e-mail messages.")
"Number of columns consumed by whitespace after from-mbox in `mh-scan-format'.
This column will only ever have spaces in it.")
(defvar mh-scan-field-destination-offset
(+ mh-scan-cmd-note-width)
"The offset from the `mh-cmd-note' for the destination column.")
(defvar mh-scan-field-from-start-offset
(+ mh-scan-cmd-note-width
mh-scan-destination-width
@ -1402,7 +1406,7 @@ Make it the current folder."
(setq buffer-read-only nil)
(erase-buffer)
(if mh-adaptive-cmd-note-flag
(mh-set-cmd-note (mh-message-number-width name)))
(mh-set-cmd-note (mh-msg-num-width-to-column (mh-msg-num-width name))))
(setq buffer-read-only t)
(mh-folder-mode)
(mh-set-folder-modified-p nil)
@ -1719,20 +1723,24 @@ Return in the folder's buffer."
(when (mh-outstanding-commands-p)
(mh-notate-deleted-and-refiled)))
(defun mh-set-cmd-note (width)
"Set `mh-cmd-note' to WIDTH (minimum of 2).
(defun mh-msg-num-width-to-column (width)
"Return the column for notations given message number WIDTH.
Note that columns in Emacs start with 0.
If `mh-scan-format-file' is set to \"Use Default scan Format\" or \"Specify a
scan Format File\", then this function will NOT update `mh-cmd-note'. In these
cases, the user should change `mh-cmd-note' with `setq' if necessary.
If `mh-scan-format-file' is set to \"Use MH-E scan Format\" this means that
either `mh-scan-format-mh' or `mh-scan-format-nmh' are in use. This function
therefore assumes that the first column is empty (to provide room for the
cursor), the following WIDTH columns contain the message number, and the
column for notations comes after that."
(if (eq mh-scan-format-file t)
(max (1+ width) 2)
(error "%s %s" "Can't call mh-msg-num-width-to-column"
"when mh-scan-format-file is not t")))
(defun mh-set-cmd-note (column)
"Set `mh-cmd-note' to COLUMN.
Note that columns in Emacs start with 0."
;; Add one to the width to always have whitespace in column zero.
(setq width (max (1+ width) 2))
(if (and (equal mh-scan-format-file t)
(not (eq mh-cmd-note width)))
(setq mh-cmd-note width))
mh-cmd-note)
(setq mh-cmd-note column))
(defun mh-regenerate-headers (range &optional update)
"Scan folder over range RANGE.
@ -1747,7 +1755,8 @@ If UPDATE, append the scan lines, otherwise replace."
(goto-char (point-max))
(delete-region (point-min) (point-max))
(if mh-adaptive-cmd-note-flag
(mh-set-cmd-note (mh-message-number-width folder))))
(mh-set-cmd-note (mh-msg-num-width-to-column (mh-msg-num-width
folder)))))
(setq scan-start (point))
(apply #'mh-exec-cmd-output
mh-scan-prog nil
@ -1781,9 +1790,9 @@ If UPDATE, append the scan lines, otherwise replace."
After doing an `mh-get-new-mail' operation in this FOLDER, at least
one line that looks like a truncated message number was found.
Remove the text added by the last `mh-inc' command. It should be the
messages cur-last. Call `mh-set-cmd-note' with the widest message number
in FOLDER.
Remove the text added by the last `mh-inc' command. It should be the messages
cur-last. Call `mh-set-cmd-note', adjusting the notation column with the width
of the largest message number in FOLDER.
Reformat the message number width on each line in the buffer and trim
the line length to fit in the window.
@ -1800,7 +1809,7 @@ line now with no message truncation."
(delete-char (- (point-max) (point)))
;; Update the current buffer to reflect the new mh-cmd-note
;; value needed to display messages.
(mh-set-cmd-note (mh-message-number-width folder))
(mh-set-cmd-note (mh-msg-num-width-to-column (mh-msg-num-width folder)))
(setq mh-cmd-note-fmt (concat "%" (format "%d" mh-cmd-note) "d"))
;; Cleanup the messages that are in the buffer right now
(goto-char (point-min))
@ -1958,11 +1967,12 @@ turned on."
(mh-notate nil nil mh-cmd-note)
(when font-lock-mode
(font-lock-fontify-region (point) (line-end-position))))
(forward-char (1+ mh-cmd-note))
(forward-char (+ mh-cmd-note mh-scan-field-destination-offset))
(let ((stack (gethash msg mh-sequence-notation-history)))
(setf (gethash msg mh-sequence-notation-history)
(cons (char-after) stack)))
(mh-notate nil mh-note-seq (1+ mh-cmd-note))))))
(mh-notate nil mh-note-seq
(+ mh-cmd-note mh-scan-field-destination-offset))))))
(defun mh-remove-sequence-notation (msg internal-seq-flag &optional all)
"Remove sequence notation from the MSG on the current line.
@ -1981,7 +1991,7 @@ If ALL is non-nil, then all sequence marks on the scan line are removed."
(when stack
(save-excursion
(beginning-of-line)
(forward-char (1+ mh-cmd-note))
(forward-char (+ mh-cmd-note mh-scan-field-destination-offset))
(delete-char 1)
(insert (car stack))))
(setf (gethash msg mh-sequence-notation-history) (cdr stack))))))

View file

@ -111,10 +111,9 @@ It is a format string; use `%d' to represent the location of the message
number within the expression as in the default of \"^[^0-9]*%d[^0-9]\".")
(defvar mh-cmd-note 4
"Column where notations begin.
"Column for notations.
This variable should be set with the function `mh-set-cmd-note'. This variable
may be updated dynamically if `mh-adaptive-cmd-note-flag' is on and
`mh-scan-format-file' is set to \"Use MH-E scan Format\".
may be updated dynamically if `mh-adaptive-cmd-note-flag' is on.
Note that columns in Emacs start with 0.")
(make-variable-buffer-local 'mh-cmd-note)
@ -1827,8 +1826,10 @@ If NOTATION is nil then no change in the buffer occurs."
(with-mh-folder-updating (t)
(beginning-of-line)
(forward-char offset)
(let* ((change-stack-flag (and (equal offset (1+ mh-cmd-note))
(not (eq notation mh-note-seq))))
(let* ((change-stack-flag
(and (equal offset
(+ mh-cmd-note mh-scan-field-destination-offset))
(not (eq notation mh-note-seq))))
(msg (and change-stack-flag (or msg (mh-get-msg-num nil))))
(stack (and msg (gethash msg mh-sequence-notation-history)))
(notation (or notation (char-after))))
@ -1992,8 +1993,8 @@ The message number width portion of the format is discovered using
(substring fmt end))))
fmt))
(defun mh-message-number-width (folder)
"Return the widest message number in this FOLDER."
(defun mh-msg-num-width (folder)
"Return the width of the largest message number in this FOLDER."
(or mh-progs (mh-find-path))
(let ((tmp-buffer (get-buffer-create mh-temp-buffer))
(width 0))