unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#21091: 25.0.50; `isearch-done' called before `isearch-update' raises wrong-type-arg error
@ 2015-07-19  3:57 Drew Adams
  2016-04-30 21:27 ` Lars Ingebrigtsen
  2016-09-04  3:45 ` npostavs
  0 siblings, 2 replies; 6+ messages in thread
From: Drew Adams @ 2015-07-19  3:57 UTC (permalink / raw)
  To: 21091

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'





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-09-04 20:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-19  3:57 bug#21091: 25.0.50; `isearch-done' called before `isearch-update' raises wrong-type-arg error Drew Adams
2016-04-30 21:27 ` 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

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