🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.vm.bug
Article #18

problem with FCC in vm-5.32 (beta)

#18
From: Frank Siebenlist
Date: Wed, 15 Apr 1992 06:16
162 lines
6115 bytes
First a compliment: nice mail reader, I use it every day.

Now one "bug" and a feature request.

*Problem.
I am using the FCC feature of emacs-mail to archive my outgoing messages.
If I want to send a mail, while reading the mailbox that stores my outgoing
messages, I get an error message:

Buffer is read-only: #<buffer mbox.out>

When I exit my vm-session with that mailbox, all works well.
Not sure if the problem is with mail or vm, but you're the experts...

*New feature.
Let me see the senders in the summary for incoming mail, and the recipients for outgoing mail.

I could not find any format specifier for this so I looked into the code.
Please find attached some code which redefines the function "vm-compile-format" (vm-summary.el).
The changes are minor: a format option "B" is added which works similar to "F" and "T".
If option "B" is chosen, the new function "vm-su-full-to-from-name" will be called (eventually).
This new function checks if the "from"-name equals the login name,
if it does "vm-su-to-names" is called, otherwise it calls "vm-su-full-name". 
This gives you the "T" behavior for incoming and the "F" behavior for outgoing.

Hope you find it useful.

Rgds, Frank.

_________________________________________________________________________________________________

; hack to make vm display the senders for incoming mail and the recipients for outgoing.
; introduces new format specifier B
; in .emacs, load this after vm and add:
; (setq vm-summary-format "%2n %*%a %-17.17B %-3.3m %2d %4l/%-5c \"%s\"\n")

(require 'vm)

; see if login name equals from-name, if so display recipients instead of senders.
(defun vm-su-full-to-from-name (m)
  (if (string-equal (user-login-name)
		    (or (vm-from-of m)
			(progn (vm-su-do-author m) (vm-from-of m))))
      (vm-su-to-names m)
    (vm-su-full-name m)))

; minor changes to original (vm-summary.el) 
; add "B" format specifier plus its handler
; 1 line changed and 3 lines added
(defun vm-compile-format (format-variable)
  (let ((format (symbol-value format-variable))
	sexp sexp-fmt conv-spec last-match-end case-fold-search)
    (store-match-data nil)
    (while (string-match
"%\\(-\\)?\\([0-9]\\)*\\(\\.\\([0-9]+\\)\\)?\\([aABcdfFhilmMnstTwyz*%]\\)"
	    format (match-end 0))
      (setq conv-spec (aref format (match-beginning 5)))
      (if (memq conv-spec '(?a ?A ?B ?c ?d ?f ?F ?h ?i ?l ?M  ;; added ?B here
			    ?m ?n ?s ?t ?T ?w ?y ?z ?*))
	  (progn
	    (cond ((= conv-spec ?a)
		   (setq sexp (cons (list 'vm-su-attribute-indicators
					  'vm-su-message) sexp)))
		  ((= conv-spec ?A)
		   (setq sexp (cons (list 'vm-su-attribute-indicators-long
					  'vm-su-message) sexp)))
		  ;; new option B
		  ((= conv-spec ?B)
		   (setq sexp (cons (list 'vm-su-full-to-from-name
					  'vm-su-message) sexp)))
		  ((= conv-spec ?c)
		   (setq sexp (cons (list 'vm-su-byte-count
					  'vm-su-message) sexp)))
		  ((= conv-spec ?d)
		   (setq sexp (cons (list 'vm-su-monthday
					  'vm-su-message) sexp)))
		  ((= conv-spec ?f)
		   (setq sexp (cons (list 'vm-su-from
					  'vm-su-message) sexp)))
		  ((= conv-spec ?F)
		   (setq sexp (cons (list 'vm-su-full-name
					  'vm-su-message) sexp)))
		  ((= conv-spec ?h)
		   (setq sexp (cons (list 'vm-su-hour
					  'vm-su-message) sexp)))
		  ((= conv-spec ?i)
		   (setq sexp (cons (list 'vm-su-message-id
					  'vm-su-message) sexp)))
		  ((= conv-spec ?l)
		   (setq sexp (cons (list 'vm-su-line-count
					  'vm-su-message) sexp)))
		  ((= conv-spec ?m)
		   (setq sexp (cons (list 'vm-su-month
					  'vm-su-message) sexp)))
		  ((= conv-spec ?M)
		   (setq sexp (cons (list 'vm-su-month-number
					  'vm-su-message) sexp)))
		  ((= conv-spec ?n)
		   (setq sexp (cons (list 'vm-su-message-number
					  'vm-su-message) sexp)))
		  ((= conv-spec ?s)
		   (setq sexp (cons (list 'vm-su-subject
					  'vm-su-message) sexp)))
		  ((= conv-spec ?T)
		   (setq sexp (cons (list 'vm-su-to-names
					  'vm-su-message) sexp)))
		  ((= conv-spec ?t)
		   (setq sexp (cons (list 'vm-su-to
					  'vm-su-message) sexp)))
		  ((= conv-spec ?w)
		   (setq sexp (cons (list 'vm-su-weekday
					  'vm-su-message) sexp)))
		  ((= conv-spec ?y)
		   (setq sexp (cons (list 'vm-su-year
					  'vm-su-message) sexp)))
		  ((= conv-spec ?z)
		   (setq sexp (cons (list 'vm-su-zone
					  'vm-su-message) sexp)))
		  ((= conv-spec ?*)
		   (setq sexp (cons (list 'vm-su-mark
					  'vm-su-message) sexp))))
	    (cond ((match-beginning 1)
		   (setcar sexp
			   (list 'vm-left-justify-string (car sexp)
				 (string-to-int (substring format
							   (match-beginning 2)
							   (match-end 2))))))
		  ((match-beginning 2)
		   (setcar sexp
			   (list 'vm-right-justify-string (car sexp)
				 (string-to-int (substring format
							   (match-beginning 2)
							   (match-end 2)))))))
	    (cond ((match-beginning 3)
		   (setcar sexp
			   (list 'vm-truncate-string (car sexp)
				 (string-to-int (substring format
							   (match-beginning 4)
							   (match-end 4)))))))
	    (setq sexp-fmt
		  (cons "%s"
			(cons (substring format
					 (or last-match-end 0)
					 (match-beginning 0))
			      sexp-fmt))))
	(setq sexp-fmt
	      (cons "%%"
		    (cons (substring format
				     (or last-match-end 0)
				     (match-beginning 0))
			  sexp-fmt))))
      (setq last-match-end (match-end 0)))
    (setq sexp-fmt 
	  (cons (substring format
			   (or last-match-end 0)
			   (length format))
		sexp-fmt)
	  sexp-fmt (apply 'concat (nreverse sexp-fmt))
	  sexp (cons 'format (cons sexp-fmt (nreverse sexp))))
    (put format-variable 'vm-format-sexp sexp)
    (put format-variable 'vm-compiled-format format)))
Technical Details
Message-ID: <9204150616.AA06254@aptp74.citihk.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!wendy-fate.uu.net!bug-vm

Show Full Headers
Complete Article Headers
Newsgroups: gnu.emacs.vm.bug
Sender: bug-vm-request@uunet.uu.net
Date: Wed, 15 Apr 92 14:16:45 HKT
From: frank@citihk.com (Frank Siebenlist)
Message-ID: <9204150616.AA06254@aptp74.citihk.com>
Subject: problem with FCC in vm-5.32 (beta)
Path: arc1-ca.pugleaf.net!sparky!uunet!wendy-fate.uu.net!bug-vm
Lines: 163