* Jump to autoconf macro documentation
@ 2011-01-30 10:47 Andrea Crotti
2011-01-30 15:09 ` Le Wang
2011-01-30 16:16 ` Kevin Rodgers
0 siblings, 2 replies; 14+ messages in thread
From: Andrea Crotti @ 2011-01-30 10:47 UTC (permalink / raw)
To: help-gnu-emacs
I would like to help myself to understand and write correct Configure.ac
files.
Now one idea would be to be able to jump from the macro to its
definition.
So I found that the definition of every macro is given in the autoconf
Info page, for example under with the string:
Macro: AC_ARG_ENABLE
so it would be easy to jump to.
Only one problem, how (thing-at-point 'word) doesn't work well with
AC_ARG_ENABLE for example, so or I redefine locally how a word should be
(if possible), or I have to do some other regexp trick to get it.
Another problem is that I don't get how to look for, if I have an Info
buffer already open it uses that position. So maybe it's better if I
create a new Info buffer and use it.
And also how do I jump to an info page from the TOC: RET is bound to
this:
(Info-follow-nearest-node &optional FORK)
But I think there is a smarter way than doing a search-regexp and then
use that function, right?
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Jump to autoconf macro documentation
2011-01-30 10:47 Jump to autoconf macro documentation Andrea Crotti
@ 2011-01-30 15:09 ` Le Wang
2011-01-30 16:03 ` Andrea Crotti
2011-01-30 16:09 ` Thien-Thi Nguyen
2011-01-30 16:16 ` Kevin Rodgers
1 sibling, 2 replies; 14+ messages in thread
From: Le Wang @ 2011-01-30 15:09 UTC (permalink / raw)
To: Andrea Crotti; +Cc: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 1505 bytes --]
You want to change the syntax table to rexognize ?_ as a word constituent.
see http://www.emacswiki.org/emacs/EmacsSyntaxTable
(defvar my-wacky-syntax-table
(modify-syntax-entry ?_ "w" (make-syntax-table)))
(defun get-word ()
(interactive)
(message "%s"
(with-syntax-table my-wacky-syntax-table
(thing-at-point 'word))))
I don't know much about info, but "g" is bound to `Info-goto-node'
On Sun, Jan 30, 2011 at 6:47 PM, Andrea Crotti <andrea.crotti.0@gmail.com>wrote:
>
> I would like to help myself to understand and write correct Configure.ac
> files.
>
> Now one idea would be to be able to jump from the macro to its
> definition.
>
> So I found that the definition of every macro is given in the autoconf
> Info page, for example under with the string:
>
> Macro: AC_ARG_ENABLE
>
> so it would be easy to jump to.
>
> Only one problem, how (thing-at-point 'word) doesn't work well with
>
> AC_ARG_ENABLE for example, so or I redefine locally how a word should be
> (if possible), or I have to do some other regexp trick to get it.
>
> Another problem is that I don't get how to look for, if I have an Info
> buffer already open it uses that position. So maybe it's better if I
> create a new Info buffer and use it.
>
> And also how do I jump to an info page from the TOC: RET is bound to
> this:
>
> (Info-follow-nearest-node &optional FORK)
>
> But I think there is a smarter way than doing a search-regexp and then
> use that function, right?
>
>
>
--
Le
[-- Attachment #2: Type: text/html, Size: 2436 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Jump to autoconf macro documentation
2011-01-30 15:09 ` Le Wang
@ 2011-01-30 16:03 ` Andrea Crotti
2011-01-30 16:09 ` Thien-Thi Nguyen
1 sibling, 0 replies; 14+ messages in thread
From: Andrea Crotti @ 2011-01-30 16:03 UTC (permalink / raw)
To: help-gnu-emacs
Le Wang <l26wang@gmail.com> writes:
> You want to change the syntax table to rexognize ?_ as a word constituent.
> see http://www.emacswiki.org/emacs/EmacsSyntaxTable
> (defvar my-wacky-syntax-table
> (modify-syntax-entry ?_ "w" (make-syntax-table)))
> (defun get-word ()
> (interactive)
> (message "%s"
> (with-syntax-table my-wacky-syntax-table
> (thing-at-point 'word))))
> I don't know much about info, but "g" is bound to `Info-goto-node'
Ah thanks a lot!
I changed to this because my-wacky-syntax-table was nil
(setq my-wacky-syntax-table (make-syntax-table))
(modify-syntax-entry ?_ "w" my-wacky-syntax-table)
(defun get-autoconf-word ()
(interactive)
(message "%s"
(with-syntax-table my-wacky-syntax-table
(thing-at-point 'word))))
But it works :)
About Info I also thought about "g", but what "g" does is just jump in
the right section, if I do
M-: RET (Info-goto-node "Autoconf")
from a info buffer where I see the entry "Autoconf"
I get:
byte-code: No such node or anchor: Autoconf
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Jump to autoconf macro documentation
2011-01-30 15:09 ` Le Wang
2011-01-30 16:03 ` Andrea Crotti
@ 2011-01-30 16:09 ` Thien-Thi Nguyen
1 sibling, 0 replies; 14+ messages in thread
From: Thien-Thi Nguyen @ 2011-01-30 16:09 UTC (permalink / raw)
To: help-gnu-emacs
() Le Wang <l26wang@gmail.com>
() Sun, 30 Jan 2011 23:09:29 +0800
change the syntax table to rexognize ?_ as a word constituent
See also:
(thing-at-point 'symbol)
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Jump to autoconf macro documentation
2011-01-30 10:47 Jump to autoconf macro documentation Andrea Crotti
2011-01-30 15:09 ` Le Wang
@ 2011-01-30 16:16 ` Kevin Rodgers
2011-01-30 17:31 ` Andrea Crotti
1 sibling, 1 reply; 14+ messages in thread
From: Kevin Rodgers @ 2011-01-30 16:16 UTC (permalink / raw)
To: help-gnu-emacs
On 1/30/11 3:47 AM, Andrea Crotti wrote:
>
> I would like to help myself to understand and write correct Configure.ac
> files.
>
> Now one idea would be to be able to jump from the macro to its
> definition.
>
> So I found that the definition of every macro is given in the autoconf
> Info page, for example under with the string:
>
> Macro: AC_ARG_ENABLE
>
> so it would be easy to jump to.
>
> Only one problem, how (thing-at-point 'word) doesn't work well with
>
> AC_ARG_ENABLE for example, so or I redefine locally how a word should be
> (if possible), or I have to do some other regexp trick to get it.
(thing-at-point 'sexp)
> Another problem is that I don't get how to look for, if I have an Info
> buffer already open it uses that position. So maybe it's better if I
> create a new Info buffer and use it.
(info "autoconf" "*autoconf*<AC_ARG_ENABLE>")
> And also how do I jump to an info page from the TOC: RET is bound to
> this:
>
> (Info-follow-nearest-node&optional FORK)
>
> But I think there is a smarter way than doing a search-regexp and then
> use that function, right?
Yes:
Info-index is an interactive compiled Lisp function in `info.el'.
(Info-index TOPIC)
Look up a string TOPIC in the index for this manual and go to that entry.
If there are no exact matches to the specified topic, this chooses
the first match which is a case-insensitive substring of a topic.
Use the , command to see the other matches.
Give an empty topic name to go to the Index node itself.
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Jump to autoconf macro documentation
2011-01-30 16:16 ` Kevin Rodgers
@ 2011-01-30 17:31 ` Andrea Crotti
2011-01-31 0:02 ` Andrea Crotti
0 siblings, 1 reply; 14+ messages in thread
From: Andrea Crotti @ 2011-01-30 17:31 UTC (permalink / raw)
To: help-gnu-emacs
> Yes:
>
> Info-index is an interactive compiled Lisp function in `info.el'.
>
> (Info-index TOPIC)
>
> Look up a string TOPIC in the index for this manual and go to that entry.
> If there are no exact matches to the specified topic, this chooses
> the first match which is a case-insensitive substring of a topic.
> Use the , command to see the other matches.
> Give an empty topic name to go to the Index node itself.
Maybe the key chosen is not the best but it works wonderfully :)
--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))))
(info "autoconf" (concat "*autconf*<" macro ">"))
(Info-index macro)))
(add-hook 'autoconf-mode-hook
(lambda ()
(local-set-key "\C-j" 'get-autoconf-macro-definition)))
--8<---------------cut here---------------end--------------->8---
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Jump to autoconf macro documentation
2011-01-30 17:31 ` Andrea Crotti
@ 2011-01-31 0:02 ` Andrea Crotti
2011-01-31 0:46 ` Le Wang
0 siblings, 1 reply; 14+ messages in thread
From: Andrea Crotti @ 2011-01-31 0:02 UTC (permalink / raw)
To: help-gnu-emacs
To be more complete I thought that I could do the following thing, first I try
to look for the macro definition in aclocal.m4, and if it's not there I try in the Info page.
So I came up with something like
--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))))
(unless (get-autoconf-macro-local macro)
(info "autoconf" (concat "*autconf*<" macro ">"))
(Info-index macro))))
(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)
(search-forward (format "AC_DEFUN([%s])" macro)))
nil)))
(add-hook 'autoconf-mode-hook
(lambda ()
(local-set-key "\C-j" 'get-autoconf-macro-definition)))
--8<---------------cut here---------------end--------------->8---
What doesn't work yet is how to return false (and thus return to the previous state in case
the macro is not found anywhere.
And I should give an error message if I don't find the macro with Info-index as well, any idea?
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Jump to autoconf macro documentation
2011-01-31 0:02 ` Andrea Crotti
@ 2011-01-31 0:46 ` Le Wang
2011-01-31 10:18 ` Andrea Crotti
0 siblings, 1 reply; 14+ messages in thread
From: Le Wang @ 2011-01-31 0:46 UTC (permalink / raw)
To: Andrea Crotti; +Cc: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 2826 bytes --]
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
<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.
On Mon, Jan 31, 2011 at 8:02 AM, Andrea Crotti <andrea.crotti.0@gmail.com>wrote:
> To be more complete I thought that I could do the following thing, first I
> try
> to look for the macro definition in aclocal.m4, and if it's not there I try
> in the Info page.
>
> So I came up with something like
> --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))))
> (unless (get-autoconf-macro-local macro)
> (info "autoconf" (concat "*autconf*<" macro ">"))
> (Info-index macro))))
>
> (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)
> (search-forward (format "AC_DEFUN([%s])" macro)))
> nil)))
>
> (add-hook 'autoconf-mode-hook
> (lambda ()
> (local-set-key "\C-j" 'get-autoconf-macro-definition)))
> --8<---------------cut here---------------end--------------->8---
>
> What doesn't work yet is how to return false (and thus return to the
> previous state in case
> the macro is not found anywhere.
>
> And I should give an error message if I don't find the macro with
> Info-index as well, any idea?
>
>
>
--
Le
[-- Attachment #2: Type: text/html, Size: 3765 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Jump to autoconf macro documentation
2011-01-31 0:46 ` Le Wang
@ 2011-01-31 10:18 ` Andrea Crotti
2011-01-31 10:31 ` Thien-Thi Nguyen
2011-01-31 22:11 ` Kevin Rodgers
0 siblings, 2 replies; 14+ messages in thread
From: Andrea Crotti @ 2011-01-31 10:18 UTC (permalink / raw)
To: help-gnu-emacs
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?
^ permalink raw reply [flat|nested] 14+ messages in thread
[parent not found: <mailman.1.1296384469.21090.help-gnu-emacs@gnu.org>]
* Re: Jump to autoconf macro documentation
[not found] <mailman.1.1296384469.21090.help-gnu-emacs@gnu.org>
@ 2011-01-31 16:14 ` Stefan Monnier
2011-01-31 23:19 ` Andrea Crotti
0 siblings, 1 reply; 14+ messages in thread
From: Stefan Monnier @ 2011-01-31 16:14 UTC (permalink / raw)
To: help-gnu-emacs
> So I found that the definition of every macro is given in the autoconf
> Info page, for example under with the string:
> Macro: AC_ARG_ENABLE
There's a general infrastructure in Emacs to jump from a use to its
Info documentation. It's bound to C-h S and is called info-lookup-symbol.
There is support for Autoconf's manual in it, so it should work.
If not, please M-x report-emacs-bug.
Stefan
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Jump to autoconf macro documentation
2011-01-31 16:14 ` Stefan Monnier
@ 2011-01-31 23:19 ` Andrea Crotti
2011-02-01 15:24 ` Oleksandr Gavenko
0 siblings, 1 reply; 14+ messages in thread
From: Andrea Crotti @ 2011-01-31 23:19 UTC (permalink / raw)
To: help-gnu-emacs
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> So I found that the definition of every macro is given in the autoconf
>> Info page, for example under with the string:
>
>> Macro: AC_ARG_ENABLE
>
> There's a general infrastructure in Emacs to jump from a use to its
> Info documentation. It's bound to C-h S and is called info-lookup-symbol.
> There is support for Autoconf's manual in it, so it should work.
> If not, please M-x report-emacs-bug.
>
>
> Stefan
Auch didn't know it, there's always one more feature to find out ;)
It works quite well yes, but it could be still added support for local
macros and things like that...
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Jump to autoconf macro documentation
2011-01-31 23:19 ` Andrea Crotti
@ 2011-02-01 15:24 ` Oleksandr Gavenko
0 siblings, 0 replies; 14+ messages in thread
From: Oleksandr Gavenko @ 2011-02-01 15:24 UTC (permalink / raw)
To: help-gnu-emacs
On 01.02.2011 1:19, Andrea Crotti wrote:
> Stefan Monnier<monnier@iro.umontreal.ca> writes:
>
>>> So I found that the definition of every macro is given in the autoconf
>>> Info page, for example under with the string:
>>
>>> Macro: AC_ARG_ENABLE
>>
>> There's a general infrastructure in Emacs to jump from a use to its
>> Info documentation. It's bound to C-h S and is called info-lookup-symbol.
>> There is support for Autoconf's manual in it, so it should work.
>> If not, please M-x report-emacs-bug.
>>
>>
>> Stefan
>
> Auch didn't know it, there's always one more feature to find out ;)
>
> It works quite well yes, but it could be still added support for local
> macros and things like that...
>
You can use TAGS file for local definition...
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2011-02-01 15:24 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-30 10:47 Jump to autoconf macro documentation Andrea Crotti
2011-01-30 15:09 ` Le Wang
2011-01-30 16:03 ` Andrea Crotti
2011-01-30 16:09 ` Thien-Thi Nguyen
2011-01-30 16:16 ` Kevin Rodgers
2011-01-30 17:31 ` Andrea Crotti
2011-01-31 0:02 ` Andrea Crotti
2011-01-31 0:46 ` Le Wang
2011-01-31 10:18 ` Andrea Crotti
2011-01-31 10:31 ` Thien-Thi Nguyen
2011-01-31 22:11 ` Kevin Rodgers
[not found] <mailman.1.1296384469.21090.help-gnu-emacs@gnu.org>
2011-01-31 16:14 ` Stefan Monnier
2011-01-31 23:19 ` Andrea Crotti
2011-02-01 15:24 ` Oleksandr Gavenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).