Article View: gnu.emacs.vm.bug
Article #9113regexps for headers in vm-auto-folder-alist
From: Roland McGrath
Date: Fri, 20 Mar 1992 21:48
Date: Fri, 20 Mar 1992 21:48
64 lines
2779 bytes
2779 bytes
This patch to 5.32 lets you use regexps to match the headers in
vm-auto-folder-alist. I found myself having several lists for each header,
to get the ordering I wanted. Using regexps can be much more concise.
cd /usr/local/lib/elisp/vm-5.32beta/
diff -u /usr/local/lib/elisp/vm-5.32beta/vm-summary.el.\~1\~ /usr/local/lib/elisp/vm-5.32beta/vm-summary.el
--- /usr/local/lib/elisp/vm-5.32beta/vm-summary.el.~1~ Wed Mar 4 02:33:34 1992
+++ /usr/local/lib/elisp/vm-5.32beta/vm-summary.el Fri Mar 20 16:38:50 1992
@@ -364,9 +364,36 @@
(put format-variable 'vm-format-sexp sexp)
(put format-variable 'vm-compiled-format format)))
+;; from v19 compile.el -- roland@gnu.ai.mit.edu
+(defun count-regexp-groupings (regexp)
+ "Return the number of \\( ... \\) groupings in REGEXP (a string)."
+ (let ((groupings 0)
+ (len (length regexp))
+ (i 0)
+ c)
+ (while (< i len)
+ (setq c (aref regexp i)
+ i (1+ i))
+ (cond ((= c ?\[)
+ ;; Find the end of this [...].
+ (while (and (< i len)
+ (not (= (aref regexp i) ?\])))
+ (setq i (1+ i))))
+ ((= c ?\\)
+ (if (< i len)
+ (progn
+ (setq c (aref regexp i)
+ i (1+ i))
+ (if (= c ?\))
+ ;; We found the end of a grouping,
+ ;; so bump our counter.
+ (setq groupings (1+ groupings))))))))
+ groupings))
+
(defun vm-get-header-contents (message header-name)
- (let (contents regexp)
- (setq regexp (format vm-header-regexp-format header-name))
+ (let ((regexp (format vm-header-regexp-format header-name))
+ (subexpr (1+ (count-regexp-groupings header-name)))
+ contents)
(save-excursion
(set-buffer (marker-buffer (vm-start-of message)))
(save-restriction
@@ -377,9 +404,11 @@
(setq contents
(concat
contents ", "
- (buffer-substring (match-beginning 1) (match-end 1))))
+ (buffer-substring (match-beginning subexpr)
+ (match-end subexpr))))
(setq contents
- (buffer-substring (match-beginning 1) (match-end 1)))))
+ (buffer-substring (match-beginning subexpr)
+ (match-end subexpr)))))
contents))))
(defun vm-left-justify-string (string width)
diff exited abnormally with code 1 at Fri Mar 20 17:39:30
Technical Details
Message-ID:
<9203202148.AA29083@geech.gnu.ai.mit.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!wendy-fate.uu.net!bug-vmShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f6829,662511b28514cdbe,start X-Google-Attributes: gidf6829,public X-Google-ArrivalTime: 1992-03-15 22:23:26 PST Newsgroups: gnu.emacs.vm.bug Sender: bug-vm-request@uunet.uu.net Date: Fri, 20 Mar 92 16:48:48 -0500 From: roland@gnu.ai.mit.edu (Roland McGrath) Message-ID: <9203202148.AA29083@geech.gnu.ai.mit.edu> Subject: regexps for headers in vm-auto-folder-alist Path: arc1-ca.pugleaf.net!sparky!uunet!wendy-fate.uu.net!bug-vm