]> git.eshelyaron.com Git - emacs.git/commitdiff
* mh-comp.el (mh-annotate-msg): Use new variable
authorBill Wohler <wohler@newt.com>
Sat, 29 Oct 2005 05:09:05 +0000 (05:09 +0000)
committerBill Wohler <wohler@newt.com>
Sat, 29 Oct 2005 05:09:05 +0000 (05:09 +0000)
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.

lisp/mh-e/ChangeLog
lisp/mh-e/mh-comp.el
lisp/mh-e/mh-customize.el
lisp/mh-e/mh-e.el
lisp/mh-e/mh-utils.el

index c0c953b5d09a2c1e6ea6749c9c63b72d286bbf20..54732241f0edff5642dd96a85b7128dd12acfda4 100644 (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
index 4b670bdd8253955f5dd3ee3182db0e65741ba857..232c0399c036c18f8e8cff2d59878d12304314da 100644 (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.
index 7c28ede3c8142d2184de0a50852b2fef7e796997..a79c10cb4e52a05f99b6cfa967b9f9b04a082b77 100644 (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.
index c442947b789afec1b89e8d673f367528be7e9761..dc67cce51c5d32cb5076b5b84e77e4b1acf1bbc2 100644 (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).
-
-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.
-
+(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 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))))))
index 87f521d605a2da2241fa9117dc8efd70d70a4264..169ccf2a0d5eee651018a15947bbb95dad28d0ec 100644 (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))