Here’s my fix:
;; Global 'last focussed window'
(setf *global-earlier-focussed-window* 'nil)
(setf *global-prev-focussed-window* 'nil)
(setf *global-cur-focussed-window* 'nil)
(defun panrecord-of-last-focussed-window (currwin lastwin)
"Record last visited windows and their group."
(unless (or (search "*EQUAKE*[" (window-name currwin))
(equal (cons (current-window) (current-group)) *global-cur-focussed-window*))
(when (find-window-globally
(car *global-prev-focussed-window*) (screen-groups (current-screen)))
(setf *global-earlier-focussed-window* *global-prev-focussed-window*))
(when (find-window-globally
(car *global-cur-focussed-window*) (screen-groups (current-screen)))
(setf *global-prev-focussed-window* *global-cur-focussed-window*))
(setf *global-cur-focussed-window* (cons currwin (current-group)))))
(defun find-window-globally (window group-list)
"Check for presence of window in all groups."
(if (equal (car group-list) 'nil)
'nil
(if (member window (group-windows (car group-list)))
window
(find-window-globally window (cdr group-list)))))
(defcommand switch-to-last-focussed-window () ()
"Switch to last focussed window, irrespective of which group it is in and
what group we're currently in."
(let ((switch-to-win
(or
(find-window-globally
(car *global-prev-focussed-window*) (screen-groups (current-screen)))
(find-window-globally
(car *global-earlier-focussed-window*) (screen-groups (current-screen))))))
(if switch-to-win
(progn
(switch-to-group (cdr *global-prev-focussed-window*))
(focus-window (car *global-prev-focussed-window*) t))
(message "No window to switch to."))))
(stumpwm:add-hook stumpwm:*focus-window-hook* 'panrecord-of-last-focussed-window)
(define-key *root-map* (kbd "s-f") "switch-to-last-focussed-window")
The unless
statement in panrecord-of-last-focussed-window
prevents
my drop-down terminal Equake “window” from “counting” for history
tracking purposes.
switch-to-last-focussed-window
essentially just switches to the last
focussed window, after making sure it still exists. (If not, the
window which was focussed before that one, or else don’t switch and
display message to user.)
(define-key *root-map* (kbd "s-f") "switch-to-last-focussed-window")
means that I can double tap s-f
to switch to the last focussed window, no matter which group it
belongs to.
I continue to really enjoy the power that StumpWM’s Common Lisp underpinnings provides the user!
]]>However, John Mercouris has been developing Next Browser (originally styled nEXT Browser), a browser with a Common Lisp front-end, allowing for customisability and extensibility along Conkeror/Emacs lines:
The back-ends are – if I understand correctly – planned to be Blink for the QT port and WebkitGTK+ for the GTK port, with the Mac port of Webkit for the Mac version. But the front-end, the user-facing side, is Common Lisp.
John is currently running an Indiegogo campaign to properly port it to Linux and other non-Mac Unix variants (it apparently runs well already on the Mac, John’s main platform it seems [there’s no accounting for taste ;) ]). The raised money would be used in part to pay a professional C/C++ developer for their time.
Ambrevar is currently working on packaging Next Browser for Guix, which is exciting and promises to add to the amount of Lisp front-end software we’ll be able to use. Currently I’m running Emacs (elisp) for the majority of my non-browser productivity (writing papers & creating class slides using AUCTeX; reading composing email with mu4e; note-taking and scheduling with Org mode; &c. &c.) and, at least on one machine, StumpWM (Common Lisp window manager) for my ‘desktop environment’; and GNU GuixSD with a Guile-based package manager, Guile-based cron (mcron), and Guile-based init/daemon-manager (Shepherd). A functional, configurable, Lisp-based browser would be a most welcome addition. As excellent as Firefox is, especially its backend, I do really miss the halcyon days of Conkeror, and Next Browser could represent a return to those heady days of configurable browsing Emacs-style.
So, if this sort of thing appeals to you (i.e. if you like Lisp, Emacs, and/or highly-extendable browsers), you might want to support the Linux/Unix-port of Next Browser: https://www.indiegogo.com/projects/next-browser-nix-support
There’s only about a week left in the campaign.
]]>