diff --git a/src/workgroups-association.el b/src/workgroups-association.el index 3cbd7e82e7941ee3aca38da6cdacc1ac39016d88..2df7fce4895bf10e49856cf15d2a2ec50bfa68d7 100644 --- a/src/workgroups-association.el +++ b/src/workgroups-association.el @@ -130,7 +130,7 @@ associate them." WINDOW-OR-EMACS-WINDOW-TREE with the given WORKGROUP. WINDOW-OR-EMACS-WINDOW-TREE must be either a window or a tree of the form produced by `(car (window-tree))'." - (wg-aif (windowp window-or-emacs-window-tree) + (if (windowp window-or-emacs-window-tree) (with-current-buffer (window-buffer window-or-emacs-window-tree) (setq wg-buffer-workgroup workgroup)) (dolist (w (cddr window-or-emacs-window-tree)) diff --git a/src/workgroups-buf.el b/src/workgroups-buf.el index c47e5668ab4d285409f895b664931e7cb7b34260..c961488e0d533181d30faf0d3bf712506123c731 100644 --- a/src/workgroups-buf.el +++ b/src/workgroups-buf.el @@ -187,7 +187,7 @@ This is only here for completeness." (defun wg-find-buffer-in-buf-list (buffer-or-name buf-list) "Find BUFFER-OR-NAME in BUF-LIST." - (wg-aif (wg-buffer-uid buffer-or-name) + (aif (wg-buffer-uid buffer-or-name) (wg-find-bufobj-by-uid it buf-list) (wg-find-bufobj buffer-or-name buf-list))) @@ -241,7 +241,7 @@ If there isn't already a buf corresponding to BUFFER in in either case." (with-current-buffer buffer (setq wg-buffer-uid - (wg-aif (wg-find-buffer-in-buf-list buffer (wg-buf-list)) + (aif (wg-find-buffer-in-buf-list buffer (wg-buf-list)) (wg-buf-uid it) (let ((buf (wg-buffer-to-buf buffer))) (push buf (wg-buf-list)) @@ -350,7 +350,7 @@ Read with PROMT DEFAULT REQUIRE-MATCH." (wg-with-buffer-list-filters 'read-buffer (funcall (wg-read-buffer-function) (wg-buffer-list-filter-prompt - (wg-aif (string-match ": *$" prompt) + (aif (string-match ": *$" prompt) (substring prompt 0 it) prompt)) default require-match)))) diff --git a/src/workgroups-specialbufs.el b/src/workgroups-specialbufs.el index f8339af10bdee285dbd5fcde40d3fca28a205bc4..55c8c1d7fbcd0bdc84f2a3b944bd966316758e58 100644 --- a/src/workgroups-specialbufs.el +++ b/src/workgroups-specialbufs.el @@ -56,7 +56,7 @@ how to write your own." (deserialize . ,(lambda (buffer vars) ;;(with-current-buffer ;; (get-buffer-create (wg-buf-name buffer)) - (wg-aif vars + (aif vars (if (fboundp 'Info-find-node) (apply #'Info-find-node it)) (info) diff --git a/src/workgroups-utils-basic.el b/src/workgroups-utils-basic.el index 904ce9e9b3581a61c9df18833cc586404407763f..a22b56b674aecbda62256d3d51e898b03881eb99 100644 --- a/src/workgroups-utils-basic.el +++ b/src/workgroups-utils-basic.el @@ -8,6 +8,7 @@ ;;; utils used in macros (require 'cl-lib) +(require 'anaphora) (require 'workgroups-faces) (require 'workgroups-variables) @@ -92,15 +93,10 @@ Else do ELSE... ;;; anaphora -(defmacro wg-aif (test then &rest else) - "Anaphoric `if'." - (declare (indent 2)) - `(let ((it ,test)) (if it ,then ,@else))) - (defmacro wg-awhen (test &rest body) "Anaphoric `when'." (declare (indent 1)) - `(wg-aif ,test (progn ,@body))) + `(aif ,test (progn ,@body))) (defmacro wg-asetf (&rest places-and-values) "Anaphoric `setf'." @@ -311,7 +307,7 @@ This only exists to get rid of duplicate lambdas in a few reductions." (defun wg-aget (alist key &optional default) "Return the value of KEY in ALIST. Uses `assq'. If PARAM is not found, return DEFAULT which defaults to nil." - (wg-aif (assq key alist) (cdr it) default)) + (aif (assq key alist) (cdr it) default)) (defun wg-acopy (alist) "Return a copy of ALIST's toplevel list structure." diff --git a/src/workgroups-workgroup.el b/src/workgroups-workgroup.el index 0e880abcea7158bea81a06ba060a3543c6803905..ec6df8c43a8d37da5697b30f9cd04c96c74eb4e7 100644 --- a/src/workgroups-workgroup.el +++ b/src/workgroups-workgroup.el @@ -27,17 +27,16 @@ that doesn't name an existing workgroup." (setf (wg-workgroup-modified workgroup) t) (setf (wg-session-modified (wg-current-session)) t))) - (defun wg-current-workgroup (&optional noerror frame) "Return the current workgroup in FRAME, or error unless NOERROR." (or wg-current-workgroup - (wg-aif (frame-parameter frame 'wg-current-workgroup-uid) + (aif (frame-parameter frame 'wg-current-workgroup-uid) (wg-find-workgroup-by :uid it noerror) (unless noerror (error "No current workgroup in this frame"))))) (defun wg-previous-workgroup (&optional noerror frame) "Return the previous workgroup in FRAME, or error unless NOERROR." - (wg-aif (frame-parameter frame 'wg-previous-workgroup-uid) + (aif (frame-parameter frame 'wg-previous-workgroup-uid) (wg-find-workgroup-by :uid it noerror) (unless noerror (error "No previous workgroup in this frame")))) diff --git a/src/workgroups-wtree.el b/src/workgroups-wtree.el index 4392f1c2edee7f4b9e08f139baf01ed97c7ffc17..dd647e5b81a20693e88cac0056f7053b5a3efdcd 100644 --- a/src/workgroups-wtree.el +++ b/src/workgroups-wtree.el @@ -193,7 +193,7 @@ Otherwise, reverse WTREE vertically." (wg-make-wtree :dir (wg-wtree-dir w) :edges (wg-wtree-edges w) - :wlist (wg-aif (cl-find t wlist :key 'wg-win-selected) + :wlist (aif (cl-find t wlist :key 'wg-win-selected) (wg-cyclic-offset-elt it wlist offset) (mapcar #'inner wlist))))))) (wg-normalize-wtree (inner wtree))))