all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#25941: 26.0.50; Different code behavior between using the auto-compiled and evaled versions
@ 2017-03-02 23:43 Kaushal Modi
  2017-03-03 12:12 ` Kaushal Modi
  0 siblings, 1 reply; 6+ messages in thread
From: Kaushal Modi @ 2017-03-02 23:43 UTC (permalink / raw)
  To: 25941, ohwoeowho

[-- Attachment #1: Type: text/plain, Size: 5156 bytes --]

I discovered a difference in between when running a command from the avy
package (available on GNU Elpa).

I verified that this issue did not exist on emacs 25.1 or emacs 25.2.1.

But it does exist on emacs 26.0.50.

How to recreate the problem:

1. emacs -Q
2. Install the avy package from GNU Elpa
3. M-x toggle-debug-on-error
4. M-x avy-goto-line
5. Enter the number 10

You will get a backtrace like this:

=====
Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p nil)
  avy-action-goto(nil)
  avy-goto-line(1)
  funcall-interactively(avy-goto-line 1)
  call-interactively(avy-goto-line record nil)
  command-execute(avy-goto-line record)
  execute-extended-command(nil "avy-goto-line" nil)
  funcall-interactively(execute-extended-command nil "avy-goto-line" nil)
  call-interactively(execute-extended-command nil nil)
  command-execute(execute-extended-command)
=====

By edebugging the avy.el code, I figured out that the problem was that this
function was returning nil when it should in fact be returning t.

The difficulty in debugging this further is that if I evaluate that
function (avy--process), then the problem goes away.
With point in that function, after I do C-M-x, M-x avy-goto-line starts
working fine.

This problem repeats after each emacs restart; and goes away after C-M-x on
avy--process.

This means that when the compiled version of avy--process is loaded, that
function returns nil incorrectly. But after manually evaluating it, it
starts returning t when expected.

=====
(defun avy--process (candidates overlay-fn)
  "Select one of CANDIDATES using `avy-read'.
Use OVERLAY-FN to visualize the decision overlay."
  (unless (and (consp (car candidates))
               (windowp (cdar candidates)))
    (setq candidates
          (mapcar (lambda (x) (cons x (selected-window)))
                  candidates)))
  (let ((len (length candidates))
        (cands (copy-sequence candidates))
        res)
    (if (= len 0)
        (message "zero candidates")
      (if (= len 1)
          (setq res (car candidates))
        (unwind-protect
             (progn
               (avy--make-backgrounds
                (avy-window-list))
               (setq res (if (eq avy-style 'de-bruijn)
                             (avy-read-de-bruijn
                              candidates avy-keys)
                           (avy-read (avy-tree candidates avy-keys)
                                     overlay-fn
                                     #'avy--remove-leading-chars))))
          (avy--done)))
      (cond ((eq res 'restart)
             (avy--process cands overlay-fn))
            ;; ignore exit from `avy-handler-function'
            ((eq res 'exit))
            (t
             (avy-push-mark)
             (when (and (consp res)
                        (windowp (cdr res)))
               (let* ((window (cdr res))
                      (frame (window-frame window)))
                 (unless (equal frame (selected-frame))
                   (select-frame-set-input-focus frame))
                 (select-window window))
               (setq res (car res)))

             (funcall (or avy-action 'avy-action-goto)
                      (if (consp res)
                          (car res)
                        res)))))))
=====

More info..

The avy--process is called via avy--line when doing M-x avy-goto-line.
Below is the relevant snippet from the avy-goto-line fn. Notice the r
variable.
When numbers are entered as input after M-x avy-goto-line, that (avy--line
(eq arg 4) form should return t. But it is returning nil instead. So
avy-action-goto gets called when it shouldn't be.

After manually evaluating avy--process, r is set to t instead of nil as
expected and the problem goes away.

===== snippet from avy-goto-line fn definition =====
             (r (avy--line (eq arg 4))))
        (unless (eq r t)
          (avy-action-goto r))))))
=====

I started off this bug report on the package github page:
https://github.com/abo-abo/avy/issues/182
But realizing that the same package version works fine on emacs 25.x but
not on the master build, I am filing this report.

In GNU Emacs 26.0.50 (build 52, x86_64-unknown-linux-gnu, GTK+ Version
2.24.23)
 of 2017-03-02
Repository revision: d0d26c1379598983d2163deb13ba8ab13b14ba2c
Windowing system distributor 'The X.Org Foundation', version 11.0.60900000
System Description: Red Hat Enterprise Linux Workstation release 6.6
(Santiago)


Configured using:
 'configure --with-modules
 --prefix=/home/kmodi/usr_local/apps/6/emacs/master
 '--program-transform-name=s/^ctags$/ctags_emacs/'
 'CPPFLAGS=-fgnu89-inline -I/home/kmodi/usr_local/6/include
 -I/usr/include/freetype2 -I/usr/include' 'CFLAGS=-ggdb3 -O0'
 'CXXFLAGS=-ggdb3 -O0' 'LDFLAGS=-L/home/kmodi/usr_local/6/lib
 -L/home/kmodi/usr_local/6/lib64 -ggdb3''

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS
NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK2 X11 MODULES

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=none
  locale-coding-system: utf-8-unix


-- 

Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 7287 bytes --]

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

end of thread, other threads:[~2017-03-09 19:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-02 23:43 bug#25941: 26.0.50; Different code behavior between using the auto-compiled and evaled versions Kaushal Modi
2017-03-03 12:12 ` Kaushal Modi
2017-03-09 16:31   ` Kaushal Modi
2017-03-09 18:23     ` Vibhav Pant
2017-03-09 18:28       ` Kaushal Modi
2017-03-09 19:15         ` Kaushal Modi

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.