bmag / emacs-purpose

Manage Windows and Buffers According to Purposes
GNU General Public License v3.0
498 stars 23 forks source link

magit purpose defined by purpose-x-magit can cause error: Wrong number of arguments: (0 . 2), 3 #144

Closed qleguennec closed 5 years ago

qleguennec commented 5 years ago

The following configuration gives me the error: Wrong number of arguments: (0 . 2), 3 when I call switch-to-buffer or magit:

(use-package window-purpose
  :demand t
  :config
  (purpose-mode)
  (require 'window-purpose-x)

  (setq pop-up-frames t)
  (purpose-x-magit-single-on)
  (add-to-list 'purpose-special-action-sequences
           '(magit
         purpose-display-reuse-window-buffer
         purpose-display-reuse-window-purpose
         purpose-display-pop-up-frame)))

emacs version: 27.0.50

bmag commented 5 years ago

When you put magit in purpose-special-action-sequences like this, because a function named magit exists, Purpose interprets it as a predicate functions and calls it with 3 arguments.

The problem here is in the purpose-x-magit extension - I should change it to define a Magit purpose instead of magit, then you can put Magit instead of magit. In the meantime you can replace magit with (lambda (purpose _buffer _alist) (eq purpose 'magit)).

I'm gonna change the title to reflect the bug (it is unrelated to Emacs version).

bmag commented 5 years ago

Should be fixed by https://github.com/bmag/emacs-purpose/commit/34b4d0894dde8d99d812bb940eeef7da44732dff. You will need to replace magit with Magit in purpose-special-action-sequences.