unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#11131: 24.0.94; Apropos bookmarks
@ 2012-03-30  8:26 Jambunathan K
  2012-03-30 12:45 ` Stefan Monnier
  0 siblings, 1 reply; 10+ messages in thread
From: Jambunathan K @ 2012-03-30  8:26 UTC (permalink / raw)
  To: 11131


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'





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#11131: 24.0.94; Apropos bookmarks
  2012-03-30  8:26 bug#11131: 24.0.94; Apropos bookmarks Jambunathan K
@ 2012-03-30 12:45 ` Stefan Monnier
  2012-09-11  8:11   ` Jambunathan K
  0 siblings, 1 reply; 10+ messages in thread
From: Stefan Monnier @ 2012-03-30 12:45 UTC (permalink / raw)
  To: Jambunathan K; +Cc: 11131

> 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





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#11131: 24.0.94; Apropos bookmarks
  2012-03-30 12:45 ` Stefan Monnier
@ 2012-09-11  8:11   ` Jambunathan K
  2012-09-11 13:18     ` Stefan Monnier
  0 siblings, 1 reply; 10+ messages in thread
From: Jambunathan K @ 2012-09-11  8:11 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 11131

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> 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"?

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.




-- 





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#11131: 24.0.94; Apropos bookmarks
  2012-09-11  8:11   ` Jambunathan K
@ 2012-09-11 13:18     ` Stefan Monnier
  2012-09-11 16:52       ` Jambunathan K
  0 siblings, 1 reply; 10+ messages in thread
From: Stefan Monnier @ 2012-09-11 13:18 UTC (permalink / raw)
  To: Jambunathan K; +Cc: 11131

> 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





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#11131: 24.0.94; Apropos bookmarks
  2012-09-11 13:18     ` Stefan Monnier
@ 2012-09-11 16:52       ` Jambunathan K
  2012-09-11 18:04         ` Stefan Monnier
  2012-10-26 17:35         ` Stefan Monnier
  0 siblings, 2 replies; 10+ messages in thread
From: Jambunathan K @ 2012-09-11 16:52 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 11131


>> 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





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#11131: 24.0.94; Apropos bookmarks
  2012-09-11 16:52       ` Jambunathan K
@ 2012-09-11 18:04         ` Stefan Monnier
  2012-09-11 19:29           ` Juri Linkov
  2012-10-26 17:35         ` Stefan Monnier
  1 sibling, 1 reply; 10+ messages in thread
From: Stefan Monnier @ 2012-09-11 18:04 UTC (permalink / raw)
  To: Jambunathan K; +Cc: 11131

>>> 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





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#11131: 24.0.94; Apropos bookmarks
  2012-09-11 18:04         ` Stefan Monnier
@ 2012-09-11 19:29           ` Juri Linkov
  0 siblings, 0 replies; 10+ messages in thread
From: Juri Linkov @ 2012-09-11 19:29 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 11131, 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).





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#11131: 24.0.94; Apropos bookmarks
  2012-09-11 16:52       ` Jambunathan K
  2012-09-11 18:04         ` Stefan Monnier
@ 2012-10-26 17:35         ` Stefan Monnier
  2012-10-26 20:11           ` Jambunathan K
  1 sibling, 1 reply; 10+ messages in thread
From: Stefan Monnier @ 2012-10-26 17:35 UTC (permalink / raw)
  To: Jambunathan K; +Cc: 11131

>> 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





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#11131: 24.0.94; Apropos bookmarks
  2012-10-26 17:35         ` Stefan Monnier
@ 2012-10-26 20:11           ` Jambunathan K
  2012-10-26 20:45             ` Stefan Monnier
  0 siblings, 1 reply; 10+ messages in thread
From: Jambunathan K @ 2012-10-26 20:11 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 11131

[-- Attachment #1: Type: text/plain, Size: 955 bytes --]

Stefan Monnier <monnier@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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: bug11131.diff --]
[-- Type: text/x-diff, Size: 837 bytes --]

=== modified file 'lisp/ChangeLog'
--- lisp/ChangeLog	2012-10-26 18:01:30 +0000
+++ lisp/ChangeLog	2012-10-26 20:02:27 +0000
@@ -1,3 +1,8 @@
+2012-10-26  Jambunathan K  <kjambunathan@gmail.com>
+
+	* minibuffer.el (completion-category-overrides): New completion
+	category `bookmark' (bug#11131).
+
 2012-10-26  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* emacs-lisp/advice.el (ad-assemble-advised-definition):

=== modified file 'lisp/minibuffer.el'
--- lisp/minibuffer.el	2012-10-25 12:56:13 +0000
+++ lisp/minibuffer.el	2012-10-26 19:58:22 +0000
@@ -743,6 +743,7 @@
 				  (const buffer)
                                   (const file)
                                   (const unicode-name)
+				  (const bookmark)
                                   symbol)
           :value-type
           (set :tag "Properties to override"


^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#11131: 24.0.94; Apropos bookmarks
  2012-10-26 20:11           ` Jambunathan K
@ 2012-10-26 20:45             ` Stefan Monnier
  0 siblings, 0 replies; 10+ messages in thread
From: Stefan Monnier @ 2012-10-26 20:45 UTC (permalink / raw)
  To: Jambunathan K; +Cc: 11131

>     `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





^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2012-10-26 20:45 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-30  8:26 bug#11131: 24.0.94; Apropos bookmarks Jambunathan K
2012-03-30 12:45 ` Stefan Monnier
2012-09-11  8:11   ` Jambunathan K
2012-09-11 13:18     ` Stefan Monnier
2012-09-11 16:52       ` Jambunathan K
2012-09-11 18:04         ` Stefan Monnier
2012-09-11 19:29           ` Juri Linkov
2012-10-26 17:35         ` Stefan Monnier
2012-10-26 20:11           ` Jambunathan K
2012-10-26 20:45             ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).