Skip to content

Commit

Permalink
use external dash library
Browse files Browse the repository at this point in the history
Five months ago I tried to have a discussion about starting to depend
on the external Dash library.  Unfortunately a troll appeared, making
any meaningful conversation impossible.  This was very stressful and
shortly after I almost had a burnout.

Back then I said I would eventually reopen the discussion.  I have now
decided not to do so and instead have start to depend on dash without
any further discussion.  I have considered the concerns raised back
then and have come to the conclusion that me having to work around
Emacs Lisp's limitations is a greater cost (not only to me, but also
to Magit as a project and to its users) than any of the concerns that
were raised.

---

I write Emacs extensions because working with "the buffer" as opposed
to e.g. "the dom" is rewarding.  On the other hand Emacs Lisp leaves
much to be desired.

Using Dash makes some of the major pain points go away.  That's why
many in the new generation of extension authors use Dash.  It makes
our lives easier if we don't have to constantly reinvent the wheel,
just so that we too get to use some of the improvement made to LISP
over the last few decades.

Users benefit too, because by using a library we can focus on the
project specific issue.   And when we use well tested and widely
used libraries instead of quick hacks, then bugs are less likely.

On the other hand this might cause some inconvenience for some users.
But it is the author not the user who gets to decide what language
(and in this case language libraries) the author uses.  By improving
Magit I provide a lot of convenience to its users.  A troll who attacks
me for occasionally doing things that make my life easier, instead of
his life, misses the bigger picture.  Consider it a reward for working
on Magit.

---

At this point I have just quickly scrolled though the code and started
to use forms from Dash in places that jumped at me.  There surely are
many more places where doing so would be beneficial.  As I run into
these places I will start using Dash there too.
  • Loading branch information
tarsius committed Feb 22, 2014
1 parent 4aa4d87 commit e11f0be
Show file tree
Hide file tree
Showing 3 changed files with 275 additions and 333 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -26,7 +26,7 @@ RMDIR ?= rm -rf
MAKEINFO ?= makeinfo
INSTALL_INFO ?= install-info

EFLAGS ?= -L ../git-modes -L ../cl-lib
EFLAGS ?= -L ../git-modes -L ../cl-lib -L ../dash
EMACS ?= emacs
BATCH = $(EMACS) $(EFLAGS) -batch -Q -L .
BATCHE = $(BATCH) -eval
Expand Down
57 changes: 28 additions & 29 deletions magit-popup.el
Expand Up @@ -52,6 +52,7 @@

(require 'button)
(require 'cl-lib)
(require 'dash)
(require 'format-spec)

;;;; Declarations
Expand Down Expand Up @@ -428,41 +429,39 @@ that without users being aware of it could lead to tears.

(defun magit-invoke-popup-switch (event)
(interactive (list last-command-event))
(let ((ev (magit-popup-lookup event :switches)))
(if ev
(progn (setf (magit-popup-event-use ev)
(not (magit-popup-event-use ev)))
(magit-refresh-popup-buffer))
(error "%c isn't bound to any switch" event))))
(--if-let (magit-popup-lookup event :switches)
(progn
(setf (magit-popup-event-use it)
(not (magit-popup-event-use it)))
(magit-refresh-popup-buffer))
(error "%c isn't bound to any switch" event)))

(defun magit-invoke-popup-option (event)
(interactive (list last-command-event))
(let ((ev (magit-popup-lookup event :options)))
(if ev
(progn
(if (magit-popup-event-use ev)
(setf (magit-popup-event-use ev) nil)
(let* ((arg (magit-popup-event-arg ev))
(val (funcall
(magit-popup-event-fun ev)
(concat arg (unless (string-match-p "=$" arg) ": "))
(magit-popup-event-val ev))))
(setf (magit-popup-event-use ev) t)
(setf (magit-popup-event-val ev) val)))
(magit-refresh-popup-buffer))
(error "%c isn't bound to any option" event))))
(--if-let (magit-popup-lookup event :options)
(progn
(if (magit-popup-event-use it)
(setf (magit-popup-event-use it) nil)
(let* ((arg (magit-popup-event-arg it))
(val (funcall
(magit-popup-event-fun it)
(concat arg (unless (string-match-p "=$" arg) ": "))
(magit-popup-event-val it))))
(setf (magit-popup-event-use it) t)
(setf (magit-popup-event-val it) val)))
(magit-refresh-popup-buffer))
(error "%c isn't bound to any option" event)))

(defun magit-invoke-popup-action (event)
(interactive (list last-command-event))
(let ((ev (magit-popup-lookup event :actions)))
(if ev
(let ((magit-current-popup magit-this-popup)
(magit-current-popup-args (magit-popup-get-args)))
(magit-popup-quit)
(call-interactively (magit-popup-event-fun ev)))
(if (eq event ?q)
(magit-popup-quit)
(error "%c isn't bound to any action" event)))))
(--if-let (magit-popup-lookup event :actions)
(let ((magit-current-popup magit-this-popup)
(magit-current-popup-args (magit-popup-get-args)))
(magit-popup-quit)
(call-interactively (magit-popup-event-fun it)))
(if (eq event ?q)
(magit-popup-quit)
(error "%c isn't bound to any action" event))))

(defun magit-popup-quit ()
(interactive)
Expand Down

0 comments on commit e11f0be

Please sign in to comment.