On 2011-04-29 22:51 +0800, Roland Winkler wrote:
> On Fri Apr 29 2011 Leo wrote:
>> >From 97e6adcdd8813d9f857972f0e5f5ba5bbb2fc406 Mon Sep 17 00:00:00 2001
>> Date: Fri, 29 Apr 2011 14:41:51 +0800
>> Subject: [PATCH] Default to current record in bbdb-completing-read-records
>>
>> For example, this is useful for `/ 1' to quickly limit to current
>> record.
>
> I am not sure whether the patch is a good way to achieve your goal
>
> - If it's useful under whatever circumstances to have a default
> value for completion, I'd prefer to make this an optional arg for
> a function like bbdb-completing-read-records. Then it is up to the
> caller to bind this to something useful.
>
> For example bbdb-merge-records calls bbdb-completing-read-records
> to determine which record to merge with the current record. So
> making the current record the default would not be useful here.
>
> Also, the default should be spelled out in the prompt.
I use ido-completing-read for nearly everything completing-related so I
almost forget about this. How about the attached patch?
> - If a proposed use of all this is limiting to the current record,
> then it appears much cleaner to me if there is a dedicated command
> for that purpose which does not require to confirm in the
> minibuffer that the current record is really what the user wants.
>
> And I am just curious: when can all this come handy?
I use C-s a lot since it is standard key binding. I use it to move to
the record I need. I don't need to remember what field I am searching
since everything displayed can be searched. When point is at the right
record, sometimes I want to omit all other records (sort of like C-x n
n) to help me focus.
Putting it on a different command is overkill and adding one more key
binding to remember is a burden on the user.
> - You talk about `/ 1' having replaced already the keybinding `S 1' :-)
Sorry about this. It is a typo and I only realised it after sending the
post.
> I was surprised: I tried to find some other emacs mode that is
> doing something similar to BBDB's search command so that possibly
> BBDB could use similar keybindings. But I couldn't find anything.
> Am I missing something?
>
> (I'd consider Gnus' limiting commands actually slightly different
> from BBDB's search commands. The limiting commands reduce what is
> displayed. BBDB's search commands increase what is displayed.)
`/' to mean search is quite established, firefox and its OSX variant
Camino uses it. There is also ibuffer in addition to gnus:
iBuffer Bindings Starting With /:
key binding
--- -------
/ TAB ibuffer-exchange-filters
/ ! ibuffer-negate-filter
/ / ibuffer-filter-disable
/ < ibuffer-filter-by-size-lt
/ > ibuffer-filter-by-size-gt
/ D ibuffer-decompose-filter-group
/ M ibuffer-filter-by-used-mode
/ P ibuffer-pop-filter-group
/ R ibuffer-switch-to-saved-filter-groups
/ S ibuffer-save-filter-groups
/ X ibuffer-delete-saved-filter-groups
/ \ ibuffer-clear-filter-groups
/ a ibuffer-add-saved-filters
/ c ibuffer-filter-by-content
/ d ibuffer-decompose-filter
/ e ibuffer-filter-by-predicate
/ f ibuffer-filter-by-filename
/ g ibuffer-filters-to-filter-group
/ m ibuffer-filter-by-mode
/ n ibuffer-filter-by-name
/ o ibuffer-or-filter
/ p ibuffer-pop-filter
/ r ibuffer-switch-to-saved-filters
/ s ibuffer-save-filters
/ t ibuffer-exchange-filters
/ x ibuffer-delete-saved-filters
> As I said, I am not opposed to changing the keybindings in the
> proposed way. I am just surprised that I don't know any other
> Emacs mode we could compare with.
>
> Roland
Leo
---
lisp/bbdb-com.el | 19 ++++++++++---------
lisp/bbdb.el | 11 +++++++++--
2 files changed, 19 insertions(+), 11 deletions(-)
Modified lisp/bbdb-com.el
diff --git a/lisp/bbdb-com.el b/lisp/bbdb-com.el
index 9fad0cb7..dd444fdd 100644
--- a/lisp/bbdb-com.el
+++ b/lisp/bbdb-com.el
@@ -1932,21 +1932,22 @@ (defun bbdb-completion-predicate (symbol)
(if (string= sym (downcase mail))
(throw 'done t)))))))))))
-(defun bbdb-completing-read-records (prompt &optional omit-records)
+(defun bbdb-completing-read-records (prompt &optional omit-records default)
"Prompt for and return list of records from the bbdb.
Completion is done according to `bbdb-completion-list'. If the user
just hits return, nil is returned. Otherwise, a valid response is forced."
(let* ((completion-ignore-case t)
(string (completing-read prompt bbdb-hashtable
- 'bbdb-completion-predicate t))
+ 'bbdb-completion-predicate
+ t nil nil default))
symbol ret)
- (unless (string= "" string)
- (setq symbol (intern-soft string bbdb-hashtable))
- (if (and (boundp symbol) (symbol-value symbol))
- (dolist (record (symbol-value symbol) (delete-dups ret))
- (if (not (memq record omit-records))
- (push record ret)))
- (error "Selecting deleted (unhashed) record \"%s\"" symbol)))))
+ (unless (string= "" string)
+ (setq symbol (intern-soft string bbdb-hashtable))
+ (if (and (boundp symbol) (symbol-value symbol))
+ (dolist (record (symbol-value symbol) (delete-dups ret))
+ (if (not (memq record omit-records))
+ (push record ret)))
+ (error "Selecting deleted (unhashed) record \"%s\"" symbol)))))
(defun bbdb-completing-read-record (prompt &optional omit-records)
"Prompt for and return a single record from the bbdb;
Modified lisp/bbdb.el
diff --git a/lisp/bbdb.el b/lisp/bbdb.el
index 243ab82f..235f732e 100644
--- a/lisp/bbdb.el
+++ b/lisp/bbdb.el
@@ -2349,8 +2349,15 @@ (defun bbdb-display-record (record layout number)
(defun bbdb-display-records (&optional records layout append
select horiz-p electric-p)
"Display RECORDS using LAYOUT."
- (interactive (list (bbdb-completing-read-records "Display records: ")
- (bbdb-layout-prefix)))
+ (interactive
+ (let ((default (ignore-errors
+ (downcase (bbdb-record-name (bbdb-current-record))))))
+ (list (bbdb-completing-read-records
+ (if default
+ (format "Display records (default %s): " default)
+ "Display records: ")
+ nil default)
+ (bbdb-layout-prefix))))
(let ((bbdb-window (get-buffer-window bbdb-buffer-name)))
;; Never be electric if the buffer is already on screen.
(if (and (not bbdb-window)
------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network
management toolset available today. Delivers lowest initial
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
bbdb-info@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/