Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

bug#11131: 24.0.94; Apropos bookmarks

8 views
Skip to first unread message

Jambunathan K

unread,
Mar 30, 2012, 4:26:49 AM3/30/12
to 11...@debbugs.gnu.org

Please provide an ido-like completion read for C-x r b.

Please provide a convenient default for C-x r m. You can work out the
details.

Some context:

As a developer, I used to use cscope to browse C code. Whenever I jump
to a symbol definition using cscope, I had a small hook which would
automatically set the bookmark at the function definition, with the
bookmark name given by the which-function or the symbol that I looked up
in the first place.

/very long time back/, I had used one of the completion packages
(icomplete?, pcomplete?, mcomplete?) to enable ido-like completion for
bookmark names.

In GNU Emacs 24.0.94.1 (i386-mingw-nt5.1.2600)
of 2012-03-19 on MARVIN
Windowing system distributor `Microsoft Corp.', version 5.1.2600
Configured using:
`configure --with-gcc (4.6) --no-opt --enable-checking --cflags
-ID:/devel/emacs/libs/libXpm-3.5.8/include
-ID:/devel/emacs/libs/libXpm-3.5.8/src
-ID:/devel/emacs/libs/libpng-dev_1.4.3-1/include
-ID:/devel/emacs/libs/zlib-dev_1.2.5-2/include
-ID:/devel/emacs/libs/giflib-4.1.4-1/include
-ID:/devel/emacs/libs/jpeg-6b-4/include
-ID:/devel/emacs/libs/tiff-3.8.2-1/include
-ID:/devel/emacs/libs/gnutls-3.0.9/include'



Stefan Monnier

unread,
Mar 30, 2012, 8:45:59 AM3/30/12
to Jambunathan K, 11...@debbugs.gnu.org
> Please provide an ido-like completion read for C-x r b.

It's a bit late to change things for 24.1, but for 24.2 we can adjust.
Which part of "ido-like" would you like to see there?

> Please provide a convenient default for C-x r m. You can work out the
> details.

C-x r m already provides a default, so could you give some more details
as to what kind of default would be more "convenient"?


Stefan



Jambunathan K

unread,
Sep 11, 2012, 4:11:08 AM9/11/12
to Stefan Monnier, 11...@debbugs.gnu.org
Use case:
========

