* Any infrastructure to select one of a few options in Emacs core? @ 2016-05-09 10:09 Marcin Borkowski 2016-05-09 14:13 ` Drew Adams 2016-05-14 4:18 ` Emanuel Berg 0 siblings, 2 replies; 18+ messages in thread From: Marcin Borkowski @ 2016-05-09 10:09 UTC (permalink / raw) To: Help Gnu Emacs mailing list Hi all, is there anything in core Emacs (i.e., no Melpa, and preferably no Elpa) to facilitate selecting one of a few (say, up to 10) options, each described in 2-3 lines of text? (I know about the Widget library, but I'd prefer something more lightweight.) TIA, -- Marcin Borkowski http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski Faculty of Mathematics and Computer Science Adam Mickiewicz University ^ permalink raw reply [flat|nested] 18+ messages in thread
* RE: Any infrastructure to select one of a few options in Emacs core? 2016-05-09 10:09 Any infrastructure to select one of a few options in Emacs core? Marcin Borkowski @ 2016-05-09 14:13 ` Drew Adams 2016-05-09 15:40 ` Marcin Borkowski 2016-05-14 4:18 ` Emanuel Berg 1 sibling, 1 reply; 18+ messages in thread From: Drew Adams @ 2016-05-09 14:13 UTC (permalink / raw) To: Marcin Borkowski, Help Gnu Emacs mailing list > is there anything in core Emacs (i.e., no Melpa, and preferably no Elpa) > to facilitate selecting one of a few (say, up to 10) options, each > described in 2-3 lines of text? (I know about the Widget library, but > I'd prefer something more lightweight.) Dunno what you mean. There is menu-bar menu `Options' (which) you can add to. There is Customize, which you can add to with `defcustom'. Specify "facilitate selection one of a few options". ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Any infrastructure to select one of a few options in Emacs core? 2016-05-09 14:13 ` Drew Adams @ 2016-05-09 15:40 ` Marcin Borkowski 2016-05-09 16:37 ` Kaushal Modi 0 siblings, 1 reply; 18+ messages in thread From: Marcin Borkowski @ 2016-05-09 15:40 UTC (permalink / raw) To: Drew Adams; +Cc: Help Gnu Emacs mailing list On 2016-05-09, at 16:13, Drew Adams <drew.adams@oracle.com> wrote: >> is there anything in core Emacs (i.e., no Melpa, and preferably no Elpa) >> to facilitate selecting one of a few (say, up to 10) options, each >> described in 2-3 lines of text? (I know about the Widget library, but >> I'd prefer something more lightweight.) > > Dunno what you mean. There is menu-bar menu `Options' (which) > you can add to. There is Customize, which you can add to > with `defcustom'. > > Specify "facilitate selection one of a few options". Sorry for being imprecise. I'd like to have (kind of) a menu, perhaps in a temporary buffer, displaying a list of options and giving a way to select one of them. Like, say clocking into one of recently clocked tasks in Org, or the main manu in mu4e, or the possible corrections in ispell etc. It seems that a lot of packages use their own mechanism to do something like that; now that I think of it, I guess it would be nice to have a "canonical" way. One advantage would be that by customizing this "default" way, the user could define his/her preferred way of showing the menu/selecting the option for _all_ applications using it. WDYT? Is there anything like that in Emacs? -- Marcin Borkowski http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski Faculty of Mathematics and Computer Science Adam Mickiewicz University ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Any infrastructure to select one of a few options in Emacs core? 2016-05-09 15:40 ` Marcin Borkowski @ 2016-05-09 16:37 ` Kaushal Modi 2016-05-09 17:10 ` Marcin Borkowski 0 siblings, 1 reply; 18+ messages in thread From: Kaushal Modi @ 2016-05-09 16:37 UTC (permalink / raw) To: Marcin Borkowski, Drew Adams, Oleh Krehel; +Cc: Help Gnu Emacs mailing list On Mon, May 9, 2016 at 11:41 AM Marcin Borkowski <mbork@mbork.pl> wrote: > I'd like to have (kind of) a menu, perhaps in a temporary buffer, > displaying a list of options and giving a way to select one of them. > Like, say clocking into one of recently clocked tasks in Org, or the > main manu in mu4e, or the possible corrections in ispell etc. It seems > that a lot of packages use their own mechanism to do something like > that; now that I think of it, I guess it would be nice to have > a "canonical" way. One advantage would be that by customizing this > "default" way, the user could define his/her preferred way of showing > the menu/selecting the option for _all_ applications using it. > > WDYT? Is there anything like that in Emacs? I haven't used it directly. But someone please correct me if I am wrong; doesn't the inbuilt completing-read already do this? Packages like ivy.el have ivy-completing-read which conforms to the default completing-read, and can be easily used to enhance that. -- -- Kaushal Modi ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Any infrastructure to select one of a few options in Emacs core? 2016-05-09 16:37 ` Kaushal Modi @ 2016-05-09 17:10 ` Marcin Borkowski 2016-05-09 17:27 ` Drew Adams 0 siblings, 1 reply; 18+ messages in thread From: Marcin Borkowski @ 2016-05-09 17:10 UTC (permalink / raw) To: Kaushal Modi; +Cc: Help Gnu Emacs mailing list, Oleh Krehel On 2016-05-09, at 18:37, Kaushal Modi <kaushal.modi@gmail.com> wrote: > On Mon, May 9, 2016 at 11:41 AM Marcin Borkowski <mbork@mbork.pl> wrote: > >> I'd like to have (kind of) a menu, perhaps in a temporary buffer, >> displaying a list of options and giving a way to select one of them. >> Like, say clocking into one of recently clocked tasks in Org, or the >> main manu in mu4e, or the possible corrections in ispell etc. It seems >> that a lot of packages use their own mechanism to do something like >> that; now that I think of it, I guess it would be nice to have >> a "canonical" way. One advantage would be that by customizing this >> "default" way, the user could define his/her preferred way of showing >> the menu/selecting the option for _all_ applications using it. >> >> WDYT? Is there anything like that in Emacs? > > > I haven't used it directly. But someone please correct me if I am wrong; > doesn't the inbuilt completing-read already do this? > > Packages like ivy.el have ivy-completing-read which conforms to the default > completing-read, and can be easily used to enhance that. Yes and no. I thought about it, and rejected the idea: I want all the options to be visible without pressing TAB. Also, each option might need more than one line (and the number of lines may vary between options), so I don't like the idea of using minibuffer at all. Thanks anyway, -- Marcin Borkowski http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski Faculty of Mathematics and Computer Science Adam Mickiewicz University ^ permalink raw reply [flat|nested] 18+ messages in thread
* RE: Any infrastructure to select one of a few options in Emacs core? 2016-05-09 17:10 ` Marcin Borkowski @ 2016-05-09 17:27 ` Drew Adams 2016-05-09 18:08 ` Marcin Borkowski 0 siblings, 1 reply; 18+ messages in thread From: Drew Adams @ 2016-05-09 17:27 UTC (permalink / raw) To: Marcin Borkowski, Kaushal Modi; +Cc: Help Gnu Emacs mailing list, Oleh Krehel > > completing-read > > Yes and no. I thought about it, and rejected the idea: I want all the > options to be visible without pressing TAB. Also, each option might > need more than one line (and the number of lines may vary between > options), so I don't like the idea of using minibuffer at all. It's still not clear from your description what you mean by "select" one of the options. Please specify how commands such as `customize', `customize-apropos' do not do what you want. `M-x customize-apropos-options RET .* RET', for example, shows you all currently defined options, together with their doc string first line (and full information if you expand an option description). --- Emacs used to also have a command `edit-options', which listed all options with their doc strings, and which had these keys: Options mode: Major mode for editing Emacs user option settings. Special commands are: s -- set variable point points at. New value read using minibuffer. x -- toggle variable, t -> nil, nil -> t. 1 -- set variable to t. 0 -- set variable to nil. Changed values made by these commands take effect immediately. Each variable description is a paragraph. For convenience, the characters p and n move back and forward by paragraphs. This feature was removed before Emacs 22, however. ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Any infrastructure to select one of a few options in Emacs core? 2016-05-09 17:27 ` Drew Adams @ 2016-05-09 18:08 ` Marcin Borkowski 2016-05-09 18:16 ` Drew Adams 2016-05-09 18:36 ` Pascal J. Bourguignon 0 siblings, 2 replies; 18+ messages in thread From: Marcin Borkowski @ 2016-05-09 18:08 UTC (permalink / raw) To: Drew Adams; +Cc: Help Gnu Emacs mailing list, Oleh Krehel, Kaushal Modi On 2016-05-09, at 19:27, Drew Adams <drew.adams@oracle.com> wrote: >> > completing-read >> >> Yes and no. I thought about it, and rejected the idea: I want all the >> options to be visible without pressing TAB. Also, each option might >> need more than one line (and the number of lines may vary between >> options), so I don't like the idea of using minibuffer at all. > > It's still not clear from your description what you mean by "select" > one of the options. OK, so let us assume that I want the user to select one of the three strings: "spam", "eggs" and "emacs". (Note: in my use case they would not be string literals.) Then, I'd like to be able to say, e.g., something like this: (ask-user-for-option "What would you like to eat?" '("spam" "ham" "eggs")) and have something like --8<---------------cut here---------------start------------->8--- Wat would you like to eat? 1. spam 2. ham 3. eggs --8<---------------cut here---------------end--------------->8--- displayed (perhaps in a *temp* buffer or so), and wait for the user to press 1, 2 or 3. Then, the above form returns the selected string. It would probably be also useful to be able to give it e.g. cons cells with the car being the string and the cdr the value returned in case of selecting this particular string. Also, it should be customizable: one user might like digit keys, another one letters, for instance. Also, the choices should be clickable for those poor souls addicted to rodents. In a more advanced scenario, the menu might be "non-modal", i.e. do not use `read-key' or something like that, but a dynamically crafted mode (probably descendant of special-mode), in which various keys/clicks would launch a callback function given to the hypothetical `ask-user-for-option' with the selected choice as a parameter. Best, -- Marcin Borkowski http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski Faculty of Mathematics and Computer Science Adam Mickiewicz University ^ permalink raw reply [flat|nested] 18+ messages in thread
* RE: Any infrastructure to select one of a few options in Emacs core? 2016-05-09 18:08 ` Marcin Borkowski @ 2016-05-09 18:16 ` Drew Adams 2016-05-19 20:06 ` Marcin Borkowski 2016-05-09 18:36 ` Pascal J. Bourguignon 1 sibling, 1 reply; 18+ messages in thread From: Drew Adams @ 2016-05-09 18:16 UTC (permalink / raw) To: Marcin Borkowski; +Cc: Help Gnu Emacs mailing list, Oleh Krehel, Kaushal Modi > (ask-user-for-option "What would you like to eat?" '("spam" "ham" "eggs")) So this has nothing to do with Emacs _options_. You are asking how to present some choices to a user for selection. ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Any infrastructure to select one of a few options in Emacs core? 2016-05-09 18:16 ` Drew Adams @ 2016-05-19 20:06 ` Marcin Borkowski 2016-05-20 1:16 ` John Mastro 0 siblings, 1 reply; 18+ messages in thread From: Marcin Borkowski @ 2016-05-19 20:06 UTC (permalink / raw) To: Drew Adams; +Cc: Help Gnu Emacs mailing list, Oleh Krehel, Kaushal Modi On 2016-05-09, at 20:16, Drew Adams <drew.adams@oracle.com> wrote: >> (ask-user-for-option "What would you like to eat?" '("spam" "ham" "eggs")) > > So this has nothing to do with Emacs _options_. > > You are asking how to present some choices to a user for > selection. Yes, sorry for the confusion. I went with this code: --8<---------------cut here---------------start------------->8--- (defun select-choice (message choices) "Display a buffer with MESSAGE and then CHOICES. Each element of CHOICES should be a cons cell, whose car is the result and the cdr is the description. The user may select one by pressing a digit." ;; TODO: This function is way too simple and not fool-proof! (if (> (length choices) 9) (error "Too many choices!") (save-window-excursion (pop-to-buffer " *amsrefs doi selection*" t t) (delete-other-windows) ; TODO: this should be fixed (erase-buffer) (insert message "\n\n") (let ((i 0)) (dolist (choice choices) (setq i (1+ i)) (insert (format "%d. %s\n\n" i (cdr choice))))) (let ((key (read-key))) (if (<= 49 key 57) (car (nth (- key 49) choices)) (error "Wrong key pressed!")))))) --8<---------------cut here---------------end--------------->8--- As it is said in the comment, it is far from ideal, but the whole program I've been writing for my friend is one big quick hack, so I didn't bother too much. Still, it would be really nice if Emacs offered a canonical (and configurable) way to do things like that. Best, -- Marcin Borkowski http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski Faculty of Mathematics and Computer Science Adam Mickiewicz University ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Any infrastructure to select one of a few options in Emacs core? 2016-05-19 20:06 ` Marcin Borkowski @ 2016-05-20 1:16 ` John Mastro 2016-05-20 23:52 ` John Mastro 0 siblings, 1 reply; 18+ messages in thread From: John Mastro @ 2016-05-20 1:16 UTC (permalink / raw) To: Help Gnu Emacs mailing list; +Cc: Oleh Krehel, Kaushal Modi Marcin Borkowski <mbork@mbork.pl> wrote: > I went with this code: > > --8<---------------cut here---------------start------------->8--- > (defun select-choice (message choices) > "Display a buffer with MESSAGE and then CHOICES. > Each element of CHOICES should be a cons cell, whose car is the > result and the cdr is the description. The user may select one > by pressing a digit." > ;; TODO: This function is way too simple and not fool-proof! > (if (> (length choices) 9) > (error "Too many choices!") > (save-window-excursion > (pop-to-buffer " *amsrefs doi selection*" t t) > (delete-other-windows) ; TODO: this should be fixed > (erase-buffer) > (insert message "\n\n") > (let ((i 0)) > (dolist (choice choices) > (setq i (1+ i)) > (insert (format "%d. %s\n\n" i (cdr choice))))) > (let ((key (read-key))) > (if (<= 49 key 57) > (car (nth (- key 49) choices)) > (error "Wrong key pressed!")))))) > --8<---------------cut here---------------end--------------->8--- > > As it is said in the comment, it is far from ideal, but the whole > program I've been writing for my friend is one big quick hack, so > I didn't bother too much. I've sometimes wanted something like this too. I played around with a few cosmetic changes to your function and ended up with this: (defun read-choice (prompt choices) (if (> (length choices) 9) (error "Too many choices (max 9)") (let ((cursor-in-echo-area t) (prompt (if (get-text-property 0 'face prompt) prompt (propertize prompt 'face 'minibuffer-prompt)))) (save-window-excursion (pop-to-buffer " *Read choice*" t t) (setq-local cursor-type nil) (erase-buffer) (let ((i 0)) (dolist (choice choices) (setq i (1+ i)) (insert (propertize (number-to-string i) 'face 'font-lock-variable-name-face) (format " %s\n" (cdr choice)))) (goto-char (point-min)) (fit-window-to-buffer) (let ((key (- (read-key prompt) 48))) (if (<= 1 key i) (car (nth (1- key) choices)) (user-error "Invalid key")))))))) Same functionality but posted anyway in the spirit of sharing :) Why did you find `delete-other-windows' necessary? (Your TODO mentions that it should be "fixed", so I assume you would have preferred not to use it.) John ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Any infrastructure to select one of a few options in Emacs core? 2016-05-20 1:16 ` John Mastro @ 2016-05-20 23:52 ` John Mastro 2016-05-21 20:48 ` Marcin Borkowski 0 siblings, 1 reply; 18+ messages in thread From: John Mastro @ 2016-05-20 23:52 UTC (permalink / raw) To: Help Gnu Emacs mailing list; +Cc: Oleh Krehel, Kaushal Modi John Mastro <john.b.mastro@gmail.com> wrote: > I played around with a few cosmetic changes to your function and ended > up with this: I realized that, for my use case, it makes more sense to let the caller specify the characters rather than automatically using the digits 1-9. So I ended up with this instead, which is also a bit shorter and simpler. (defun read-choice (prompt choices) (let ((cursor-in-echo-area t) (prompt (if (get-text-property 0 'face prompt) prompt (propertize prompt 'face 'minibuffer-prompt)))) (save-window-excursion (pop-to-buffer " *Read choice*" t t) (setq-local cursor-type nil) (erase-buffer) (pcase-dolist (`(,char ,description) choices) (insert (propertize (string char) 'face 'font-lock-variable-name-face) (format " %s\n" description))) (goto-char (point-min)) (fit-window-to-buffer) (or (assoc (read-key prompt) choices) (user-error "Invalid selection"))))) In Emacs's master branch (but not the emacs-25 release branch) there's a new function `read-multiple-choice' that's similar in purpose and worth a look. John ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Any infrastructure to select one of a few options in Emacs core? 2016-05-20 23:52 ` John Mastro @ 2016-05-21 20:48 ` Marcin Borkowski 0 siblings, 0 replies; 18+ messages in thread From: Marcin Borkowski @ 2016-05-21 20:48 UTC (permalink / raw) To: John Mastro; +Cc: Help Gnu Emacs mailing list, Oleh Krehel, Kaushal Modi On 2016-05-21, at 01:52, John Mastro <john.b.mastro@gmail.com> wrote: > John Mastro <john.b.mastro@gmail.com> wrote: > >> I played around with a few cosmetic changes to your function and ended >> up with this: > > I realized that, for my use case, it makes more sense to let the caller > specify the characters rather than automatically using the digits 1-9. > So I ended up with this instead, which is also a bit shorter and > simpler. > > (defun read-choice (prompt choices) > (let ((cursor-in-echo-area t) > (prompt (if (get-text-property 0 'face prompt) > prompt > (propertize prompt > 'face > 'minibuffer-prompt)))) > (save-window-excursion > (pop-to-buffer " *Read choice*" t t) > (setq-local cursor-type nil) > (erase-buffer) > (pcase-dolist (`(,char ,description) choices) > (insert (propertize (string char) > 'face > 'font-lock-variable-name-face) > (format " %s\n" description))) > (goto-char (point-min)) > (fit-window-to-buffer) > (or (assoc (read-key prompt) choices) > (user-error "Invalid selection"))))) Nice, thanks! I didn't know about several things you used here - every day is an opportunity to learn! (I'll finally have to read about pcase, too.) I like especially the `fit-window-to-buffer' function - it seems it's exactly what I needed, much better than my `delete-other-windows'! Also, it seems you don't need `setq-local' here, since `cursor-type' is automatically buffer-local anyway. > In Emacs's master branch (but not the emacs-25 release branch) there's a > new function `read-multiple-choice' that's similar in purpose and worth > a look. Yes, I've seen that. Not useful for me, though -- in my use case the descriptions of the choices are too long (maybe even several lines!). > John Best, -- Marcin Borkowski http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski Faculty of Mathematics and Computer Science Adam Mickiewicz University ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Any infrastructure to select one of a few options in Emacs core? 2016-05-09 18:08 ` Marcin Borkowski 2016-05-09 18:16 ` Drew Adams @ 2016-05-09 18:36 ` Pascal J. Bourguignon 2016-05-14 4:20 ` Emanuel Berg 2016-05-21 20:49 ` Marcin Borkowski 1 sibling, 2 replies; 18+ messages in thread From: Pascal J. Bourguignon @ 2016-05-09 18:36 UTC (permalink / raw) To: help-gnu-emacs Marcin Borkowski <mbork@mbork.pl> writes: > On 2016-05-09, at 19:27, Drew Adams <drew.adams@oracle.com> wrote: > >>> > completing-read >>> >>> Yes and no. I thought about it, and rejected the idea: I want all the >>> options to be visible without pressing TAB. Also, each option might >>> need more than one line (and the number of lines may vary between >>> options), so I don't like the idea of using minibuffer at all. >> >> It's still not clear from your description what you mean by "select" >> one of the options. > > OK, so let us assume that I want the user to select one of the three > strings: "spam", "eggs" and "emacs". (Note: in my use case they would > not be string literals.) Then, I'd like to be able to say, e.g., > something like this: > > (ask-user-for-option "What would you like to eat?" '("spam" "ham" "eggs")) > > and have something like > > Wat would you like to eat? > > 1. spam > > 2. ham > > 3. eggs > > displayed (perhaps in a *temp* buffer or so), and wait for the user to > press 1, 2 or 3. Then, the above form returns the selected string. > > It would probably be also useful to be able to give it e.g. cons cells > with the car being the string and the cdr the value returned in case of > selecting this particular string. Also, it should be customizable: one > user might like digit keys, another one letters, for instance. Also, > the choices should be clickable for those poor souls addicted to > rodents. > > In a more advanced scenario, the menu might be "non-modal", i.e. do not > use `read-key' or something like that, but a dynamically crafted mode > (probably descendant of special-mode), in which various keys/clicks would > launch a callback function given to the hypothetical > `ask-user-for-option' with the selected choice as a parameter. You can use a popup menu for that. (let ((options '("spam" "ham" "eggs"))) (x-popup-menu (let ((mp (mouse-position))) (list (list (cadr mp) (cddr mp)) (selected-window))) (list "menu" (cons "What would yuo like to eat?" (mapcar (lambda (option) (cons option option)) options))))) -- __Pascal Bourguignon__ http://www.informatimago.com/ “The factory of the future will have only two employees, a man and a dog. The man will be there to feed the dog. The dog will be there to keep the man from touching the equipment.” -- Carl Bass CEO Autodesk ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Any infrastructure to select one of a few options in Emacs core? 2016-05-09 18:36 ` Pascal J. Bourguignon @ 2016-05-14 4:20 ` Emanuel Berg 2016-05-21 20:49 ` Marcin Borkowski 1 sibling, 0 replies; 18+ messages in thread From: Emanuel Berg @ 2016-05-14 4:20 UTC (permalink / raw) To: help-gnu-emacs "Pascal J. Bourguignon" <pjb@informatimago.com> writes: > (let ((options '("spam" "ham" "eggs"))) > (x-popup-menu (let ((mp (mouse-position))) (list > (list (cadr mp) (cddr mp)) (selected-window))) > (list "menu" (cons "What would yuo like to eat?" > (mapcar (lambda (option) (cons option option)) > options))))) Cute, but is there any reason not to use the ordinary minibuffer/echo area area for this as for everything else? The whole thing with Emacs, or at least part of the whole thing, is to have a uniform interface. -- underground experts united .... http://user.it.uu.se/~embe8573 Emacs Gnus Blogomatic ......... http://user.it.uu.se/~embe8573/blogomatic - so far: 29 Blogomatic articles - ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Any infrastructure to select one of a few options in Emacs core? 2016-05-09 18:36 ` Pascal J. Bourguignon 2016-05-14 4:20 ` Emanuel Berg @ 2016-05-21 20:49 ` Marcin Borkowski 1 sibling, 0 replies; 18+ messages in thread From: Marcin Borkowski @ 2016-05-21 20:49 UTC (permalink / raw) To: Pascal J. Bourguignon; +Cc: help-gnu-emacs On 2016-05-09, at 20:36, Pascal J. Bourguignon <pjb@informatimago.com> wrote: > You can use a popup menu for that. > > (let ((options '("spam" "ham" "eggs"))) > (x-popup-menu (let ((mp (mouse-position))) > (list (list (cadr mp) > (cddr mp)) > (selected-window))) > (list "menu" > (cons "What would yuo like to eat?" > (mapcar (lambda (option) (cons option option)) > options))))) Thanks a lot, I'll remember about `x-popup-menu', it might be useful one day. It's not what I like, though; I prefer to have everything (including menus) in buffers. (Well, almost everything.) Best, -- Marcin Borkowski http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski Faculty of Mathematics and Computer Science Adam Mickiewicz University ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Any infrastructure to select one of a few options in Emacs core? 2016-05-09 10:09 Any infrastructure to select one of a few options in Emacs core? Marcin Borkowski 2016-05-09 14:13 ` Drew Adams @ 2016-05-14 4:18 ` Emanuel Berg 2016-05-21 20:52 ` Marcin Borkowski [not found] ` <mailman.43.1463863961.1216.help-gnu-emacs@gnu.org> 1 sibling, 2 replies; 18+ messages in thread From: Emanuel Berg @ 2016-05-14 4:18 UTC (permalink / raw) To: help-gnu-emacs Marcin Borkowski <mbork@mbork.pl> writes: > ... Check out my 'buc' module! (I don't remember why I called it that.) It is actually brilliant. You have a bunch of options: A, B, ... N. Then you have keys on your keyboard: RET, SPC, TAB, DEL, that are close and fast and singular. So there is an association between the options, and the keys! But the genius of it is, if you don't care for any of the options displayed and shortcutted, just type! Any other char will take away the whole "buc prompt" and instead appear as the first char in the input string, i.e., an arbitrary string is still inputable! Also, I added a function so that it works like a cache, with the most recently selected option always being the leftmost (RET), and then sorted rightways... It is an open question if this really is beneficial - it can be frustrating as well, if the keys keep moving around! It should at least be disableable. A screenshot: http://user.it.uu.se/~embe8573/dumps/buc.png The source: http://user.it.uu.se/~embe8573/conf/emacs-init/buc.el -- underground experts united .... http://user.it.uu.se/~embe8573 Emacs Gnus Blogomatic ......... http://user.it.uu.se/~embe8573/blogomatic - so far: 29 Blogomatic articles - ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Any infrastructure to select one of a few options in Emacs core? 2016-05-14 4:18 ` Emanuel Berg @ 2016-05-21 20:52 ` Marcin Borkowski [not found] ` <mailman.43.1463863961.1216.help-gnu-emacs@gnu.org> 1 sibling, 0 replies; 18+ messages in thread From: Marcin Borkowski @ 2016-05-21 20:52 UTC (permalink / raw) To: Emanuel Berg; +Cc: help-gnu-emacs On 2016-05-14, at 06:18, Emanuel Berg <embe8573@student.uu.se> wrote: > Marcin Borkowski <mbork@mbork.pl> writes: > >> ... > > Check out my 'buc' module! (I don't remember why > I called it that.) > > It is actually brilliant. You have a bunch of > options: A, B, ... N. > > Then you have keys on your keyboard: RET, SPC, TAB, > DEL, that are close and fast and singular. > > So there is an association between the options, and > the keys! > > But the genius of it is, if you don't care for any > of the options displayed and shortcutted, just type! > Any other char will take away the whole "buc prompt" > and instead appear as the first char in the input > string, i.e., an arbitrary string is still inputable! > > Also, I added a function so that it works like > a cache, with the most recently selected option > always being the leftmost (RET), and then sorted > rightways... It is an open question if this really is > beneficial - it can be frustrating as well, if the > keys keep moving around! It should at least > be disableable. Do I get it correctly that you have reinvented hydra? (Or the other way round;-).) Though the idea of sorting by recent-ness is nice. Thanks! -- Marcin Borkowski http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski Faculty of Mathematics and Computer Science Adam Mickiewicz University ^ permalink raw reply [flat|nested] 18+ messages in thread
[parent not found: <mailman.43.1463863961.1216.help-gnu-emacs@gnu.org>]
* Re: Any infrastructure to select one of a few options in Emacs core? [not found] ` <mailman.43.1463863961.1216.help-gnu-emacs@gnu.org> @ 2016-05-22 6:32 ` Emanuel Berg 0 siblings, 0 replies; 18+ messages in thread From: Emanuel Berg @ 2016-05-22 6:32 UTC (permalink / raw) To: help-gnu-emacs Marcin Borkowski <mbork@mbork.pl> writes: >> Check out my 'buc' module! (I don't remember >> why I called it that.) It is actually >> brilliant. You have a bunch of options: A, >> B, ... N. Then you have keys on your >> keyboard: RET, SPC, TAB, DEL, that are close >> and fast and singular. So there is an >> association between the options, and the >> keys! But the genius of it is, if you don't >> care for any of the options displayed and >> shortcutted, just type! Any other char will >> take away the whole "buc prompt" and instead >> appear as the first char in the input >> string, i.e., an arbitrary string is still >> inputable! Also, I added a function so that >> it works like a cache, with the most >> recently selected option always being the >> leftmost (RET), and then sorted rightways... >> It is an open question if this really is >> beneficial - it can be frustrating as well, >> if the keys keep moving around! It should at >> least be disableable. > > Do I get it correctly that you have > reinvented hydra? (Or the other way > round;-).) If it does the same thing, perhaps I should rebrand mine "Chimera and the Gorgons"? -- underground experts united .... http://user.it.uu.se/~embe8573 Emacs Gnus Blogomatic ......... http://user.it.uu.se/~embe8573/blogomatic - so far: 39 Blogomatic articles - ^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2016-05-22 6:32 UTC | newest] Thread overview: 18+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-05-09 10:09 Any infrastructure to select one of a few options in Emacs core? Marcin Borkowski 2016-05-09 14:13 ` Drew Adams 2016-05-09 15:40 ` Marcin Borkowski 2016-05-09 16:37 ` Kaushal Modi 2016-05-09 17:10 ` Marcin Borkowski 2016-05-09 17:27 ` Drew Adams 2016-05-09 18:08 ` Marcin Borkowski 2016-05-09 18:16 ` Drew Adams 2016-05-19 20:06 ` Marcin Borkowski 2016-05-20 1:16 ` John Mastro 2016-05-20 23:52 ` John Mastro 2016-05-21 20:48 ` Marcin Borkowski 2016-05-09 18:36 ` Pascal J. Bourguignon 2016-05-14 4:20 ` Emanuel Berg 2016-05-21 20:49 ` Marcin Borkowski 2016-05-14 4:18 ` Emanuel Berg 2016-05-21 20:52 ` Marcin Borkowski [not found] ` <mailman.43.1463863961.1216.help-gnu-emacs@gnu.org> 2016-05-22 6:32 ` Emanuel Berg
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).