[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ebdb 957fc1b 157/350: Implement popping of buffer searc
From: |
Eric Abrahamsen |
Subject: |
[elpa] externals/ebdb 957fc1b 157/350: Implement popping of buffer search history |
Date: |
Mon, 14 Aug 2017 11:46:26 -0400 (EDT) |
branch: externals/ebdb
commit 957fc1bc2dd2a58c88f7b141512412b61259c9dd
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>
Implement popping of buffer search history
Closes #12
* ebdb-com.el (ebdb-search-history): New buffer-local defvar holding
search history for this EBDB buffer. Search history is a list of
record uuids.
(ebdb-search-display): When running user-initiated searches in an
existing EBDB buffer, store the list of previously-displayed
records.
(ebdb-display-records): Don't call `ebdb-mode' if we're already in
it, as that wipes local variables.
(ebdb-search-pop): New command for popping history.
* ebdb.org: Document in manual.
---
ebdb-com.el | 35 ++++++++++++++++++++++++++++++-----
ebdb.org | 5 +++++
2 files changed, 35 insertions(+), 5 deletions(-)
diff --git a/ebdb-com.el b/ebdb-com.el
index 2cac6f0..1a51e41 100644
--- a/ebdb-com.el
+++ b/ebdb-com.el
@@ -160,6 +160,14 @@ Used by `ebdb-mouse-menu'."
In the *EBDB* buffers it includes the records that are actually displayed
and its elements are (RECORD DISPLAY-FORMAT MARKER-POS MARK).")
+(defvar-local ebdb-search-history nil
+ "A list of lists of previously-displayed EBDB records in this buffer.
+
+For each search in a user-initiated EBDB buffer, the
+previously-displayed EBDB records are pushed here, as a list of
+UUIDs. ebdb-mode keybindings make it possible to pop back to
+previous records.")
+
(defvar ebdb-modeline-info (make-vector 2 nil)
"Precalculated mode line info for EBDB commands.
This is a vector [INVERT-M INVERT].
@@ -316,6 +324,7 @@ display information."
(define-key km (kbd "/ D") 'ebdb-search-database)
(define-key km (kbd "C-x n w") 'ebdb-display-all-records)
(define-key km (kbd "C-x n d") 'ebdb-display-current-record)
+ (define-key km (kbd "^") 'ebdb-search-pop)
(define-key km [mouse-3] 'ebdb-mouse-menu)
(define-key km [mouse-2] (lambda (event)
@@ -676,7 +685,8 @@ name based on the current major mode."
(sort (delete-dups (append records existing))
(lambda (x y) (ebdb-record-lessp x y))))))
- (ebdb-mode)
+ (unless (derived-mode-p 'ebdb-mode)
+ (ebdb-mode))
(setq ebdb-records
(mapcar (lambda (r)
@@ -903,7 +913,8 @@ displayed records."
["New creation date" ebdb-creation-newer t]
["Creation date = time stamp" ebdb-creation-no-change t]
"--"
- ["Invert search" ebdb-search-invert t])
+ ["Invert search" ebdb-search-invert t]
+ ["Pop search history" ebdb-search-pop t])
("Mail"
["Send mail" ebdb-mail t]
"--"
@@ -1883,13 +1894,17 @@ appended to existing records, or filtered from existing
records.
TYPE is the type of search being conducted (ie, 'name, 'mail,
'address, etc). CRIT is the search criteria; often a regexp, but
not necessarily. FMT is the optional formatter to use."
- (let* ((pool (if (eql style 'filter)
- (mapcar #'car ebdb-records)
+ (let* ((prev (mapcar #'car ebdb-records))
+ (pool (if (eql style 'filter)
+ prev
(ebdb-records)))
(invert (ebdb-search-invert-p))
(recs (ebdb-search pool clauses invert)))
(if recs
- (ebdb-display-records recs fmt (eql style 'append))
+ (progn
+ (when prev
+ (push (mapcar #'ebdb-record-uuid prev) ebdb-search-history))
+ (ebdb-display-records recs fmt (eql style 'append)))
(message "No matching records"))))
;;;###autoload
@@ -2091,6 +2106,16 @@ FUNCTION is called with one argument, the record, and
should return
the record to be displayed or nil otherwise."
(ebdb-display-records (seq-filter function (ebdb-records)) fmt))
+(defun ebdb-search-pop ()
+ "Pop to the last set of EBDB search results."
+ (interactive)
+ (if ebdb-search-history
+ (ebdb-display-records
+ (mapcar (lambda (r)
+ (ebdb-gethash r 'uuid))
+ (pop ebdb-search-history)))
+ (message "No further search history in this buffer.")))
+
;;; Send-Mail interface
;;;###autoload
diff --git a/ebdb.org b/ebdb.org
index 023b479..8bd1a14 100644
--- a/ebdb.org
+++ b/ebdb.org
@@ -368,6 +368,11 @@ Search commands that currently only work with the "/"
prefix are:
- "/ d": Search duplicate records
- "/ D": Prompt for a database and display all records belonging to
that database
+
+User-created {{{ebuf}}} buffers keep track of search history in that
+buffer. To pop back to previous searches, use:
+
+- "^": ebdb-search-pop
** Marking
Records can be marked and acted on in bulk. The "#" key will toggle
the mark of the record under point. "M-#" will toggle the marks of
- [elpa] externals/ebdb f9d5af6 243/350: Add close parenthesis to email regexp delimiter, (continued)
- [elpa] externals/ebdb f9d5af6 243/350: Add close parenthesis to email regexp delimiter, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 4882f66 238/350: Include addresses in vcard output, plus escaping, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 440cb9e 245/350: More search functions can use prefixes: mention in manual, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb c8bdb70 194/350: Don't assume Chinese names have both surname and given-names, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 212a1e1 212/350: Snarfing shouldn't pop up its own window, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb fc813dd 193/350: Yet more fixes to proper name formatting, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 06123d9 217/350: Make sure database files are decoded as utf-8-emacs, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb c07babf 203/350: If alt-names search fails, fall back on actual name field search, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 501edfb 149/350: Give Org mode its own popup window, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 0612d92 153/350: Comment out ebdb-mua-auto-snarf-signature, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 957fc1b 157/350: Implement popping of buffer search history,
Eric Abrahamsen <=
- [elpa] externals/ebdb 3cb827e 181/350: Check for existence of fiel-attribute-modification-time, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb aabe2c0 189/350: Stupid mistake in previous commit, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 6549647 198/350: More tests, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb f316417 202/350: Change keybinding for ebdb-prev-field, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb bfc5d9d 208/350: Internationalized ebdb-parse method for names must accept slots arg, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 0c2056c 209/350: Basic tests for EBDB's internationalization support, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 2bfb04e 220/350: Move ebdb-message-search to ebdb.el, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 40d71b9 222/350: Steal UUID generating function from Org, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 4937cbd 225/350: Specify class of name fields when updating from MUA, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 13c0a38 216/350: Tweaks to testing macros, more tests, Eric Abrahamsen, 2017/08/14