I mark frequently used functions with `C-x r m' and I create a bookmark
to that function name using something like this in .emacs.

(defadvice bookmark-set
(around my-bookmark-set (name no-overwrite))
(ad-set-arg 0 (which-function))
(ad-set-arg 1 nil)
(message "Bookmark: %s" (ad-get-arg 0))
ad-do-it)

(ad-activate 'bookmark-set)

With a simple ido-like completion (or iswitchb-like completion), I can
jump to the function name quickly without typing the whole function
name.

(Indicative) patch
==================

This is not an actual patch. Something like this will do.

=== modified file 'lisp/bookmark.el'
--- lisp/bookmark.el 2012-08-08 08:48:57 +0000
+++ lisp/bookmark.el 2012-09-11 08:03:37 +0000
@@ -433,7 +433,7 @@ the empty string."
(format " (%s): " default)
": ")))
(str
- (completing-read prompt
+ (ido-completing-read prompt
bookmark-alist
nil
0

Gnus also does it
=================

Gnus also tries to achieve the same thing - that which I am trying to do
wrt bookmarks - by it's own private user variable.


,---- from gnus-util.el :: L43
| (defcustom gnus-completing-read-function 'gnus-emacs-completing-read
| "Function use to do completing read."
| :version "24.1"
| :group 'gnus-meta
| :type `(radio (function-item
| :doc "Use Emacs standard `completing-read' function."
| gnus-emacs-completing-read)
| ;; iswitchb.el is very old and ido.el is unavailable
| ;; in XEmacs, so we exclude those function items.
| ,@(unless (featurep 'xemacs)
| '((function-item
| :doc "Use `ido-completing-read' function."
| gnus-ido-completing-read)
| (function-item
| :doc "Use iswitchb based completing-read function."
| gnus-iswitchb-completing-read)))))
`----

There is another way to do it
=============================

Have bookmark use completing-read-function. Then I can set it to use
ido-completing-read.

,----[ C-h v completing-read-function RET ]
| completing-read-function is a variable defined in `minibuffer.el'.
| Its value is completing-read-default
|
| This variable may be risky if used as a file-local variable.
|
| Documentation:
| The function called by `completing-read' to do its work.
| It should accept the same arguments as `completing-read'.
|
| [back]
`----

Question
========

Now the question is, what is the best way to kill multiple mangoes with
a single stone and not allow above customizations to proliferate on
per-package basis.




--



Stefan Monnier

unread,
Sep 11, 2012, 9:18:59 AM9/11/12
to Jambunathan K, 11...@debbugs.gnu.org
> With a simple ido-like completion (or iswitchb-like completion), I can
> jump to the function name quickly without typing the whole function
> name.

Again: "Which part of "ido-like" would you like to see there?".
IDO completion has many differences compared to Emacs's historical
prefix-completion. But Emacs's current default completion code supports
several of those features.

E.g. in Emacs-24, C-x b provides substring completion (and if you
enable icomplete-mode which just shows you the list of completion
candidates at the end of the minibuffer, it gets even closer to
iswitchb).

> - (completing-read prompt
> + (ido-completing-read prompt

That is not an option: we want the completion behavior to be consistent,
and there's nothing magical about bookmarks which justifies a thoroughly
different behavior, I think.
OTOH, maybe bookmarks have particular properties which justify tweaking
the completion behavior for them, just like it is the case for C-x b.
E.g. we could make C-x r b use substring completion.

> Have bookmark use completing-read-function.

It does, since it calls completing-read which in turn calls the
completing-read-function.


Stefan



Jambunathan K

unread,
Sep 11, 2012, 12:52:50 PM9/11/12
to Stefan Monnier, 11...@debbugs.gnu.org

>> With a simple ido-like completion (or iswitchb-like completion), I can
>> jump to the function name quickly without typing the whole function
>> name.
>
> Again: "Which part of "ido-like" would you like to see there?".

The answer has to be how the UI works (i.e., how I *interact* with the
completion mechanism and not how completions are computed.)

It would be wonderful if -

All aspects of completion happens right within the mini-buffer.

With the default interface the following are turn-offs (which is pretty
much everything)

- TAB,
- work window getting split in to two
- Using mouse or RET for final choice

> IDO completion has many differences compared to Emacs's historical
> prefix-completion. But Emacs's current default completion code supports
> several of those features.
>
> E.g. in Emacs-24, C-x b provides substring completion (and if you
> enable icomplete-mode which just shows you the list of completion
> candidates at the end of the minibuffer, it gets even closer to
> iswitchb).
>
>> - (completing-read prompt
>> + (ido-completing-read prompt
>
> That is not an option: we want the completion behavior to be consistent,
> and there's nothing magical about bookmarks which justifies a thoroughly
> different behavior, I think.
> OTOH, maybe bookmarks have particular properties which justify tweaking
> the completion behavior for them, just like it is the case for C-x b.
> E.g. we could make C-x r b use substring completion.

Since my bookmarks are function names, substring completion is what I
desire. (Many functions share the *same* prefix)

[Context Switch] I think having a standard hook to choose the default
name of bookmark will also be useful. In prog-modes, I will probably
set it to which-function.

>> Have bookmark use completing-read-function.
>
> It does, since it calls completing-read which in turn calls the
> completing-read-function.

May be there is a reason why completing-read-function is not
customizable?

> Stefan



Stefan Monnier

unread,
Sep 11, 2012, 2:04:28 PM9/11/12
to Jambunathan K, 11...@debbugs.gnu.org
>>> With a simple ido-like completion (or iswitchb-like completion),
>>> I can jump to the function name quickly without typing the whole
>>> function name.
>> Again: "Which part of "ido-like" would you like to see there?".
> The answer has to be how the UI works (i.e., how I *interact* with the
> completion mechanism and not how completions are computed.)

In that case the change can't be active by default because that would be
incompatible with our desire for a consistent completion UI.

> It would be wonderful if -
> All aspects of completion happens right within the mini-buffer.
> With the default interface the following are turn-offs (which is pretty
> much everything)
> - TAB,
> - work window getting split in to two
> - Using mouse or RET for final choice

I'm not exactly sure about what you mean by the above. IDO still uses
TAB and RET in mostly similar ways to the default UI, and still splits
the window when displaying the *Completions* buffer.

Have you tried icomplete-mode?

> Since my bookmarks are function names, substring completion is what I
> desire. (Many functions share the *same* prefix)

It seems this can't be changed by customizing
completion-category-overrides right now, so we'll need to change
bookmark.el's completion table to provide a `category'.

