Not directly related to Slime, but hopefully someone can help me still...
I get Hyperspec lookup inside of Slime, by setting browse-url-browser-function to w3m-browse-url. Now, when I do C-c C-d h I get Hyperspec lookup, and with C-c C-d C-d I get a description. My roblem is that the hyperspec lookup insists n popping up in the same window where I invoked it, which conveniently hides whatever I was working on. 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 suspect that writing my own browser function is the right way to do it, but I am not an elisp wizard, and am not clear on how to go about it. Any ideas?
(Sorry if this is too off-topic for the list.)
Björn
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)
Cheers,
Mark
"Mark" == Mark Triggs mark@dishevelled.net writes:
Mark> 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.
Mark> I've had the following fragment in my ~/.emacs for a while with Mark> no obvious side-effects or respiratory trouble:
[...]
Funny how many people have to solve same problems. Attached is my try at solving the same annoyance, except I tried to fix w3m for more than just hyperspec browsing.
YMMV, of course.
--J.
* Jan Rychter jan@rychter.com [2004-07-15T23:36-0700]:
"Mark" == Mark Triggs mark@dishevelled.net writes:
Mark> 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.
Mark> I've had the following fragment in my ~/.emacs for a while
Setting w3m-pop-up-frames to t works for me, though it does not have exactly the same effect Jan describes: it creates a new (and then reused) frame for w3m buffers, so emacs does not touch the window configuration of the frame which I program in. Placing the new frame conveniently is done by my window-manager.
Oh, ISTR that at first w3m-pop-up-frames did not seem to have any impact, "rebooting" emacs helped there. (GNU Emacs 21.3.50.1 here).
Cheers, M/
Michael Weber michaelw+slime@foldr.org writes:
- Jan Rychter jan@rychter.com [2004-07-15T23:36-0700]:
> "Mark" == Mark Triggs mark@dishevelled.net writes:
Mark> 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.
Mark> I've had the following fragment in my ~/.emacs for a while
Setting w3m-pop-up-frames to t works for me, though it does not have exactly the same effect Jan describes: it creates a new (and then reused) frame for w3m buffers, so emacs does not touch the window configuration of the frame which I program in. Placing the new frame conveniently is done by my window-manager.
Thanks for all who responded. Still, neither of the suggestions seem to do what I want. Michaels suggestion above does not work for me, since I do not want to devote a whole frame or window just for w3m. I tried both Marks and Jans suggestions briefly, and neither actually seemed that different from how w3m behaves originally on my system. Perhaps we are working in different ways.
The two key things for me are, first that I would like w3m to pop up in a window (or frame) /other/ than the one I am in when I am invoking the Hyperspec lookup, so that I can read the HS entry and still see what I was working on. Secondly, I would like the window configuration to be restored once I press "q" when in w3m. I have not noticed this to be too much of a problem so far in the regular case, but I imagine that a smarter initiating function would necessitate more work for this too. It seems that Marks and Jans solutions are mostly for dealing with this last issue.
At least I now got some elisp code specific to the problem to work with, and I'll see if I can work something out. In case I misunderstood any of the solutions I am hapy to be corrected.
Björn
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
In message hcs1xjcgdm9.fsf@faun.nada.kth.se, Björn Lindberg writes: [...snip...]
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.
I also have a solution I use. Mine opens the hyperspec in a new window if w3m has no buffers open, otherwise it uses the already existing w3m buffer and window. I explicitly turn pop-up-frames OFF. Combine that with the previous suggestions, and you should be closer to the "ideal". ---
(require 'w3m)
(defun w3m-browse-url-other-window (url &optional newwin) (interactive (browse-url-interactive-arg "w3m URL: ")) (let ((pop-up-frames nil)) (switch-to-buffer-other-window (w3m-get-buffer-create "*w3m*")) (w3m-browse-url url)))
;; The ftp stuff is irrelevant for this discussion. I left it in anyhow. (setq browse-url-browser-function (list (cons "^ftp:/.*" (lambda (url &optional nf) (call-interactively #'find-file-at-point url))) (cons "." #'w3m-browse-url-other-window)))