Function: mh-generate-new-cmd-note

mh-generate-new-cmd-note is a byte-compiled function defined in mh-folder.el.gz.

Signature

(mh-generate-new-cmd-note FOLDER)

Documentation

Fix the mh-cmd-note value for this FOLDER.

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, 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.

Rescan the FOLDER in the range cur-last in order to display the messages that were removed earlier. They should all fit in the scan line now with no message truncation.

Source Code

;; Defined in /usr/src/emacs/lisp/mh-e/mh-folder.el.gz
(defun mh-generate-new-cmd-note (folder)
  "Fix the `mh-cmd-note' value for this FOLDER.

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', 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.

Rescan the FOLDER in the range cur-last in order to display the
messages that were removed earlier. They should all fit in the scan
line now with no message truncation."
  (save-excursion
    (let ((maxcol (1- (window-width)))
          (old-cmd-note mh-cmd-note)
          mh-cmd-note-fmt
          msgnum)
      ;; Nuke all of the lines just added by the last inc
      (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-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))
      (cond ((memq 'unthread mh-view-ops)
             (mh-thread-add-spaces (- mh-cmd-note old-cmd-note)))
            (t (while (re-search-forward (mh-scan-msg-number-regexp) nil 0 1)
                 ;; reformat the number to fix in mh-cmd-note columns
                 (setq msgnum (string-to-number
                               (buffer-substring
                                (match-beginning 1) (match-end 1))))
                 (replace-match (format mh-cmd-note-fmt msgnum))
                 ;; trim the line to fix in the window
                 (end-of-line)
                 (let ((eol (point)))
                   (move-to-column maxcol)
                   (if (<= (point) eol)
                       (delete-char (- eol (point))))))))
      ;; now re-read the lost messages
      (goto-char (point-max))
      (prog1 (point)
        (mh-regenerate-headers "cur-last" t)))))