unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: 21091@debbugs.gnu.org
Subject: bug#21091: 25.0.50; `isearch-done' called before `isearch-update' raises wrong-type-arg error
Date: Sat, 18 Jul 2015 20:57:32 -0700 (PDT)	[thread overview]
Message-ID: <d59c504a-132b-4166-82b0-e0d9a0bac78a@default> (raw)

Dunno whether I'll be able to convince you that this is a bug, but here
goes.

Recently someone added `isearch--current-buffer' to isearch.el.

This is initially nil.  It is given a string value (buffer name) only in
`isearch-update'.  But it is called in `isearch-done' and expected to
have a string value there.  If it does not, a wrong-type-arg error is
raised.

I have code that defines some Isearch commands that each start out by
calling (isearch-done) - they can be called at top level or from
`isearch-mode-map'.  Here is the beginning of one:

(defun foo (arg)
  (interactive "P")
  (bar 'isearch-forward arg))

(defun bar (arg)
  (isearch-done)
  (setq isearch-success   t
        isearch-adjusted  t)
  (let* ((enable-recursive-minibuffers t)
         ...)
    ...
    (setq isearch-filter-predicate ...)
    ...)
  (funcall search-fn))

When called at top level, `isearch--current-buffer' is nil, and the
wrong-type arg error is raised.

I can "fix" the problem that was introduced by wrapping the
`isearch-done' call in `ignore-errors'.  But I think it would be better
for isearch.el not to assume that `isearch-done' is called after
`isearch-update'.  I don't think there is a reason why the two need to
be coupled in that way.  Adding variable `isearch--current-buffer' in
the way it was done makes the isearch.el code more fragile than it needs
to be, I think.

Anyway, please consider somehow ensuring that `isearch-done' does not
care whether `isearch--current-buffer' has a string value.

Perhaps one possibility would be something like this - dunno.

  (when isearch--current-buffer
    (with-current-buffer isearch--current-buffer
      (setq isearch--current-buffer nil)
      (setq cursor-sensor-inhibit (delq 'isearch cursor-sensor-inhibit))))

Or maybe even:

  (when (and isearch--current-buffer
             (get-buffer isearch--current-buffer))
    ...)


In GNU Emacs 25.0.50.1 (i686-pc-mingw32)
 of 2015-07-03 on LEG570
Bzr revision: 2b848fadd51e805b2f46da64c5958ea7f009048a
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --host=i686-pc-mingw32 --enable-checking=yes,glyphs'





             reply	other threads:[~2015-07-19  3:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-19  3:57 Drew Adams [this message]
2016-04-30 21:27 ` bug#21091: 25.0.50; `isearch-done' called before `isearch-update' raises wrong-type-arg error Lars Ingebrigtsen
2016-09-04  0:08   ` Drew Adams
2016-09-04  3:45 ` npostavs
2016-09-04  5:43   ` Drew Adams
2016-09-04 20:47     ` npostavs

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=d59c504a-132b-4166-82b0-e0d9a0bac78a@default \
    --to=drew.adams@oracle.com \
    --cc=21091@debbugs.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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).