emacs windmove and focus

Russell Carden <rlc2-OhmvVRJSr/[email protected]>
Newsgroups gmane.comp.window-managers.ratpoison.devel
Message-ID <[email protected]>
Hello,

I have been using ratpoison for a little over a year.  Over the summer I 
discovered emacs windmove package.  I finally got around to making 
emacs's windmove to work with my keybindings for ratpoison's focus 
commands.  I had to modify the windmove-do-window-select function in 
windmove.el.  It would be nice if windmove's response to hitting the 
edge of the frame could be determined by a user defined function.

Anyway, for my fix, windmove wrapping has to be disabled.  If 
windmove-{dir}  would result in an error due to there not being a window 
in the direction dir,  then a call is made to ratpoison's focus{dir} 
command.  I setup keyboard shorcuts for ratpoison's focus{dir} that call 
windmove-{dir} if the current frame is emacs and otherwise call focus{dir}.

I modified the following function in windmove.el

#+begin_src emacs-lisp
   ;; Selects the window that's hopefully at the location returned by
   ;; `windmove-other-window-loc', or screams if there's no window there.
   (defun windmove-do-window-select (dir &optional arg window)
     "Move to the window at direction DIR.
   DIR, ARG, and WINDOW are handled as by `windmove-other-window-loc'.
   If no window is at direction DIR, an error is signaled."
     (let ((other-window (windmove-find-other-window dir arg window)))
       (cond ((null other-window)
;Added code
              (call-process-shell-command (concat "ratpoison -c " 
(combine-and-quote-strings (list (concat "focus" (format "%s" dir)))) 
"&") nil 0 )
              (message "focus%s" dir)
;End added code
              (error "No window %s from selected window" dir))
             ((and (window-minibuffer-p other-window)
                   (not (minibuffer-window-active-p other-window)))
              (error "Minibuffer is inactive"))
             (t
              (select-window other-window)))))

Modifications to ratpoisonrc.
        - definekey top s-h     exec result=`ratpoison -c "info %a"` ;if 
[ "$result" == "emacs" ]; then   emacsclient -e "(windmove-left)" ; else 
ratpoison -c "focusleft";fi; exit 0
        - definekey top s-j     exec result=`ratpoison -c "info %a"` ;if 
[ "$result" == "emacs" ]; then   emacsclient -e "(windmove-down)" ; else 
ratpoison -c "focusdown";fi; exit 0
        - definekey top s-k     exec result=`ratpoison -c "info %a"` ;if 
[ "$result" == "emacs" ]; then   emacsclient -e "(windmove-up)" ; else 
ratpoison -c "focusup";fi; exit 0
        - definekey top s-l     exec result=`ratpoison -c "info %a"` ;if 
[ "$result" == "emacs" ]; then   emacsclient -e "(windmove-right)" ; 
else ratpoison -c "focusright";fi; exit 0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.