Mark Triggs mark@dishevelled.net writes:
d95-bli@nada.kth.se (Björn Lindberg) writes:
I would much prefer if the behaviour was closer to the one for C-c C-d C-d, where the description pops up in another window, and an effort is made upon exit to restore the windows to what they were before.
I've had the following fragment in my ~/.emacs for a while with no obvious side-effects or respiratory trouble:
(defadvice common-lisp-hyperspec (around hyperspec-lookup-w3m () activate) (let* ((window-configuration (current-window-configuration)) (browse-url-browser-function `(lambda (url new-window) (w3m-browse-url url nil) (let ((hs-map (copy-keymap w3m-mode-map))) (define-key hs-map (kbd "q") (lambda () (interactive) (kill-buffer nil) (set-window-configuration ,window-configuration))) (use-local-map hs-map))))) ad-do-it))
Of course, your mileage may vary :o)
I modified the above into
(defadvice common-lisp-hyperspec (around hyperspec-lookup-w3m () activate) (let* ((window-configuration (current-window-configuration)) (browse-url-browser-function `(lambda (url new-window) (w3m-browse-url url nil) (let ((hs-map (copy-keymap w3m-mode-map))) (define-key hs-map (kbd "q") (lambda () (interactive) (kill-buffer nil) (set-window-configuration ,window-configuration))) (use-local-map hs-map))))) (when (one-window-p) ; <== Inserted code here (split-window)) ; <== (other-window 1) ; <== ad-do-it))
And now it works like this: If there is only one window, split into two, and pop up the hyperspec in the newly created one. Otherwise if there is more than one window, pop up the hyperspec in the other window.
It sort of works the way I had in mind, so I'm going to try it for a while, although now I'm thinking that I'd like to have it check for other frames too, and if present open the hyperspec in another frame instead. I suspect the "right" behaviour for these things depend a lot on how you use Emacs, ie how many frames and windows you use, and wether you use the same emacs session for both Slime as well as other activities.
Again, thanks all for the help.
Björn