From: Tomas Nordin <tomasn@posteo.net>
To: Emanuel Berg <moasen@zoho.com>, help-gnu-emacs@gnu.org
Subject: Re: killing the result of isearch
Date: Mon, 13 Nov 2017 22:17:16 +0100 [thread overview]
Message-ID: <87o9o5x4ir.fsf@fliptop> (raw)
In-Reply-To: <86r2t32lip.fsf@zoho.com>
Emanuel Berg <moasen@zoho.com> writes:
> WARNING! Now there will be a lot at once. You,
> and many other people, will not agree to
> everything I say. That is completely natural as
> these are complicated matters. It is not like
> a single speed rear hub from Torpedo which has
> a limited number of parts that are put together
> in one and only one way. Everyone
> understands that.
I am warned, thanks for feedback.
>
>> (defun tn-frozen-search (arg &optional
>> start-point)
>
> arg is something that one sees in Elisp source.
> But it isn't good. It is like calling a module
> "main". It is lazy and do not contribute to the
> understanding of what it is or what it does.
> You call it "term" later, and while I'm not
> sure how much clearer that is, its better than
> arg. With arg, might as well call the function
> "function" and the file "file".
It could be called PROMPT or something like that. If non-nil, a prefix
argument was given and a search string is prompted for.
>
>> "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.
>> This function is for interactive use only.
>
> Why?
>
>> There will be an overwrap with no ding."
>
> ... you mean if it isn't used interactively?
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. I don't know how un-elispy it is to write functions mainly
for interactive use. It should be emacsy at least?
>> (cond
>> (success
>> (push-mark (car (match-data)) t t))
>> ((and (= (point) (point-min)) (not success))
>
> Isn't (not success) always true there as
> otherwise success would be true above?
You must be right.
> (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.
>
>> (if (not start-point)
>> (setq start-point (point)))
>
> `unless'? And: Avoid `setq' in functions if
> possible. Rely on `let'! Make it part of your
> game like the pawns in Chess or the artillery
> in the Red Army.
unless, ok. But the setq is manipulating a function argument, it's local
already, no?
>> (tn-frozen-search nil start-point)
>
> OK, so it *is* recursive! Still, I don't
> understand the first reference to recursion?
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.
> Again, in general recursion should be avoided
> because Elisp isn't the fastest of languages
> and especially piling functions on top of each
> other can bring it down faster than the tower
> of Babel.
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? I am aware
there is a maximum recursion depth.
>
>> (t
>> (message "semantic error in code"))))) ; hit C-x C-e
>
> How can that ever happen? Since the first
> clause is success, and the third (not success)?
> You could have the third t and remove the
> fourth what I can see. (?)
Yes. In some earlier iteration the fourth clause made sense, but not
now.
>
>> (global-set-key (kbd "<f9>") 'tn-frozen-search)
>
> (global-set-key [f9] #'tn-frozen-search)
>
> I always said the function keys should be
> avoided as it requires the hands to be moved
> from and back to typing asdf/jkl; position.
> Speed kills. So hang on to it :)
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?
Let me say though that this function was mainly trying to address part of
the OP:s expectation as I understand it, to see if that understanding is
correct.
next prev parent reply other threads:[~2017-11-13 21:17 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 [this message]
2017-11-13 22:13 ` Emanuel Berg
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87o9o5x4ir.fsf@fliptop \
--to=tomasn@posteo.net \
--cc=help-gnu-emacs@gnu.org \
--cc=moasen@zoho.com \
/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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.