[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to generate a help-function-def-button?
From: |
"Rocky Zhang" |
Subject: |
Re: How to generate a help-function-def-button? |
Date: |
Wed, 28 Mar 2012 19:29:54 -0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (windows-nt) |
Alan <wehmann@fnal.gov> writes:
> On Dec 20, 12:32 pm, Rocky Zhang <rocky...@163.com-NOSPAM> wrote:
>> Hi, everybody!
>>
>> The `help-function-def-button' in the help-window is very
>> convenient to jump to the definition of a function. But I
>> don't know how to generate such a button. Can anyone give
>> me some tips about it?
>>
>> I've read the codes of `describe-function' in the
>> `help-fns.el', but that's difficult to me to get point of
>> it.
>>
>> Thanks very much!
>>
>> Best wishes,
>> Rocky Zhang
>>
>> --- Posted via news://freenews.netfront.net/ - Complaints to
>> n...@netfront.net ---
>
> I made the following notes to myself, while learning how to make such
> buttons:
>
> -----------------------------------------------------------------------------------------------------
>
> Below is an example of using "make-button", taken from "startup.el".
>
> (make-button (prog1 (point) (insert-image img)) (point)
> 'face 'default
> 'help-echo "mouse-2, RET: Browse http://www.gnu.org/"
> 'action (lambda (button) (browse-url "http://
> www.gnu.org/"))
> 'follow-link t)
Thanks a lot! I replaced the sexp (insert-image img) with (insert
"img"),and copy this lisp code to *scratch* buffer, then press "C-j".
It does show that button, but followed with some text like this #<overlay
from 439 to 442 in *scratch*>.
>
> Note the use of 'follow-link t. This is to make Mouse button 1 follow
> links, if its duration is less than 450 milliseconds.
>
> If a mouse click activates a button, subsequent use of "yes-or-no-p"
> may use "dialog boxes". Help for that function says:
>
> yes-or-no-p is a built-in function in `fns.c'.
^^^^^In fact, my really
point is how to get the
link of button `fns.c'.
This can help people jump
to the definition of the
function conveniently.
>
> (yes-or-no-p PROMPT)
>
> Ask user a yes-or-no question. Return t if answer is yes.
> Takes one argument, which is the string to display to ask the
> question. It should end in a space; `yes-or-no-p' adds `(yes or
> no) ' to it. The user must confirm the answer with RET, and can
> edit it until it has been confirmed.
>
> Under a windowing system a dialog box will be used if
> `last-nonmenu-event' is nil, and `use-dialog-box' is non-nil.
>
> -----------------------------------------------------------------------------------------------------
>
> I defined a function to standardize my buttons:
>
> (defun aw-make-button (button_text action_function remaining_text
> &optional help_text new_line)
> "inserts a button e.g. in nova control buffer"
> (if (null help_text)
> (setq help_text button_text))
> (if (bolp)
> (insert "-"))
> (make-button (prog1 (point) (insert button_text)) (point)
> 'help-echo (concat "mouse-1, RET: " help_text)
> 'action action_function
> 'follow-link t)
> (if (null new_line)
> (insert remaining_text "\n\n")
> (insert remaining_text)))
>
> An example of using my "aw-make-button" function is:
>
> (aw-make-button "Open customization group: nova_review"
> '(lambda (button) (customize-group "nova_review"))
> "\t\t" nil t)
>
> I was handing off a fair amount of lisp code to someone who knew
> Emacs, but knew little lisp. I wanted to use buttons to automate a
> fair amount of what I had been doing with lisp, so that this person
> could simply click on buttons in a buffer.
Finally, Thank you for you reply again!
Best wishes,
Rocky Zhang
--- Posted via news://freenews.netfront.net/ - Complaints to news@netfront.net
---