abo-abo / ace-window

Quickly switch windows in Emacs
977 stars 87 forks source link

avy-mouse-event-window #124

Closed nickdrozd closed 6 years ago

nickdrozd commented 6 years ago

I went to rebase on master recently and discovered that I couldn't run ace-window. It kept telling me that avy-mouse-event-window was not defined. Looking into the problem, I discovered that that function was added to avy in https://github.com/abo-abo/avy/commit/a0ce6a7558e48b2ae150042a3e3cd559ba26152c and introduced into ace-window in https://github.com/abo-abo/ace-window/commit/5e733ff695062725d39acd241bf8b3c6efcc5447. I was running the MELPA stable version of avy (https://stable.melpa.org/#/avy), so indeed I did not have that function defined.

I don't know if its introduction was intentional, since the commit message only mentions "minor changes". The code also seems a little strange to me:

(defun aw-dispatch-default (char)
  "Perform an action depending on CHAR."
  (cond ((avy-mouse-event-window char)) ; <-- where is the consequent? <--
        ((= char (aref (kbd "C-g") 0))
         (throw 'done 'exit))
        ((= char aw-make-frame-char)
         ;; Make a new frame and perform any action on its window.
         (let ((start-win (selected-window))
               (end-win (frame-selected-window (aw-make-frame))))
           (if aw-action
               ;; Action must be called from the start-win.  The action
               ;; determines which window to leave selected.
               (progn (select-frame-set-input-focus (window-frame start-win))
                      (funcall aw-action end-win))
             ;; Select end-win when no action
             (aw-switch-to-window end-win)))
         (throw 'done 'exit))
        (t
         (let ((action (aw--dispatch-action char)))
           (if action
               (cl-destructuring-bind (_key fn &optional description) action
                 (if (and fn description)
                     (prog1 (setq aw-action fn)
                       (aw-set-mode-line (format " Ace - %s" description)))
                   (funcall fn)
                   (throw 'done 'exit)))
             (aw-clean-up-avy-current-path)
             ;; Prevent any char from triggering an avy dispatch command.
             (let ((avy-dispatch-alist))
               (avy-handler-default char)))))))

If it really should be there, perhaps a new stable version should be released? Or something like that?

abo-abo commented 6 years ago

If it really should be there, perhaps a new stable version should be released? Or something like that?

Thanks, I'll look into that.

At the same time, I don't see anything strange going on: the stable version of ace-window works fine with the stable version of avy.

It would be nice for the unstable version of ace-window to be compatible with the stable version of avy. But is it OK if not always the case?

As a user you have some fall-back options:

I'll add a fboundp check to ace-window for the time being, until a new stable avy version.

abo-abo commented 6 years ago

Thanks, added fboundp check. Sorry for the delay.

nickdrozd commented 6 years ago

Thanks, that did it!