unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Emanuel Berg <moasen@zoho.com>
To: help-gnu-emacs@gnu.org
Subject: Re: killing the result of isearch
Date: Mon, 13 Nov 2017 23:13:10 +0100	[thread overview]
Message-ID: <86efp13k09.fsf@zoho.com> (raw)
In-Reply-To: 87o9o5x4ir.fsf@fliptop

Tomas Nordin wrote:

>> "Search forward for a preloaded frozen term.
>> Here, "preloaded" and "frozen" aren't
>> familiar designations. If you use them,
>> explain immediately what they mean.
>> Or rephrase. Also, in the docstring, the
>> arguments, all arguments, should appear in
>> o r d e r and in CAPS. So if you change arg
>> into term, it should be ~"Search forward for
>> TERM. Blablablah START-POINT etc."
>
> Actually, I don't think any of the docstring
> try to explain the arguments. It tries to
> explain how to use the
> function interactively.

Let's put it this way, any docstring to any
function with arguments is incomplete without
a reference to each argument, in o r d e r and
in CAPS. E.g.,

    (defun do-magic (spell victim &optional alternative-incantation)
      "Invoke SPELL on VICTIM.
      If ALTERNATIVE-INCANTATION is provided, use
      that instead of the default method."
      (interactive ...) ...)

Use this to check your code:

    (defun check-package-style ()
      (interactive)
      (checkdoc-current-buffer t) ; TAKE-NOTES
      (message "Style check done.") )

> I mean that it is written only with the
> interactive use in mind. Nothing blows up if
> it is called by other code, but I don't think
> it is meaningful.

It doesn't matter. If it works both ways, don't
mention it as it is only confusing and the
implication is something will brake if you do.

> I don't know how un-elispy it is to write
> functions mainly for interactive use.
> It should be emacsy at least?

But if there is no reason why complicate
matters and limit the possibilities what one
can do with it?

>> (car search-ring) two times! Better put it
>> above success in the `let' clause and then
>> use `let*' instead.
>
> Hmmmm, ehhhh, jaahhh, maybe... But the
> variable is there already? A car call cannot
> be very costly.

It is a style and maintenance issue.

Say you have the data item 5 three times in
your code: 5, 5, and 5.

Is it faster to have a literal 5 three times
rather than one variable? Perhaps (?) but
probably not as that should be optimized
anyway.

However, say that that 5 is to be changed into
6. Now if there is a single variable, it has to
be changed *once*, with no risk of overlooking
the other twos! Much more relaxed and less
error prone to edit/read such clear code.

Here, of course the 5s shouldn't be bunched
together because they are the same value!
If one 5 refers to the five fingers, and two 5s
refer to the points of a star, there should be
- you guessed it - two variables instead
of one.

> unless, ok. But the setq is manipulating
> a function argument, it's local already, no?

More of a style issue.

> It refers to this call that will end up where
> the comment is. So this start-point argument
> is for the recursive case, and this is partly
> why I say the function doesn't make much
> sense in other code.

People come up with all sorts of crazy stuff to
do with code and actually any type of
equipment. It is not always what the
developer/producer had in mind.

> But there will be only one level of recursion
> that I am aware of. Is a recursive function
> call slower than a regular function call?

A function call, recursive or not, is slow.
So if you have recursion which can be replaced
with a loop, this will always be faster as no
stockpiling of functions on the stack.

> Yea, they are a bit far away. This is
> a suggestion. I wanted it to be some
> available single-stroke combination.
> What would you pick?

Look down on your fingers! asdf and jkl; are
the best keys. Every step away from them is one
step down the key hierarchy. The most basic
functions, that works generally and in most
modes, should get those. Functions that are
seldom used - well, by all means those can be
assigned a function key - however what I would
do is assign them a short alias and then do
M-x. It is a trade-off. Long combination of
close keys are sometimes faster than a single,
distant key. However make them too long and you
won't remember them. So best fiddle with it
back and forth until reach a state when you are
happy.

The rule is "make the common [frequent] case
fast and the rare case correct".

-- 
underground experts united
http://user.it.uu.se/~embe8573




  reply	other threads:[~2017-11-13 22:13 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-07  2:41 killing the result of isearch Jean-Christophe Helary
2017-11-07  5:34 ` Drew Adams
2017-11-07  6:01   ` Jean-Christophe Helary
2017-11-07  6:25     ` Søren Pilgård
     [not found]     ` <mailman.3103.1510035932.27995.help-gnu-emacs@gnu.org>
2017-11-07  7:07       ` Loris Bennett
2017-11-07  7:49         ` Jean-Christophe Helary
2017-11-07  8:43         ` Jean-Christophe Helary
     [not found]         ` <mailman.3106.1510044223.27995.help-gnu-emacs@gnu.org>
2017-11-07 10:49           ` Loris Bennett
2017-11-07 12:45             ` Jean-Christophe Helary
2017-11-07 15:26               ` Drew Adams
2017-11-07 15:51                 ` Jean-Christophe Helary
2017-11-07 16:46                   ` Drew Adams
2017-11-07 22:38                     ` Jean-Christophe Helary
2017-11-07 16:53                   ` Eric Abrahamsen
2017-11-07 17:24                     ` Drew Adams
2017-11-07 17:45                       ` Eric Abrahamsen
2017-11-08  8:21               ` Thien-Thi Nguyen
2017-11-08 13:47                 ` Emanuel Berg
2017-11-11 15:36                   ` Charles A. Roelli
     [not found]             ` <mailman.3114.1510058721.27995.help-gnu-emacs@gnu.org>
2017-11-07 15:08               ` Loris Bennett
2017-11-07 15:28                 ` Jean-Christophe Helary
2017-11-07 16:24                   ` Drew Adams
2017-11-07 22:34                     ` Jean-Christophe Helary
2017-11-07 22:54                       ` Drew Adams
2017-11-08 22:24                   ` Tomas Nordin
2017-11-08 22:44                     ` Jean-Christophe Helary
2017-11-08 23:07                       ` Emanuel Berg
2017-11-09 21:38                       ` Tomas Nordin
2017-11-10 13:11                         ` Jean-Christophe Helary
2017-11-10 16:54                           ` Drew Adams
2017-11-07  8:31     ` Marcin Borkowski
2017-11-07 15:26     ` Drew Adams
2017-11-07 20:59     ` Bob Proulx
2017-11-07 22:10       ` Drew Adams
2017-11-07 22:53         ` Bob Proulx
2017-11-07 23:15       ` Jean-Christophe Helary
2017-11-08  4:27         ` Bob Proulx
2017-11-08  5:29           ` Jean-Christophe Helary
2017-11-08 18:50             ` Bob Proulx
2017-11-07 17:53 ` Stefan Monnier
2017-11-07 22:59   ` Jean-Christophe Helary
2017-11-12 20:02     ` Tomas Nordin
2017-11-12 22:13       ` Emanuel Berg
2017-11-13 21:17         ` Tomas Nordin
2017-11-13 22:13           ` Emanuel Berg [this message]
2017-11-20  3:24           ` Emanuel Berg
2017-11-15 14:48       ` Emanuel Berg

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=86efp13k09.fsf@zoho.com \
    --to=moasen@zoho.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).