diff options
-rw-r--r-- | .emacs.d/init.el | 21 | ||||
-rw-r--r-- | .emacs.d/init.org | 62 |
2 files changed, 61 insertions, 22 deletions
diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 93bc348..380e99b 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -35,10 +35,6 @@ (defvar sql-product) (defvar sql-prompt-regexp) -(defvar init-stumpish-program - (expand-file-name - "~/.local/share/quicklisp/local-projects/stumpwm/contrib/stumpish")) - (defadvice org-agenda-redo (after ext:org-agenda-redo-add-appts) "Pressing `r' on the agenda will also add appointments." (progn @@ -49,27 +45,10 @@ "Kill the term buffer if the process finished." (kill-buffer (current-buffer))) -(defadvice windmove-do-window-select - (around init-windmove-stumpwm activate) - "If no window can be moved to, move stumpwm." - (condition-case err - ad-do-it - (error (stumpwm-command (format "move-focus %s" (ad-get-arg 0)))))) - (defmacro addf (place value) "Prepend to PLACE VALUE." `(setf ,place (cons ,value ,place))) -(defmacro stumpwm (&rest body) - "Execute BODY in stumpwm." - (declare (indent 0)) - `(call-process init-stumpish-program nil nil nil - ,(format "eval '%S'" `(progn ,@body)))) - -(defun stumpwm-command (cmd) - "Execute CMD in stumpwm." - (call-process init-stumpish-program nil nil nil cmd)) - (defun init-augment-sql-prompt () "Add the MariaDB prompt to the `sql-pomrpt-regexp'." (if (eq sql-product 'mysql) diff --git a/.emacs.d/init.org b/.emacs.d/init.org index c921e9d..e471651 100644 --- a/.emacs.d/init.org +++ b/.emacs.d/init.org @@ -20,7 +20,7 @@ certain package has been loaded. So in order to keep start-up as fast as possible, while still taking advantage of byte-compiling everything, I wrap most settings in the following macro, which is - explained [[http://lunaryorn.com/blog/2013/05/31_byte-compiling-eval-after-load.html][here]]. + explained [[http://lunaryorn.com/2013/05/31/byte-compiling-eval-after-load/][here]]. #+BEGIN_SRC emacs-lisp (defmacro stante-after (feature &rest forms) @@ -323,3 +323,63 @@ (stante-after simple (define-key special-mode-map "z" #'kill-this-buffer)) #+END_SRC + +* Falling back to WM to switch windows + + Emacs and any window manager have a difference op opinion on what + windows are. It doesn't have to matter, Emacs can manage its windows + and stumpwm can do the rest. When moving around with ~windmove~ and it + finds that there's no way to move in that direction, let stumpwm do + it. + + First we have to know where the stumpish program is. SLIME could + also be used, but calling stumpish might be easier for now. + + #+BEGIN_SRC emacs-lisp + (defvar init-stumpish-program + (expand-file-name + "~/.local/share/quicklisp/local-projects/stumpwm/contrib/stumpish") + "The location of the stumpish executable.") + #+END_SRC + + Now that we know that, we should have an easy way to send stuff to + it. + + #+BEGIN_SRC emacs-lisp + (defun stumpwm-command (cmd) + "Execute CMD in stumpwm." + (call-process init-stumpish-program nil nil nil cmd)) + #+END_SRC + + And then we can advise =windmove-do-window-select=, so that when it + finds there are no more windows to move to, it asks stumpwm to move + in the same direction. + + #+BEGIN_SRC emacs-lisp + (defadvice windmove-do-window-select + (around init-windmove-stumpwm activate) + "If no window can be moved to, move stumpwm." + (condition-case err + ad-do-it + (error (stumpwm-command (format "move-focus %s" (ad-get-arg 0)))))) + #+END_SRC + + Now, whenever I try to move out of my Emacs windows, it just moves + to the next X11 window, whatever it might be. My stumpwm config has + a matching command that checks to see if the current window is + Emacs, and if so sends the ~S-<direction>~ key to Emacs, which in turn + calls stumpwm when it can't (getting a little crazy here). + + I also wrote a simplistic macro to execute some stumpwm lisp in + Emacs. + + #+BEGIN_SRC emacs-lisp + (defmacro stumpwm (&rest body) + "Execute BODY in stumpwm." + (declare (indent 0)) + `(call-process init-stumpish-program nil nil nil + ,(format "eval '%S'" `(progn ,@body)))) + #+END_SRC + + Which is pretty much the same as my =elisp= macro in my stumpwm + config. |