Skip to content

Commit b343739

Browse files
MorganJamesSmithjpgrayson
authored andcommitted
stgit.el: Replace depercated cl function calls with new style
1 parent 02aeaec commit b343739

File tree

1 file changed

+40
-40
lines changed

1 file changed

+40
-40
lines changed

contrib/stgit.el

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
(error "Emacs older than 22 is not supported by stgit.el"))
5353

5454
(require 'git nil t)
55-
(require 'cl)
55+
(require 'cl-lib)
5656
(require 'comint)
5757
(require 'dired)
5858
(require 'ewoc)
@@ -318,7 +318,7 @@ See `stgit-mode' for commands available."
318318

319319
(defun stgit-assert-mode ()
320320
"Signal an error if not in an StGit buffer."
321-
(assert (derived-mode-p 'stgit-mode) nil "Not an StGit buffer"))
321+
(cl-assert (derived-mode-p 'stgit-mode) nil "Not an StGit buffer"))
322322

323323
(unless (fboundp 'git-get-top-dir)
324324
(defun git-get-top-dir (dir)
@@ -361,13 +361,13 @@ directory DIR or `default-directory'"
361361
(switch-to-buffer (or buffer
362362
(create-stgit-buffer dir)))))
363363

364-
(defstruct (stgit-patch
364+
(cl-defstruct (stgit-patch
365365
(:conc-name stgit-patch->))
366366
status name desc empty files-ewoc)
367367

368368
(defun stgit-patch-display-name (patch)
369369
(let ((name (stgit-patch->name patch)))
370-
(case name
370+
(cl-case name
371371
(:index "Index")
372372
(:work "Work Tree")
373373
(t (symbol-name name)))))
@@ -393,10 +393,10 @@ A newline is appended."
393393
(face (cdr (assq status stgit-patch-status-face-alist)))
394394
(fmt (stgit-line-format))
395395
(spec (format-spec-make
396-
?s (case status
397-
('applied "+")
398-
('top ">")
399-
('unapplied "-")
396+
?s (cl-case status
397+
(applied "+")
398+
(top ">")
399+
(unapplied "-")
400400
(t " "))
401401
?m (if (memq name stgit-marked-patches)
402402
"*" " ")
@@ -575,8 +575,8 @@ default) that can be used to restore the point using
575575
(defun stgit-restore-position (state)
576576
"Move point to the position in STATE, as returned by
577577
`stgit-get-position'."
578-
(destructuring-bind (patch file line column) state
579-
(unless (and patch (case (stgit-goto-patch patch file)
578+
(cl-destructuring-bind (patch file line column) state
579+
(unless (and patch (cl-case (stgit-goto-patch patch file)
580580
((t) (move-to-column column) t)
581581
((:patch) t)))
582582
(goto-char (point-min))
@@ -605,7 +605,7 @@ Use `stgit-restore-window-state' to restore the state."
605605
(defun stgit-restore-window-state (state)
606606
"Restore the state of the stgit buffer and windows in STATE, as
607607
obtained from `stgit-get-window-state'."
608-
(destructuring-bind
608+
(cl-destructuring-bind
609609
(buffer window-states buffer-state mark-state
610610
old-mark-active old-transient-mark-mode)
611611
state
@@ -753,7 +753,7 @@ using (make-hash-table :test 'equal)."
753753
(stgit-run-series-insert-index ewoc))
754754
(setq stgit-index-node index-node
755755
stgit-worktree-node worktree-node
756-
stgit-marked-patches (intersection stgit-marked-patches
756+
stgit-marked-patches (cl-intersection stgit-marked-patches
757757
all-patchsyms)))))
758758

759759
(defun stgit-current-branch ()
@@ -894,7 +894,7 @@ Cf. `stgit-file-type-change-string'."
894894
(propertize (format "%o" new-perm)
895895
'face 'stgit-file-permission-face)))))))
896896

897-
(defstruct (stgit-file
897+
(cl-defstruct (stgit-file
898898
(:conc-name stgit-file->))
899899
old-perm new-perm copy-or-rename cr-score cr-from cr-to status file)
900900

@@ -909,7 +909,7 @@ If NO-QUOTES is non-nil, do not enclose the result in double quotes."
909909
(if (stgit-escape-file-name-p name)
910910
(concat (if no-quotes "" "\"")
911911
(mapconcat (lambda (c)
912-
(case c
912+
(cl-case c
913913
(?\t "\\t")
914914
(?\n "\\n")
915915
(?\" "\\\"")
@@ -1137,11 +1137,11 @@ Non-interactively, operate on PATCHES, and collapse instead of
11371137
expand if COLLAPSE is not nil."
11381138
(interactive (list (stgit-patches-marked-or-at-point t)))
11391139
(stgit-assert-mode)
1140-
(let ((patches-diff (funcall (if collapse #'intersection #'set-difference)
1140+
(let ((patches-diff (funcall (if collapse #'cl-intersection #'cl-set-difference)
11411141
patches stgit-expanded-patches)))
11421142
(setq stgit-expanded-patches
11431143
(if collapse
1144-
(set-difference stgit-expanded-patches patches-diff)
1144+
(cl-set-difference stgit-expanded-patches patches-diff)
11451145
(append stgit-expanded-patches patches-diff)))
11461146
(stgit-show-task-message (concat (if collapse "Collapsing" "Expanding")
11471147
" "
@@ -1180,7 +1180,7 @@ See also `stgit-expand'."
11801180
(set-marker end (point))
11811181
(set-marker-insertion-type end t))
11821182

1183-
(assert (string-match "/$" filename))
1183+
(cl-assert (string-match "/$" filename))
11841184
;; remove trailing "/"
11851185
(setf (stgit-file->file file) (substring filename 0 -1))
11861186
(ewoc-invalidate ewoc node)
@@ -1214,10 +1214,10 @@ With point on a file, open the associated file. Opens the target
12141214
file for (applied) copies and renames."
12151215
(interactive)
12161216
(stgit-assert-mode)
1217-
(case (get-text-property (point) 'entry-type)
1218-
('patch
1217+
(cl-case (get-text-property (point) 'entry-type)
1218+
(patch
12191219
(stgit-select-patch))
1220-
('file
1220+
(file
12211221
(stgit-select-file))
12221222
(t
12231223
(error "No patch or file on line"))))
@@ -1258,9 +1258,9 @@ With prefix argument, open a buffer with that revision of the file."
12581258

12591259
(defun stgit-goal-column ()
12601260
"Return goal column for the current line."
1261-
(case (get-text-property (point) 'entry-type)
1262-
('patch 2)
1263-
('file 4)
1261+
(cl-case (get-text-property (point) 'entry-type)
1262+
(patch 2)
1263+
(file 4)
12641264
(t 0)))
12651265

12661266
(defun stgit-next-line (&optional arg)
@@ -1769,7 +1769,7 @@ MODE specifies what to do:
17691769
(if elem
17701770
;; if buffer is already present, update its mode if necessary
17711771
(let ((omode (cdr elem)))
1772-
(when (case mode
1772+
(when (cl-case mode
17731773
(:index (eq mode :work))
17741774
(:reload t))
17751775
(setcdr elem mode)))
@@ -1820,7 +1820,7 @@ allow historical commits; if nil, also allow work tree and index."
18201820
(let ((patch (stgit-patch-at-point)))
18211821
(and patch
18221822
(memq (stgit-patch->status patch)
1823-
(case types
1823+
(cl-case types
18241824
((nil) nil)
18251825
((allow-committed) '(work index))
18261826
((t) '(work index committed))
@@ -1904,7 +1904,7 @@ line of PATCHSYM and return :patch."
19041904
(stgit-assert-mode)
19051905
(let* ((node (ewoc-locate stgit-ewoc))
19061906
(patch (ewoc-data node)))
1907-
(case (stgit-patch->status patch)
1907+
(cl-case (stgit-patch->status patch)
19081908
(work (error "Cannot mark the work tree"))
19091909
(index (error "Cannot mark the index"))
19101910
(committed (error "Cannot mark a committed patch")))
@@ -2042,7 +2042,7 @@ If SKIP-CURRENT is not nil, do not include the current branch."
20422042

20432043
;; Do not expand any (normal) patches in the new branch
20442044
(setq stgit-expanded-patches
2045-
(remove-if-not (lambda (p) (memq p '(:work :index)))
2045+
(cl-remove-if-not (lambda (p) (memq p '(:work :index)))
20462046
stgit-expanded-patches))
20472047

20482048
(stgit-reload))))
@@ -2060,7 +2060,7 @@ If OMIT-STGIT is not nil, filter out \"resf/heads/*.stgit\"."
20602060
(substring s (match-end 0))
20612061
s))
20622062
(if omit-stgit
2063-
(delete-if (lambda (s)
2063+
(cl-delete-if (lambda (s)
20642064
(string-match "^refs/heads/.*\\.stgit$" s))
20652065
result)
20662066
result))))
@@ -2212,7 +2212,7 @@ tree, or a single change in either."
22122212
(stgit-revert-file)
22132213
(let* ((patch-name (or (stgit-patch-name-at-point)
22142214
(error "No patch or file at point")))
2215-
(patch-desc (case patch-name
2215+
(patch-desc (cl-case patch-name
22162216
(:index "index")
22172217
(:work "work tree")
22182218
(t (error (substitute-command-keys
@@ -2309,7 +2309,7 @@ If ONLY-PATCHES is not nil, exclude index and work tree."
23092309
(stgit-assert-mode)
23102310
(let* ((patchsyms (stgit-patches-marked-or-at-point t t))
23112311
(applied-syms (stgit-applied-patchsyms t))
2312-
(unapplied (set-difference patchsyms applied-syms)))
2312+
(unapplied (cl-set-difference patchsyms applied-syms)))
23132313
(stgit-capture-output nil
23142314
(apply 'stgit-run
23152315
(if unapplied "push" "pop")
@@ -2330,7 +2330,7 @@ If ONLY-PATCHES is not nil, exclude index and work tree."
23302330
or :bottom."
23312331
(let ((patch (stgit-patch-at-point)))
23322332
(cond (patch
2333-
(case (stgit-patch->status patch)
2333+
(cl-case (stgit-patch->status patch)
23342334
((work index) nil)
23352335
((committed) :bottom)
23362336
(t (stgit-patch->name patch))))
@@ -2349,7 +2349,7 @@ patches if used on a line after or before all patches."
23492349
(let ((patchsym (stgit-goto-target)))
23502350
(unless patchsym
23512351
(error "No patch to go to on this line"))
2352-
(case patchsym
2352+
(cl-case patchsym
23532353
(:top (stgit-push-or-pop-patches t t))
23542354
(:bottom (stgit-push-or-pop-patches nil t))
23552355
(t (stgit-capture-output nil
@@ -2380,14 +2380,14 @@ which stage to diff against in the case of unmerged files."
23802380
(let* ((space-arg (stgit-whitespace-diff-arg ignore-whitespace))
23812381
(patch-name (stgit-patch-name-at-point t))
23822382
(entry-type (get-text-property (point) 'entry-type))
2383-
(diff-desc (case entry-type
2384-
('file "diff")
2385-
('patch "patch")
2383+
(diff-desc (cl-case entry-type
2384+
(file "diff")
2385+
(patch "patch")
23862386
(t (error "No patch or file at point")))))
23872387
(stgit-show-task-message (concat "Showing " diff-desc)
23882388
(stgit-capture-output (concat "*StGit " diff-desc "*")
2389-
(case entry-type
2390-
('file
2389+
(cl-case entry-type
2390+
(file
23912391
(let* ((patched-file (stgit-patched-file-at-point))
23922392
(patch-id (let ((id (stgit-id patch-name)))
23932393
(if (and (eq id :index)
@@ -2412,7 +2412,7 @@ which stage to diff against in the case of unmerged files."
24122412
(stgit-file->cr-to patched-file))
24132413
(list (stgit-file->file patched-file))))))
24142414
(apply 'stgit-run-git "diff" args)))
2415-
('patch
2415+
(patch
24162416
(let* ((patch-id (stgit-id patch-name)))
24172417
(if (or (eq patch-id :index) (eq patch-id :work))
24182418
(apply 'stgit-run-git "diff"
@@ -2629,7 +2629,7 @@ This works like `stgit-new' followed by `stgit-move'."
26292629
(interactive "P")
26302630
(stgit-assert-mode)
26312631
(let ((patch (stgit-patch-at-point t)))
2632-
(case (stgit-patch->status patch)
2632+
(cl-case (stgit-patch->status patch)
26332633
((index work) (stgit-new add-sign))
26342634
((applied top)
26352635
(unless (and (stgit-index-empty-p)
@@ -2909,7 +2909,7 @@ When the command has finished, reload the stgit buffer."
29092909
(let* ((patches (stgit-sort-patches
29102910
(stgit-patches-marked-or-at-point nil 'allow-committed)))
29112911
(patch-names (mapcar 'symbol-name patches))
2912-
(hyphens (find-if (lambda (s) (string-match "^-" s)) patch-names))
2912+
(hyphens (cl-find-if (lambda (s) (string-match "^-" s)) patch-names))
29132913
(program (if git-mode stgit-git-program stgit-stg-program))
29142914
(defaultcmd (concat program
29152915
" "

0 commit comments

Comments
 (0)