[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Jump to autoconf macro documentation
From: |
Andrea Crotti |
Subject: |
Re: Jump to autoconf macro documentation |
Date: |
Mon, 31 Jan 2011 11:18:01 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.2 (darwin) |
Le Wang <l26wang@gmail.com> writes:
> You haven't said why it doesn't work. Maybe you need to look into error
> handling?
> http://www.gnu.org/software/emacs/elisp/html_node/Handling-Errors.html
> In the future, please try harder to use the built-in help system *and*
> Google first before posting to this list. This list should not be your
> first line of defense when you come across an issue.
> Also when you post your issue, describe it in detail; and demonstrate that
> you've tried the obvious avenues to resolve it yourself, i.e. describe
> your attempts at solving the problem, and why you are stuck
> "I thought the issue might be xxx, so I tried A, B and C. But now I'm
> stuck."
> Giving more details will help others in the future who Google similar
> issues, It also shows people that you are sincere and willing to invest
> your own time before bothering others.
> People who persistently spray terse "stream of thought" style questions
> into mailing lists get filtered out. I like it when people show respect
> for others' time.
> Please understand that I'm not trying to offend you, just trying to help
> you get more answers to your questions in the future.
Yes sorry you're right, I was half sleeping and I just wanted to write
something but it wasn't complete.
Anyway I think I added some nice features:
--8<---------------cut here---------------start------------->8---
(setq autoconf-macro-syntax-table (make-syntax-table))
(modify-syntax-entry ?_ "w" autoconf-macro-syntax-table)
(defun get-autoconf-macro-definition ()
"jump to the definition of a macro"
(interactive)
(let
((macro (with-syntax-table autoconf-macro-syntax-table (thing-at-point
'word))))
(or
(get-autoconf-macro-local macro)
(lookup-in-info "autoconf" macro)
(lookup-in-info "automake" macro)
(google-it macro))))
(defun lookup-in-info (section string)
"lookup string in the given section"
(info section (format "*%s*<%s>" section string))
(condition-case nil
(Info-index string)
(error nil)))
(defun get-autoconf-macro-local (macro)
"Look for the definition of the macro in aclocal.m4 before"
(let
((local-macro-file "aclocal.m4"))
(if (file-exists-p local-macro-file)
(save-excursion
(find-file local-macro-file)
(condition-case nil
(search-forward (format "AC_DEFUN([%s])" macro))
(error nil))
nil))))
(add-hook 'autoconf-mode-hook
(lambda ()
(local-set-key "\C-j" 'get-autoconf-macro-definition)))
--8<---------------cut here---------------end--------------->8---
So it tries before in aclocal.m4, then autoconf macros, then automake
macros and then looking up with google.
Not sure that using or is the best thing but it works fine in this
case...
But why in the "condition-case" I need to do "(error nil)" instead of
just "nil" when I return false?