[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/undo-fu-session 00bc3807d7 25/53: Cleanup: replace 'if' wi
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/undo-fu-session 00bc3807d7 25/53: Cleanup: replace 'if' with 'cond' |
Date: |
Thu, 7 Jul 2022 12:05:17 -0400 (EDT) |
branch: elpa/undo-fu-session
commit 00bc3807d7286a686a829832305ecb2903a95cb6
Author: Campbell Barton <ideasman42@gmail.com>
Commit: Campbell Barton <ideasman42@gmail.com>
Cleanup: replace 'if' with 'cond'
Personal preference.
---
undo-fu-session-test.el | 8 ++-
undo-fu-session.el | 156 +++++++++++++++++++++++++++---------------------
2 files changed, 94 insertions(+), 70 deletions(-)
diff --git a/undo-fu-session-test.el b/undo-fu-session-test.el
index 6320219a49..02cf865c81 100644
--- a/undo-fu-session-test.el
+++ b/undo-fu-session-test.el
@@ -56,8 +56,10 @@
(let ((contents (buffer-string)))
(set-buffer-modified-p nil)
(kill-buffer (current-buffer))
- (if (string-equal contents "")
- (message "Test succeeded #%s" f)
- (error "Test failed #%s" f)))))))
+ (cond
+ ((string-equal contents "")
+ (message "Test succeeded #%s" f))
+ (t
+ (error "Test failed #%s" f))))))))
(message "Done")
diff --git a/undo-fu-session.el b/undo-fu-session.el
index 1f59ce4a8a..2d4b3ebb93 100644
--- a/undo-fu-session.el
+++ b/undo-fu-session.el
@@ -136,9 +136,11 @@ ignoring all branches that aren't included in the current
undo state."
;;
;; Note that we use 'nil' as this is what `buffer-undo-list' is set
;; to when there are no undo steps yet.
- (if (and linear-list (not (equal (list nil) linear-list)))
- (nreverse linear-list)
- nil)))
+ (cond
+ ((and linear-list (not (equal (list nil) linear-list)))
+ (nreverse linear-list))
+ (t
+ nil))))
;; ---------------------------------------------------------------------------
;; Undo Encode/Decode Functionality
@@ -148,34 +150,40 @@ ignoring all branches that aren't included in the current
undo state."
(cond
((consp tree)
(let ((value (funcall fn tree)))
- (if (eq value tree)
- (let*
- (
- (cons (cons (undo-fu-session--walk-tree fn (car tree)) nil))
- (cur cons)
- cdr)
- (while tree
- (setq cdr (cdr tree))
- (if (consp cdr)
- (let ((next (cons (undo-fu-session--walk-tree fn (car cdr))
nil)))
- (setcdr cur next)
- (setq cur next)
- (setq tree cdr))
- (setcdr cur (undo-fu-session--walk-tree fn cdr))
- (setq tree nil)))
- cons)
- value)))
+ (cond
+ ((eq value tree)
+ (let*
+ (
+ (cons (cons (undo-fu-session--walk-tree fn (car tree)) nil))
+ (cur cons)
+ cdr)
+ (while tree
+ (setq cdr (cdr tree))
+ (cond
+ ((consp cdr)
+ (let ((next (cons (undo-fu-session--walk-tree fn (car
cdr)) nil)))
+ (setcdr cur next)
+ (setq cur next)
+ (setq tree cdr)))
+ (t
+ (setcdr cur (undo-fu-session--walk-tree fn cdr))
+ (setq tree nil))))
+ cons))
+ (t
+ value))))
((vectorp tree)
(let ((value (funcall fn tree)))
- (if (eq value tree)
- (let*
- (
- (length (length tree))
- (vector (make-vector length nil)))
- (dotimes (i (1- length))
- (aset vector i (undo-fu-session--walk-tree fn (aref tree i))))
- vector)
- value)))
+ (cond
+ ((eq value tree)
+ (let*
+ (
+ (length (length tree))
+ (vector (make-vector length nil)))
+ (dotimes (i (1- length))
+ (aset vector i (undo-fu-session--walk-tree fn (aref tree i))))
+ vector))
+ (t
+ value))))
(tree
(funcall fn tree))))
@@ -186,9 +194,11 @@ ignoring all branches that aren't included in the current
undo state."
(cond
((markerp a)
(cons
- (if (marker-insertion-type a)
- 'marker*
- 'marker)
+ (cond
+ ((marker-insertion-type a)
+ 'marker*)
+ (t
+ 'marker))
(marker-position a)))
((overlayp a)
`(overlay ,(overlay-start a) ,(overlay-end a)))
@@ -202,29 +212,33 @@ ignoring all branches that aren't included in the current
undo state."
"Decode `TREE' so that it can be recovered as undo data."
(undo-fu-session--walk-tree
(lambda (a)
- (if (consp a)
- (cond
- ((eq (car a) 'marker)
- (set-marker (make-marker) (cdr a)))
- ((eq (car a) 'marker*)
- (let ((marker (make-marker)))
- (set-marker marker (cdr a))
- (set-marker-insertion-type marker t)
- marker))
- ((eq (car a) 'overlay)
- (let
- (
- (start (cadr a))
- (end (caddr a)))
- (if (and start end)
- (make-overlay (cadr a) (caddr a))
- ;; Make deleted overlay
- (let ((overlay (make-overlay (point-min) (point-min))))
- (delete-overlay overlay)
- overlay))))
- (t
- a))
- a))
+ (cond
+ ((consp a)
+ (cond
+ ((eq (car a) 'marker)
+ (set-marker (make-marker) (cdr a)))
+ ((eq (car a) 'marker*)
+ (let ((marker (make-marker)))
+ (set-marker marker (cdr a))
+ (set-marker-insertion-type marker t)
+ marker))
+ ((eq (car a) 'overlay)
+ (let
+ (
+ (start (cadr a))
+ (end (caddr a)))
+ (cond
+ ((and start end)
+ (make-overlay (cadr a) (caddr a)))
+ ;; Make deleted overlay
+ (t
+ (let ((overlay (make-overlay (point-min) (point-min))))
+ (delete-overlay overlay)
+ overlay)))))
+ (t
+ a)))
+ (t
+ a)))
tree))
(defun undo-fu-session--next-step (list)
@@ -276,9 +290,11 @@ Argument PENDING-LIST typically `pending-undo-list'."
(
(key-num (gethash key step-to-index-hash))
(val-num
- (if (eq t val)
- t
- (gethash val step-to-index-hash))))
+ (cond
+ ((eq t val)
+ t)
+ (t
+ (gethash val step-to-index-hash)))))
(when (and key-num val-num)
(push (cons key-num val-num) equiv-table-alist))))
equiv-table)
@@ -309,9 +325,11 @@ Argument PENDING-LIST an `pending-undo-list'. compatible
list."
(
(key (gethash key-num step-from-index-hash))
(val
- (if (eq t val-num)
- t
- (gethash val-num step-from-index-hash))))
+ (cond
+ ((eq t val-num)
+ t)
+ (t
+ (gethash val-num step-from-index-hash)))))
(puthash key val equiv-table-hash)))))
equiv-table-hash))
@@ -354,18 +372,22 @@ Argument PENDING-LIST an `pending-undo-list'. compatible
list."
(expand-file-name
(url-hexify-string (convert-standard-filename (expand-file-name
filename)))
undo-fu-session-directory)
- (if undo-fu-session-compression
- ".gz"
- ".el")))
+ (cond
+ (undo-fu-session-compression
+ ".gz")
+ (t
+ ".el"))))
(defun undo-fu-session--match-file-name (filename test-files)
"Return t if FILENAME match any item in TEST-FILES."
(catch 'found
(dolist (matcher test-files)
(when
- (if (stringp matcher)
- (string-match-p matcher filename)
- (funcall matcher filename))
+ (cond
+ ((stringp matcher)
+ (string-match-p matcher filename))
+ (t
+ (funcall matcher filename)))
(throw 'found t)))))
(defun undo-fu-session--recover-buffer-p (buffer)
- [nongnu] elpa/undo-fu-session 4330e87aac 50/53: Remove undo-fu-session hooks when no buffers have the mode enabled, (continued)
- [nongnu] elpa/undo-fu-session 4330e87aac 50/53: Remove undo-fu-session hooks when no buffers have the mode enabled, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu-session 3e54374b37 52/53: Cleanup: use double-dash for private functions, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu-session fa4833d470 02/53: readme: update to reference other packages, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu-session fa62a9b9a1 03/53: Cleanup: messages & docstrings, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu-session 049fe942f6 11/53: Cleanup: order buffer-undo-list before pending-undo-list, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu-session 5cc4b4f33d 12/53: Fix for linearizing an empty undo-list disabling undo on reload, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu-session 56cdd3538a 16/53: Don't show common-place messages in the echo area, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu-session 5135b5cb61 15/53: Update changelog, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu-session a038914736 18/53: Update readme, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu-session 191babe23c 24/53: Cleanup: docstring width warnings, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu-session 00bc3807d7 25/53: Cleanup: replace 'if' with 'cond',
ELPA Syncer <=
- [nongnu] elpa/undo-fu-session 7c095e863c 26/53: Cleanup: remove redundant groups, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu-session cbe37c6643 31/53: Alternate fix for #2, make the directory only readable by the user, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu-session 4605b0cc2b 33/53: Tests: simplify execution, with & without the linear option set, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu-session 3e810c7c9a 34/53: Tests: move into subdirectory, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu-session 1a3d500d8b 39/53: Support different compression formats & format conversion, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu-session b492c07573 43/53: Fix bzip2 and Z-standard compression types, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu-session d2a5ca1299 45/53: Use 600 for the mode instead of 700, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu-session e4cf026fd5 47/53: Use GPL 3 license in header, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu-session 703ea8d000 46/53: Fix incorrect mode for the undo-fu-session directory, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu-session 4b14cea4a9 44/53: Fix integer comparison and use assoc instead of assoc-default, ELPA Syncer, 2022/07/07