> [Context Switch] I think having a standard hook to choose the default
> name of bookmark will also be useful. In prog-modes, I will probably
> set it to which-function.

Sounds fine. Patch welcome.

>>> Have bookmark use completing-read-function.
>> It does, since it calls completing-read which in turn calls the
>> completing-read-function.
> May be there is a reason why completing-read-function is not
> customizable?

You can customize it, just not with Custom. No particular reason.


Stefan



Juri Linkov

unread,
Sep 11, 2012, 3:29:15 PM9/11/12
to Stefan Monnier, 11...@debbugs.gnu.org, Jambunathan K
>> [Context Switch] I think having a standard hook to choose the default
>> name of bookmark will also be useful. In prog-modes, I will probably
>> set it to which-function.
>
> Sounds fine. Patch welcome.

Bug#12107 added a new parameter for the default bookmark names.
So `bookmark-make-record-default' could be modified to set its value
from the result of a function defined by a new customizable variable
(where `which-function' could be one of its possible value).



Stefan Monnier

unread,
Oct 26, 2012, 1:35:40 PM10/26/12
to Jambunathan K, 11...@debbugs.gnu.org
>> Again: "Which part of "ido-like" would you like to see there?".
> With the default interface the following are turn-offs (which is pretty
> much everything)
> - TAB,
> - work window getting split in to two
> - Using mouse or RET for final choice

IIUC, you're looking into making icomplete provide what you need, so
this is tracked elsewhere now.

> Since my bookmarks are function names, substring completion is what I
> desire. (Many functions share the *same* prefix)

I haven't changed the default, but I have added a `category' of
`bookmark', so you can use substring completion simply by customizing
completion-category-overrides.

> [Context Switch] I think having a standard hook to choose the default
> name of bookmark will also be useful. In prog-modes, I will probably
> set it to which-function.

I'd be happy to install patch that goes along these lines (tho I'd probably
prefer "filename:functionname").

>>> Have bookmark use completing-read-function.
>> It does, since it calls completing-read which in turn calls the
>> completing-read-function.
> May be there is a reason why completing-read-function is not
> customizable?

Yes: it's expected to be modified by Lisp code rather than via
a Custom setting. The Customize UI wouldn't be able to provide much
guidance as to what value the user could want to put there.


Stefan



Jambunathan K

unread,
Oct 26, 2012, 4:11:59 PM10/26/12
to Stefan Monnier, 11...@debbugs.gnu.org
Stefan Monnier <mon...@iro.umontreal.ca> writes:

>> Since my bookmarks are function names, substring completion is what I
>> desire. (Many functions share the *same* prefix)
>
> I haven't changed the default, but I have added a `category' of
> `bookmark', so you can use substring completion simply by customizing
> completion-category-overrides.

Thanks for this patch.

Good news:
I can confirm that `substring' for `bookmark' category works.

(custom-set-variables
'(completion-category-overrides
(quote ((buffer (styles basic substring))
(bookmark (styles substring))))))

Bad news:
`icomplete-mode' never kicks in for `C-x r b' (even with default
setting of `completion-category-overrides'). Once I reverse your
changes icomplete-mode kicks in.

$ bzr merge . -r 110680..110679

Something is surely amiss.

Request:
Following patch advertizes new category.

bug11131.diff

Stefan Monnier

unread,
Oct 26, 2012, 4:45:01 PM10/26/12
to Jambunathan K, 11...@debbugs.gnu.org
> `icomplete-mode' never kicks in for `C-x r b' (even with default
> setting of `completion-category-overrides'). Once I reverse your
> changes icomplete-mode kicks in.
> $ bzr merge . -r 110680..110679
> Something is surely amiss.

(setq icomplete-with-completion-tables t)

> Request:
> Following patch advertizes new category.

Thanks, installed,


Stefan



0 new messages