[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Outgoing message importance?



At Fri, 10 Dec 2010 10:48:27 +0800,
James Harkins wrote:
> 
> I searched the info pages and FAQ in vain and can't find how to set
> the importance of an outgoing message.
> 
> Manually type this into the headers?
> 
> X-Priority: 1
> 
> Any keybinding?
> 
I did once implement my own header adding code, when I wanted to set a
Return-Receipt-To header. It's probably a bit crude, and maybe
replicates some existing functionality:


  (defvar rjl/wl-draft-insert-header-hook nil)
  (defvar rjl/wl-recognised-headers '("To" "CC" "BCC" "From" "Subject" "User-Agent" "Fcc" "Reply-To" "Return-Receipt-To"))

  (defun rjl/wl-draft-insert-header (header-name header-value)
    (interactive
     (let* ((h-n (completing-read "Header: " rjl/wl-recognised-headers))
  	  (h-v (read-from-minibuffer "Value: " (rjl/wl-draft-get-header h-n))))
       (list h-n h-v)))
    (save-excursion
      (goto-char (point-min))
      (let ((header-separator-point (search-forward mail-header-separator nil t))
  	  (existing-header (rjl/wl-draft-get-header header-name)))
        (goto-char (point-min))
        (if existing-header
  	  (wl-user-agent-insert-header header-name header-value)
  	(progn
  	  (search-forward mail-header-separator nil t)
  	  (beginning-of-line)
  	  (rjl/wl-draft-insert-header-here header-name header-value)))
        (wl-highlight-headers 'for-draft)
        (run-hooks 'rjl/wl-draft-insert-header-hook))))

  (defun rjl/wl-draft-insert-header-here (header-name header-value)
    (insert header-name ": " header-value "\n"))

  (defun rjl/wl-draft-disposition-notification (return-address)
    (interactive (read-from-minibuffer "Return address: " (wl-address-header-extract-address wl-from)))
    (rjl/wl-draft-insert-header "Return-Receipt-To" return-address))

  (defun rjl/wl-draft-get-header (header-name)
    (save-excursion
      (goto-char (point-min))
      (let ((header-separator-point (search-forward mail-header-separator nil t)))
        (goto-char (point-min))
        (let ((existing-header-point (search-forward-regexp (concat "^" header-name ":") header-separator-point t))
              (next-header-point (if (search-forward-regexp "^[A-Za-z-]: " header-separator-point t)
                                     (progn (beginning-of-line) (point))
                                   nil)))
          (cond ((null existing-header-point) nil)
                (t (buffer-substring
                  (+ existing-header-point 1)
                  (if (null next-header-point) (progn (end-of-line) (point)) (- next-header-point 1)))))))))

  (add-hook 'wl-draft-mode-hook
            (lambda ()
              (define-key wl-draft-mode-map (kbd "C-c h") 'rjl/wl-draft-insert-header)
              (define-key wl-draft-mode-map (kbd "C-c d") 'rjl/wl-draft-disposition-notification)))

So now in wl-draft-mode C-c h prompts for a header name and then
value, and then inserts the header.

Best,
Richard
-- 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Richard Lewis
ISMS, Computing
Goldsmiths, University of London
JID: ironchicken@jabber.earth.li
http://www.richardlewis.me.uk/
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-