aboutsummaryrefslogtreecommitdiffhomepage
path: root/emacs/notmuch.el
diff options
context:
space:
mode:
authorGravatar David Edmondson <dme@dme.org>2010-04-29 11:33:36 +0100
committerGravatar Carl Worth <cworth@cworth.org>2010-10-27 17:41:50 -0700
commitc506e1034b5adb54b3e4f8d3e59086756f2bb126 (patch)
tree7fda3e5dc2e837473281c0754994fc791e2294bd /emacs/notmuch.el
parentb67c3ed6094025558ebcdd608735d116a01997f8 (diff)
emacs: Avoid runtime use of `cl'.
The GNU Emacs Lisp Reference Manual section D.1 says: > * Please don't require the cl package of Common Lisp extensions at > run time. Use of this package is optional, and it is not part of > the standard Emacs namespace. If your package loads cl at run time, > that could cause name clashes for users who don't use that package. > > However, there is no problem with using the cl package at compile > time, with (eval-when-compile (require 'cl)). That's sufficient for > using the macros in the cl package, because the compiler expands > them before generating the byte-code. Follow this advice, requiring the following changes where `cl' was used at runtime: - replace `rassoc-if' in `notmuch-search-buffer-title' with the `loop' macro and inline code. At the same time find the longest prefix which matches the query rather than simply the last, - replace `union', `intersection' and `set-difference' in `notmuch-show-add-tag' and `notmuch-show-remove-tag' with local code to calculate the result of adding and removing a list of tags from another list of tags.
Diffstat (limited to 'emacs/notmuch.el')
-rw-r--r--emacs/notmuch.el16
1 files changed, 11 insertions, 5 deletions
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 42619b26..8d69fc87 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -47,7 +47,7 @@
; kudos: Notmuch list <notmuch@notmuchmail.org> (subscription is not
; required, but is available from http://notmuchmail.org).
-(require 'cl)
+(eval-when-compile (require 'cl))
(require 'mm-view)
(require 'message)
@@ -741,10 +741,16 @@ characters as well as `_.+-'.
(defun notmuch-search-buffer-title (query)
"Returns the title for a buffer with notmuch search results."
- (let* ((saved-search (rassoc-if (lambda (key)
- (string-match (concat "^" (regexp-quote key))
- query))
- (reverse (notmuch-saved-searches))))
+ (let* ((saved-search
+ (let (longest
+ (longest-length 0))
+ (loop for tuple in notmuch-saved-searches
+ if (let ((quoted-query (regexp-quote (cdr tuple))))
+ (and (string-match (concat "^" quoted-query) query)
+ (> (length (match-string 0 query))
+ longest-length)))
+ do (setq longest tuple))
+ longest))
(saved-search-name (car saved-search))
(saved-search-query (cdr saved-search)))
(cond ((and saved-search (equal saved-search-query query))