[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[SOLUTION] Open Hypspec with w3m
From: |
Jason Earl |
Subject: |
[SOLUTION] Open Hypspec with w3m |
Date: |
Fri, 28 Jan 2011 16:58:33 -0700 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
On Fri, Jan 28 2011, Jason Earl wrote:
> On Fri, Jan 28 2011, Tim X wrote:
>
>> Jason Earl <jearl@notengoamigos.org> writes:
>>
>>> I have been spending a bit of my free time learning Common Lisp (and
>>> enjoying it). Part of learning Common Lisp is getting to know the
>>> HyperSpec. The fact that Emacs includes a function 'hyperspec-lookup
>>> that makes this a matter of a few keystrokes is very helpful. However,
>>> by default this opens up the page in Firefox, and I would pretty much
>>> always like to open the HyperSpec in w3m. I would change the default
>>> browse-url-browser-function, but I generally want to open URLs with
>>> Firefox.
>>>
>>> For Common Lisp buffers I make 'browse-url-browser-function a local
>>> variable and set it to 'w3m-browse-url.
>>>
>>> (add-hook 'lisp-mode-hook 'jadoea-lispstuff)
>>>
>>> ;; my python configuration
>>> (defun jadoea-lispstuff ()
>>> "Custom Lisp Configurator.
>>>
>>> Turn on flyspell-prog-mode. Clean up whitespace on save (leave
>>> tabs). Make browse-url-browser-function buffer-local and set it
>>> to browse-url-w3m."
>>> (flyspell-prog-mode)
>>> (add-hook 'before-save-hook
>>> (lambda ()
>>> (jadoea-clean-whitespace t nil)) nil t)
>>> (make-local-variable 'browse-url-browser-function)
>>> (setq browse-url-browser-function 'w3m-browse-url))
>>>
>>> This works great as long as I am in a Common Lisp buffer, but I find
>>> myself constant wanting to look up stuff from the HyperSpec while in a
>>> Slime REPL, or some other type of buffer.
>>>
>>> So is there a way to override 'hyperspec-lookup so that it always
>>> behaves as if browse-url-browser-function was 'w3m-browse-url?
>>>
>>> I build Emacs from source, and I maintain my own branch so that I
>>> can easily deploy Emacs on various machines. So I considered simply
>>> hacking common-lisp-hyperspec to do what I wanted. However, that
>>> hardly seems like the cleanest way to do this sort of thing.
>>>
>>> Any suggestions?
>>>
>>
>> You could try using defadvice and advise hyperspec-lookup. In the
>> advice, locally bind browse-url-browser-function to use w3m. I guess
>> you would need either 'before or 'around form of defadvice.
>
> That looks like what I need. Thank you very much. I will do a little
> bit of experimenting and post a solution.
It turns out the solution was much easier than I would have guessed. I
assumed that I would have to read the manual for a bit. However, this
bit of Elisp seems to have done the trick.
--8<---------------cut here---------------start------------->8---
(defadvice hyperspec-lookup (around hyperspec-lookup-around)
"I always want `hyperspec-lookup' to use 'w3m-browse-url."
(let ((browse-url-browser-function 'w3m-browse-url))
ad-do-it))
(ad-activate 'hyperspec-lookup)
--8<---------------cut here---------------end--------------->8---
Jason
Re: Open Hypspec with w3m, Stefan Monnier, 2011/01/28
- Re: Open Hypspec with w3m, Jason Earl, 2011/01/28
- Re: Open Hypspec with w3m, Stefan Monnier, 2011/01/28
- Re: Open Hypspec with w3m, Jason Earl, 2011/01/29
- Re: Open Hypspec with w3m, Tim X, 2011/01/29
- Re: Open Hypspec with w3m, rusi, 2011/01/29
- Re: Open Hypspec with w3m, Perry Smith, 2011/01/30
- Message not available
- Re: Open Hypspec with w3m, Krzysztof Bieniasz, 2011/01/30