Hi Scott, Thanks for the informative reply! It would be great if we could put this on the wiki somewhere for the benefit of all. I agree with Stefan's criticisms of how the window list is managed, but as Scott points out, it may be hard to implement the fixes.
Cheers, Dave Scott Jaderholm <jaderh...@gmail.com> writes: > On Wed, Jun 03 2015,Stefan Huchler wrote: > >> I use the windowlist function to switch between windows in stumpwm. >> >> But it is just not on par with even the normal buffer switch-to-buffer >> function/command in emacs, so I hope there is a way to make it better. > > In case no one implements your feature requests in StumpWM proper, I'll > give you some ideas of how you could implement them in your own RC file. > >> 1. when I use switch-to-buffer in emacs automaticly the last buffer is >> selected so with C-x b (default bindings) and <RET> I can fast switch >> between 2 buffers, would love to have that in stumpwm. > > StumpWM doesn't, afaik, keep track of the previously selected window (it > does keep track of the previously selected frame), on a global or > per-group basis (windowlist is per group). You could add a function to > focus-window-hook that saves the previous window somewhere, but it would > have to keep track of it on a per group basis since windowlist would > need to know the previous window of the current group. > > You could then redefine windowlist or select-window-from-menu to use > the previous window you stored instead of the current window. > > I've included a globally-previous command below that that I use to > toggle between two windows. > >> 2. emacs switch-to-buffer hides buffers that does not match the >> letters given in, makes seeing when you can type enter much easier. > > I don't think that StumpWM's menu can do that. You can use dmenu to do > that though, and I provide code to use dmenu from StumpWM below. > >> 3. emacs s-t-b resorts the buffers to what matches best your search >> string > > switch-to-buffer doesn't do that. flx or helm will do that, maybe > icomplete does that. Ido does not resort, unless flx-ido is loaded. > >> 4. I dont get why stumpwm opens buffers(in stump windows) in the >> position it was opened even it was not visible, makes more sense to >> open that "buffer" over the "buffer" I just have focused. > > There is a command pull-window-select that behaves like that. > >> 5. bonus points for a fuzzy (smex) search that is more powerful then a >> normal search to select a window with the name 'A - trash@#$@#$ - B' >> with A B search string when 'A - ' and ' - B' alone is not unique. > > It's ido doing the fuzzy search, not smex itself, afaik. > > The code below will allow you to use dmenu for menus in StumpWM instead > of the built-in menu UI. Note I don't use it, so I can't really support > it. There is a bug with it, but I forget what it is :) > > If you use dmenu2, then you can enable fuzzy matching, but IIRC it > doesn't work when case insensitive option is set. You can also use > "space separated token" matching, so "A B" would match "A - trash@#$@#$ > - B". You can enable vertical mode and non-matching lines will be > removed as you type. > > (defun select-from-menu (screen table &optional prompt > (initial-selection 0)) > "Prompt the user to select from a menu using dmenu on SCREEN. TABLE > can be a list of values or an alist. If it's an alist, the CAR of each > element is displayed in the menu. What is displayed as menu items must > be strings. Returns the selected element in TABLE or nil if aborted." > > (let* ((menu-options (mapcar #'menu-element-name table)) > ;; FIXME can't handle two items with same string representation > (cmd (format nil "echo \"~{~A\\n~}\" | dmenu" menu-options)) > (selection-string (string-trim '(#\Newline) > (run-shell-command cmd t))) > (selection (find selection-string menu-options > :test (lambda (selection-string item) > (string-equal selection-string > (format nil "~A" item)))))) > (if (listp (car table)) > (assoc selection table) > selection))) > > ;; And the globally-previous code > > (defvar *globally-previous* '()) > (defvar *globally-current* '()) > > (defun remember-focus-window-hook (new old) > (setf *globally-previous* *globally-current*) > (setf *globally-current* new)) > > (add-hook *focus-window-hook* 'remember-focus-window-hook) > > (defcommand globally-previous () () > "Switch to the previous window (possibly from another group) that had focus" > (let* > ((window *globally-previous*) > (group (window-group window)) > (frame (window-frame window))) > (when (not (= 0 (window-state window))) > (gselect group) > (focus-frame group frame) > (focus-window window)))) > > Scott > > _______________________________________________ > Stumpwm-devel mailing list > Stumpwm-devel@nongnu.org > https://lists.nongnu.org/mailman/listinfo/stumpwm-devel _______________________________________________ Stumpwm-devel mailing list Stumpwm-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/stumpwm-devel