From c676444a43e4634c1f98ec286b5bd9e46b23216b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Engdeg=C3=A5rd?= Date: Wed, 31 Jul 2019 19:45:06 +0200 Subject: Add conditional operator xor to subr.el Suggested by Oleh Krehel and implemented by Basil Contovounesios in the following thread: https://lists.gnu.org/archive/html/emacs-devel/2019-07/msg00547.html * lisp/array.el (xor): Move unused function from here... * lisp/subr.el: ...to here, and improve. * lisp/gnus/spam.el (spam-xor): * lisp/play/5x5.el (5x5-xor): * lisp/proced.el (proced-xor): * lisp/progmodes/idlwave.el (idlwave-xor): * lisp/vc/diff-mode.el (diff-xor): Define as obsolete aliases of, and replace all uses with, xor. * lisp/jsonrpc.el: Remove unused dependency on array.el. * lisp/org/org.el (org-xor): Move from here... * lisp/org/org-compat.el (org-xor): ...to here, as a compatibility shim for xor. * lisp/progmodes/idlw-shell.el (idlwave-shell-enable-all-bp): * lisp/simple.el (exchange-point-and-mark): * lisp/windmove.el (windmove-display-in-direction): Use xor. * lisp/strokes.el (strokes-xor): Remove commented-out xor implementation. * doc/lispref/control.texi (Control Structures): Extend menu entry for new combining condition. (Combining Conditions): * etc/NEWS (Lisp Changes): Document xor. * test/lisp/subr-tests.el (subr-test-xor): New test. --- lisp/proced.el | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'lisp/proced.el') diff --git a/lisp/proced.el b/lisp/proced.el index db8bdb5ac80..24bc321f434 100644 --- a/lisp/proced.el +++ b/lisp/proced.el @@ -1194,10 +1194,7 @@ Return `equal' if T1 equals T2. Return nil otherwise." ;;; Sorting -(defsubst proced-xor (b1 b2) - "Return the logical exclusive or of args B1 and B2." - (and (or b1 b2) - (not (and b1 b2)))) +(define-obsolete-function-alias 'proced-xor 'xor "27.1") (defun proced-sort-p (p1 p2) "Predicate for sorting processes P1 and P2." @@ -1208,8 +1205,8 @@ Return `equal' if T1 equals T2. Return nil otherwise." (k2 (cdr (assq (car sorter) (cdr p2))))) ;; if the attributes are undefined, we should really abort sorting (if (and k1 k2) - (proced-xor (funcall (nth 1 sorter) k1 k2) - (nth 2 sorter)))) + (xor (funcall (nth 1 sorter) k1 k2) + (nth 2 sorter)))) (let ((sort-list proced-sort-internal) sorter predicate k1 k2) (catch 'done (while (setq sorter (pop sort-list)) @@ -1219,7 +1216,7 @@ Return `equal' if T1 equals T2. Return nil otherwise." (if (and k1 k2) (funcall (nth 1 sorter) k1 k2))) (if (not (eq predicate 'equal)) - (throw 'done (proced-xor predicate (nth 2 sorter))))) + (throw 'done (xor predicate (nth 2 sorter))))) (eq t predicate))))) (defun proced-sort (process-alist sorter descend) -- cgit v1.2.1