From: Tim Johnson <tim@akwebsoft.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Proper use of function form
Date: Mon, 27 Apr 2020 11:12:22 -0800 [thread overview]
Message-ID: <9e707c54-047a-eb8a-1c56-e6c69734b11e@akwebsoft.com> (raw)
In-Reply-To: <87pnbt2w03.fsf@ebih.ebihd>
On 4/27/20 12:06 AM, Emanuel Berg via Users list for the GNU Emacs text
editor wrote:
> Tim Johnson wrote:
>
>> Here is a key definition:
>>
>> (define-key jinja2-mode-map (kbd "C-c i") #'jinja2-insert-var)
>>
>> As I understand it, the sharp-quote (#') tells the
>> compiler that jinja2-insert-var is meant to be
>> a function
> Yes, that's what happens. I don't know what the
> byte-compiler does with that information tho, maybe it
> is just a matter of it being able to warn you if that
> function doesn't exist, since with the hash-quote, it
> knows where to look specifically...
>
> But there is also the advantage of you being able to see
> that something is, or supposed to be, a function.
>
> Perhaps font-lock could also be told to give it
> a special color, e.g. `font-lock-function-name-face', if
> desired - to increase seeing/reduce reading
> even further.
>
>> The following quotation:
>>
>> "it is always good practice to sharp quote every
>> symbol that is the name of a function, whether it's
>> going into a mapcar, an apply, a funcall, or
>> anything else."
> Well, that's what I do and it always worked. But if you
> seek a more scientific documentation and practical
> HOWTO, surely this is documented in the official
> manual(s)?
>
>> (setq my-keypairs '("h" my-h-func "g" my-g-func "f" my-f-func))
>>
>> and using iteration to *programmatically* call
>> define-key for multiple key definitions as in
>>
>> (define-key mymap ;; add to keymap
>> (kbd (concat ldr (nth ndx mylist))) ;; sequence as in "g"
>> (nth (+ ndx 1) mylist)) ;;
>> command as in my-g-func
>>
>> The form above is indeed a snippet from a defun that
>> I have used for years
>>
>> Would it be better to change (nth (+ ndx 1) mylist) to
>> (function (nth (+ ndx 1) mylist)) ?
> But even if that had worked all the advantages mentioned
> so far would be lost, right?
>
> Maybe you could initially instead of the quote use the
> backquote/comma, or `list', with hash-quote?
>
Thanks Emanuel. Of course you know that it was your use of the
sharp-quote in a response to an earlier question by me that prompted me
to ask this latter question. I will play around with with subsequent
advice when I have the time.
cheers
--
Tim
tj49.com
prev parent reply other threads:[~2020-04-27 19:12 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-26 23:27 Proper use of function form Tim Johnson
2020-04-27 0:05 ` Michael Heerdegen
2020-04-27 0:43 ` Tim Johnson
2020-04-27 0:48 ` Noam Postavsky
2020-04-27 1:58 ` Tim Johnson
2020-04-27 8:06 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-04-27 19:12 ` Tim Johnson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9e707c54-047a-eb8a-1c56-e6c69734b11e@akwebsoft.com \
--to=tim@akwebsoft.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).