diff --git a/contrib/stgit.el b/contrib/stgit.el index d10214fa..6d91c13b 100644 --- a/contrib/stgit.el +++ b/contrib/stgit.el @@ -52,7 +52,7 @@ (error "Emacs older than 22 is not supported by stgit.el")) (require 'git nil t) -(require 'cl) +(require 'cl-lib) (require 'comint) (require 'dired) (require 'ewoc) @@ -159,8 +159,8 @@ flag, which reduces performance." "This variable controls where the \"Index\" and \"Work tree\" will be shown on in the buffer. -It can be set to 'top (above all patches), 'center (show between -applied and unapplied patches), and 'bottom (below all patches)." +It can be set to \='top (above all patches), \='center (show between +applied and unapplied patches), and \='bottom (below all patches)." :type '(radio (const :tag "above all patches (top)" top) (const :tag "between applied and unapplied patches (center)" center) @@ -236,65 +236,65 @@ format characters are recognized: (defface stgit-branch-name-face '((t :inherit bold)) - "The face used for the StGit branch name" + "The face used for the StGit branch name." :group 'stgit-faces) (defface stgit-top-patch-face '((((background dark)) (:weight bold :foreground "yellow")) (((background light)) (:weight bold :foreground "purple")) (t (:weight bold))) - "The face used for the top patch names" + "The face used for the top patch names." :group 'stgit-faces) (defface stgit-applied-patch-face '((((background dark)) (:foreground "light yellow")) (((background light)) (:foreground "purple")) (t ())) - "The face used for applied patch names" + "The face used for applied patch names." :group 'stgit-faces) (defface stgit-unapplied-patch-face '((((background dark)) (:foreground "gray80")) (((background light)) (:foreground "orchid")) (t ())) - "The face used for unapplied patch names" + "The face used for unapplied patch names." :group 'stgit-faces) (defface stgit-committed-patch-face '((((background dark)) (:foreground "gray50")) (((background light)) (:foreground "gray50")) (t ())) - "The face used for already committed patch names" + "The face used for already committed patch names." :group 'stgit-faces) (defface stgit-description-face '((((background dark)) (:foreground "tan")) (((background light)) (:foreground "dark red"))) - "The face used for StGit descriptions" + "The face used for StGit descriptions." :group 'stgit-faces) (defface stgit-index-work-tree-title-face '((((supports :slant italic)) :slant italic) (t :inherit bold)) - "StGit mode face used for the \"Index\" and \"Work tree\" titles" + "StGit mode face used for the \"Index\" and \"Work tree\" titles." :group 'stgit-faces) (defface stgit-unmerged-file-face '((((class color) (background light)) (:foreground "red" :bold t)) (((class color) (background dark)) (:foreground "red" :bold t))) - "StGit mode face used for unmerged file status" + "StGit mode face used for unmerged file status." :group 'stgit-faces) (defface stgit-unknown-file-face '((((class color) (background light)) (:foreground "goldenrod" :bold t)) (((class color) (background dark)) (:foreground "goldenrod" :bold t))) - "StGit mode face used for unknown file status" + "StGit mode face used for unknown file status." :group 'stgit-faces) (defface stgit-ignored-file-face '((((class color) (background light)) (:foreground "grey60")) (((class color) (background dark)) (:foreground "grey40"))) - "StGit mode face used for ignored files") + "StGit mode face used for ignored files.") (defface stgit-file-permission-face '((((class color) (background light)) (:foreground "green" :bold t)) @@ -305,7 +305,7 @@ format characters are recognized: (defface stgit-modified-file-face '((((class color) (background light)) (:foreground "purple")) (((class color) (background dark)) (:foreground "salmon"))) - "StGit mode face used for modified file status" + "StGit mode face used for modified file status." :group 'stgit-faces) (defun stgit (dir) @@ -318,7 +318,7 @@ See `stgit-mode' for commands available." (defun stgit-assert-mode () "Signal an error if not in an StGit buffer." - (assert (derived-mode-p 'stgit-mode) nil "Not an StGit buffer")) + (cl-assert (derived-mode-p 'stgit-mode) nil "Not an StGit buffer")) (unless (fboundp 'git-get-top-dir) (defun git-get-top-dir (dir) @@ -361,13 +361,13 @@ directory DIR or `default-directory'" (switch-to-buffer (or buffer (create-stgit-buffer dir))))) -(defstruct (stgit-patch +(cl-defstruct (stgit-patch (:conc-name stgit-patch->)) status name desc empty files-ewoc) (defun stgit-patch-display-name (patch) (let ((name (stgit-patch->name patch))) - (case name + (cl-case name (:index "Index") (:work "Work Tree") (t (symbol-name name))))) @@ -375,9 +375,7 @@ directory DIR or `default-directory'" (defun stgit-insert-without-trailing-whitespace (text) "Insert TEXT in buffer using `insert', without trailing whitespace. A newline is appended." - (unless (string-match "\\(.*?\\) *$" text) - (error)) - (insert (match-string 1 text) ?\n)) + (insert (string-trim-right text " ") ?\n)) (defun stgit-line-format () "Return the current line format; one of @@ -393,10 +391,10 @@ A newline is appended." (face (cdr (assq status stgit-patch-status-face-alist))) (fmt (stgit-line-format)) (spec (format-spec-make - ?s (case status - ('applied "+") - ('top ">") - ('unapplied "-") + ?s (cl-case status + (applied "+") + (top ">") + (unapplied "-") (t " ")) ?m (if (memq name stgit-marked-patches) "*" " ") @@ -484,7 +482,7 @@ necessary and no message will be shown if MESSAGE is nil. If `stgit-inhibit-messages' is non-nil, messages are suppressed. See also `stgit-message'. If MESSAGE is non-nil, BODY -will be executed with `stgit-inhibit-messages' set to `t'. +will be executed with `stgit-inhibit-messages' set to t. Returns the return value of BODY." (declare (indent 1) (debug (form body))) @@ -545,6 +543,8 @@ been advised to update the stgit status when necessary.") (ewoc-invalidate (car stgit-worktree-node) (cdr stgit-worktree-node)))) (defun stgit-run-series-insert-index (ewoc) + ;; TODO: non-lexical stuff happening here (`index-node' and `worktree-node'). + ;; Fix this before enabling lexical binding. (setq index-node (cons ewoc (ewoc-enter-last ewoc (make-stgit-patch :status 'index @@ -562,7 +562,7 @@ been advised to update the stgit status when necessary.") "Return `stgit-mode' position information at POSITION (point by default) that can be used to restore the point using `stgit-restore-position'." - (let ((opoint (point))) + (let ((point (point))) (and position (goto-char position)) (prog1 (list (stgit-patch-name-at-point) @@ -570,13 +570,13 @@ default) that can be used to restore the point using (and f (stgit-file->file f))) (line-number-at-pos) (current-column)) - (goto-char opoint)))) + (goto-char point)))) (defun stgit-restore-position (state) "Move point to the position in STATE, as returned by `stgit-get-position'." - (destructuring-bind (patch file line column) state - (unless (and patch (case (stgit-goto-patch patch file) + (cl-destructuring-bind (patch file line column) state + (unless (and patch (cl-case (stgit-goto-patch patch file) ((t) (move-to-column column) t) ((:patch) t))) (goto-char (point-min)) @@ -586,8 +586,8 @@ default) that can be used to restore the point using column))))) (defun stgit-get-window-state () - "Return the state of the buffer and its windows. Use -`stgit-restore-window-state' to restore the state." + "Return the state of the buffer and its windows. +Use `stgit-restore-window-state' to restore the state." (list (current-buffer) (mapcar (lambda (window) (cons window @@ -605,7 +605,7 @@ default) that can be used to restore the point using (defun stgit-restore-window-state (state) "Restore the state of the stgit buffer and windows in STATE, as obtained from `stgit-get-window-state'." - (destructuring-bind + (cl-destructuring-bind (buffer window-states buffer-state mark-state old-mark-active old-transient-mark-mode) state @@ -643,7 +643,7 @@ where they were." reported by git svn. Cached data is stored in HASH, which must have been created -using (make-hash-table :test 'equal)." +using (make-hash-table :test \='equal)." (let ((result (gethash sha1 hash t))) (when (eq result t) (let ((svn-rev (with-output-to-string @@ -753,7 +753,7 @@ using (make-hash-table :test 'equal)." (stgit-run-series-insert-index ewoc)) (setq stgit-index-node index-node stgit-worktree-node worktree-node - stgit-marked-patches (intersection stgit-marked-patches + stgit-marked-patches (cl-intersection stgit-marked-patches all-patchsyms))))) (defun stgit-current-branch () @@ -772,7 +772,7 @@ during the operation." (stgit-show-task-message description (let ((inhibit-read-only t)) (stgit-save-excursion - (ewoc-filter stgit-ewoc #'(lambda (x) nil)) + (ewoc-filter stgit-ewoc #'(lambda (_) nil)) (ewoc-set-hf stgit-ewoc (concat "Branch: " (propertize (stgit-current-branch) @@ -800,7 +800,7 @@ during the operation." (unmerged "Unmerged" stgit-unmerged-file-face) (unknown "Unknown" stgit-unknown-file-face) (ignore "Ignored" stgit-ignored-file-face))) - "Alist of code symbols to description strings") + "Alist of code symbols to description strings.") (defconst stgit-patch-status-face-alist '((applied . stgit-applied-patch-face) @@ -809,10 +809,10 @@ during the operation." (committed . stgit-committed-patch-face) (index . stgit-index-work-tree-title-face) (work . stgit-index-work-tree-title-face)) - "Alist of face to use for a given patch status") + "Alist of face to use for a given patch status.") (defun stgit-file-status-code-as-string (file) - "Return stgit status code for FILE as a string" + "Return stgit status code for FILE as a string." (let* ((code (assq (stgit-file->status file) stgit-file-status-code-strings)) (score (stgit-file->cr-score file))) @@ -824,7 +824,7 @@ during the operation." (cdr code))))) (defun stgit-file-status-code (str &optional score) - "Return stgit status code from git status string" + "Return stgit status code from git status string." (let ((code (assoc str '(("A" . add) ("C" . copy) ("D" . delete) @@ -845,7 +845,7 @@ during the operation." '((#o100 . "file") (#o120 . "symlink") (#o160 . "subproject")) - "Alist of names of file types") + "Alist of names of file types.") (defun stgit-file-type-string (type) "Return string describing file type TYPE (the high bits of file permission). @@ -894,7 +894,7 @@ Cf. `stgit-file-type-change-string'." (propertize (format "%o" new-perm) 'face 'stgit-file-permission-face))))))) -(defstruct (stgit-file +(cl-defstruct (stgit-file (:conc-name stgit-file->)) old-perm new-perm copy-or-rename cr-score cr-from cr-to status file) @@ -909,7 +909,7 @@ If NO-QUOTES is non-nil, do not enclose the result in double quotes." (if (stgit-escape-file-name-p name) (concat (if no-quotes "" "\"") (mapconcat (lambda (c) - (case c + (cl-case c (?\t "\\t") (?\n "\\n") (?\" "\\\"") @@ -1018,6 +1018,7 @@ If NO-QUOTES is non-nil, do not enclose the result in double quotes." (let ((file (cond ((looking-at "\\([CR]\\)\\([0-9]*\\)\0\\([^\0]*\\)\0\\([^\0]*\\)\0") + ;; TODO: Where does `patch' come from? (let* ((patch-status (stgit-patch->status patch)) (file-subexp (if (eq patch-status 'unapplied) 3 @@ -1104,7 +1105,7 @@ at point." "" (stgit-id patchsym)) ":" file))) - (error "git cat-file failed")))) + (error "Command 'git cat-file' failed")))) (funcall (if other-window 'switch-to-buffer-other-window 'switch-to-buffer) @@ -1137,11 +1138,11 @@ Non-interactively, operate on PATCHES, and collapse instead of expand if COLLAPSE is not nil." (interactive (list (stgit-patches-marked-or-at-point t))) (stgit-assert-mode) - (let ((patches-diff (funcall (if collapse #'intersection #'set-difference) + (let ((patches-diff (funcall (if collapse #'cl-intersection #'cl-set-difference) patches stgit-expanded-patches))) (setq stgit-expanded-patches (if collapse - (set-difference stgit-expanded-patches patches-diff) + (cl-set-difference stgit-expanded-patches patches-diff) (append stgit-expanded-patches patches-diff))) (stgit-show-task-message (concat (if collapse "Collapsing" "Expanding") " " @@ -1180,7 +1181,7 @@ See also `stgit-expand'." (set-marker end (point)) (set-marker-insertion-type end t)) - (assert (string-match "/$" filename)) + (cl-assert (string-match "/$" filename)) ;; remove trailing "/" (setf (stgit-file->file file) (substring filename 0 -1)) (ewoc-invalidate ewoc node) @@ -1210,14 +1211,14 @@ See also `stgit-expand'." (defun stgit-select () "With point on a patch, toggle showing files in the patch. -With point on a file, open the associated file. Opens the target +With point on a file, open the associated file. Opens the target file for (applied) copies and renames." (interactive) (stgit-assert-mode) - (case (get-text-property (point) 'entry-type) - ('patch + (cl-case (get-text-property (point) 'entry-type) + (patch (stgit-select-patch)) - ('file + (file (stgit-select-file)) (t (error "No patch or file on line")))) @@ -1257,24 +1258,24 @@ With prefix argument, open a buffer with that revision of the file." (git-status dir)))) (defun stgit-goal-column () - "Return goal column for the current line" - (case (get-text-property (point) 'entry-type) - ('patch 2) - ('file 4) + "Return goal column for the current line." + (cl-case (get-text-property (point) 'entry-type) + (patch 2) + (file 4) (t 0))) (defun stgit-next-line (&optional arg) - "Move cursor vertically down ARG lines" + "Move cursor vertically down ARG lines." (interactive "p") (stgit-assert-mode) - (next-line arg) + (forward-line arg) (move-to-column (stgit-goal-column))) (defun stgit-previous-line (&optional arg) - "Move cursor vertically up ARG lines" + "Move cursor vertically up ARG lines." (interactive "p") (stgit-assert-mode) - (previous-line arg) + (forward-line (- arg)) (move-to-column (stgit-goal-column))) (defun stgit-next-patch (&optional arg) @@ -1305,19 +1306,19 @@ With prefix argument, open a buffer with that revision of the file." ((stgit-at-header-p) (goto-char (point-min))) (t - (let ((opatch (stgit-patch-at-point))) + (let ((patch (stgit-patch-at-point))) (when (stgit-patched-file-at-point) (setq arg (1- arg))) (ewoc-goto-prev stgit-ewoc arg) (unless (zerop arg) - (when (eq opatch (stgit-patch-at-point)) + (when (eq patch (stgit-patch-at-point)) (goto-char (point-min))))) (move-to-column (stgit-goal-column))))) (defun stgit-previous-patch-group (&optional arg) "Move to the previous group of patches. -If ARG is non-nil, do this ARG times. If ARG is negative, move +If ARG is non-nil, do this ARG times. If ARG is negative, move -ARG groups forward instead; cf. `stgit-next-patch-group'." (interactive "p") (stgit-assert-mode) @@ -1326,22 +1327,22 @@ If ARG is non-nil, do this ARG times. If ARG is negative, move (while (and (not (bobp)) (> arg 0)) (stgit-previous-patch 1) - (let* ((opoint (point)) + (let* ((point (point)) (patch (stgit-patch-at-point)) (status (and patch (stgit-patch->status patch)))) (while (and (not (bobp)) (let* ((npatch (stgit-patch-at-point)) (nstatus (and npatch (stgit-patch->status npatch)))) (eq status nstatus))) - (setq opoint (point)) + (setq point (point)) (stgit-previous-patch 1)) - (goto-char opoint)) + (goto-char point)) (setq arg (1- arg))))) (defun stgit-next-patch-group (&optional arg) "Move to the next group of patches. -If ARG is non-nil, do this ARG times. If ARG is negative, move +If ARG is non-nil, do this ARG times. If ARG is negative, move -ARG groups backwards instead; cf. `stgit-previous-patch-group'." (interactive "p") (stgit-assert-mode) @@ -1732,7 +1733,7 @@ refresh the stgit buffers as the git status of files change." (defvar stgit-pending-refresh-buffers nil "Alist of (`buffer' . `mode') of buffers that need to be -refreshed. See `stgit-post-refresh' for the different values of +refreshed. See `stgit-post-refresh' for the different values of `mode'.") (defun stgit-run-pending-refreshs () @@ -1768,8 +1769,8 @@ MODE specifies what to do: (let ((elem (assq buffer stgit-pending-refresh-buffers))) (if elem ;; if buffer is already present, update its mode if necessary - (let ((omode (cdr elem))) - (when (case mode + (let ((mode (cdr elem))) + (when (cl-case mode (:index (eq mode :work)) (:reload t)) (setcdr elem mode))) @@ -1782,7 +1783,7 @@ MODE specifies what to do: "When Emacs becomes idle, update the status in any `stgit-mode' buffer that shows the status of the current buffer. -MODE specifies how to update the buffer. See `stgit-post-refresh' +MODE specifies how to update the buffer. See `stgit-post-refresh' for the different values MODE can have." (let* ((dir (cond ((derived-mode-p 'stgit-mode 'stgit-status-mode 'dired-mode) default-directory) @@ -1808,19 +1809,24 @@ for the different values MODE can have." (setq stgit-marked-patches '())) (defun stgit-patch-at-point (&optional cause-error) - (get-text-property (point) 'patch-data)) + "Return patch at point. +If CAUSE-ERROR then throw an error when there is no patch." + (let ((return (get-text-property (point) 'patch-data))) + (when (and cause-error (not return)) + (error "No patch at point")) + return)) (defun stgit-patch-name-at-point (&optional cause-error types) "Return the patch name on the current line as a symbol. If CAUSE-ERROR is not nil, signal an error if none found. TYPES controls which types of commits and patches can be returned. -If it is t, only allow stgit patches; if 'allow-committed, also +If it is t, only allow stgit patches; if \='allow-committed, also allow historical commits; if nil, also allow work tree and index." (let ((patch (stgit-patch-at-point))) (and patch (memq (stgit-patch->status patch) - (case types + (cl-case types ((nil) nil) ((allow-committed) '(work index)) ((t) '(work index committed)) @@ -1839,7 +1845,7 @@ allow historical commits; if nil, also allow work tree and index." If CAUSE-ERRROR is not nil, signal an error if none found. TYPES controls which types of commits and patches can be returned. -If it is t, only allow stgit patches; if 'allow-committed, also +If it is t, only allow stgit patches; if \='allow-committed, also allow historical commits; if nil, also allow work tree and index." (if stgit-marked-patches stgit-marked-patches @@ -1887,7 +1893,7 @@ line of PATCHSYM and return :patch." (stgit-assert-mode) (unless (zerop (stgit-capture-output nil (stgit-run "init"))) - (error "stg init failed")) + (error "Command 'stg init' failed")) (stgit-reload)) (defun stgit-toggle-mark () @@ -1904,7 +1910,7 @@ line of PATCHSYM and return :patch." (stgit-assert-mode) (let* ((node (ewoc-locate stgit-ewoc)) (patch (ewoc-data node))) - (case (stgit-patch->status patch) + (cl-case (stgit-patch->status patch) (work (error "Cannot mark the work tree")) (index (error "Cannot mark the index")) (committed (error "Cannot mark a committed patch"))) @@ -2042,7 +2048,7 @@ If SKIP-CURRENT is not nil, do not include the current branch." ;; Do not expand any (normal) patches in the new branch (setq stgit-expanded-patches - (remove-if-not (lambda (p) (memq p '(:work :index))) + (cl-remove-if-not (lambda (p) (memq p '(:work :index))) stgit-expanded-patches)) (stgit-reload)))) @@ -2060,7 +2066,7 @@ If OMIT-STGIT is not nil, filter out \"resf/heads/*.stgit\"." (substring s (match-end 0)) s)) (if omit-stgit - (delete-if (lambda (s) + (cl-delete-if (lambda (s) (string-match "^refs/heads/.*\\.stgit$" s)) result) result)))) @@ -2078,8 +2084,8 @@ git-config setting branch..stgit.parentbranch." (defun stgit-rebase (new-base) "Rebase the current branch to NEW-BASE. -Interactively, first ask which branch to rebase to. Defaults to -what git-config branch..stgit.parentbranch is set to." +Interactively, first ask which branch to rebase to. Defaults to what +git-config branch..stgit.parentbranch is set to." (interactive (list (completing-read "Rebase to: " (stgit-available-refs t) nil nil @@ -2131,9 +2137,9 @@ previous file if point is at the last file within a patch." "Returns list of the merge stages that contain FILE, which must be an unmerged file. -Stage 1, the common ancestor, is 'ancestor. -Stage 2, HEAD, is 'head. -Stage 3, MERGE_HEAD, is 'merge-head." +Stage 1, the common ancestor, is \='ancestor. +Stage 2, HEAD, is \='head. +Stage 3, MERGE_HEAD, is \='merge-head." (let ((output (with-output-to-string (stgit-run-git-silent "ls-files" "-u" "-z" "--" (stgit-file->file file)))) @@ -2212,7 +2218,7 @@ tree, or a single change in either." (stgit-revert-file) (let* ((patch-name (or (stgit-patch-name-at-point) (error "No patch or file at point"))) - (patch-desc (case patch-name + (patch-desc (cl-case patch-name (:index "index") (:work "work tree") (t (error (substitute-command-keys @@ -2309,7 +2315,7 @@ If ONLY-PATCHES is not nil, exclude index and work tree." (stgit-assert-mode) (let* ((patchsyms (stgit-patches-marked-or-at-point t t)) (applied-syms (stgit-applied-patchsyms t)) - (unapplied (set-difference patchsyms applied-syms))) + (unapplied (cl-set-difference patchsyms applied-syms))) (stgit-capture-output nil (apply 'stgit-run (if unapplied "push" "pop") @@ -2330,7 +2336,7 @@ If ONLY-PATCHES is not nil, exclude index and work tree." or :bottom." (let ((patch (stgit-patch-at-point))) (cond (patch - (case (stgit-patch->status patch) + (cl-case (stgit-patch->status patch) ((work index) nil) ((committed) :bottom) (t (stgit-patch->name patch)))) @@ -2342,14 +2348,14 @@ or :bottom." (defun stgit-goto () "Go to the patch on the current line. -Push or pop patches to make this patch topmost. Push or pop all +Push or pop patches to make this patch topmost. Push or pop all patches if used on a line after or before all patches." (interactive) (stgit-assert-mode) (let ((patchsym (stgit-goto-target))) (unless patchsym (error "No patch to go to on this line")) - (case patchsym + (cl-case patchsym (:top (stgit-push-or-pop-patches t t)) (:bottom (stgit-push-or-pop-patches nil t)) (t (stgit-capture-output nil @@ -2380,14 +2386,14 @@ which stage to diff against in the case of unmerged files." (let* ((space-arg (stgit-whitespace-diff-arg ignore-whitespace)) (patch-name (stgit-patch-name-at-point t)) (entry-type (get-text-property (point) 'entry-type)) - (diff-desc (case entry-type - ('file "diff") - ('patch "patch") + (diff-desc (cl-case entry-type + (file "diff") + (patch "patch") (t (error "No patch or file at point"))))) (stgit-show-task-message (concat "Showing " diff-desc) (stgit-capture-output (concat "*StGit " diff-desc "*") - (case entry-type - ('file + (cl-case entry-type + (file (let* ((patched-file (stgit-patched-file-at-point)) (patch-id (let ((id (stgit-id patch-name))) (if (and (eq id :index) @@ -2412,7 +2418,7 @@ which stage to diff against in the case of unmerged files." (stgit-file->cr-to patched-file)) (list (stgit-file->file patched-file)))))) (apply 'stgit-run-git "diff" args))) - ('patch + (patch (let* ((patch-id (stgit-id patch-name))) (if (or (eq patch-id :index) (eq patch-id :work)) (apply 'stgit-run-git "diff" @@ -2463,9 +2469,9 @@ greater than four (e.g., \\[universal-argument] \ (defun stgit-diff-range (&optional ignore-whitespace) "Show diff for the range of patches between point and the marked patch. -With a prefix argument, ignore whitespace. With a prefix argument -greater than four (e.g., \\[universal-argument] \ -\\[universal-argument] \\[stgit-diff-range]), ignore all whitespace." +With a prefix argument, ignore whitespace. With a prefix argument +greater than four (e.g., \\[universal-argument] \ \\[universal-argument] +\\[stgit-diff-range]), ignore all whitespace." (interactive "p") (stgit-assert-mode) (unless (= (length stgit-marked-patches) 1) @@ -2503,7 +2509,7 @@ If FORCE is not nil, use --force." '("--") (list file)))))) (defun stgit-remove-change-from-index (file) - "Unstages the change in FILE from the index" + "Unstages the change in FILE from the index." (stgit-capture-output "*git output*" (stgit-run-git "reset" "-q" "--" file))) @@ -2525,7 +2531,7 @@ If FORCE is not nil, use --force." "Move modified file in or out of the index. Leaves the point where it is, but moves the mark to where the -file ended up. You can then jump to the file with \ +file ended up. You can then jump to the file with \ \\[exchange-point-and-mark]." (interactive) (stgit-assert-mode) @@ -2564,7 +2570,7 @@ file ended up. You can then jump to the file with \ Works on index and work tree, as well as files in either. Leaves the point where it is, but moves the mark to where the -file ended up. You can then jump to the file with \ +file ended up. You can then jump to the file with \ \\[exchange-point-and-mark]." (interactive) (stgit-assert-mode) @@ -2606,16 +2612,21 @@ file ended up. You can then jump to the file with \ (defun stgit-confirm-edit () (interactive) - (let ((file (make-temp-file "stgit-edit-"))) - (write-region (point-min) (point-max) file) + (let ((file (make-temp-file "stgit-edit-")) + (start (point-min)) + (summary-string "Summary: ")) + ;; log-edit puts this summary string here that we do not want + (if (string-equal (buffer-substring start (+ 1 (length summary-string))) + summary-string) + (setq start (+ start (length summary-string)))) + (write-region start (point-max) file) (stgit-capture-output nil (stgit-run "edit" "-f" file "--" stgit-edit-patchsym)) (with-current-buffer log-edit-parent-buffer (stgit-reload)))) (defun stgit-new-here (add-sign) - "Create a new patch before the patch at point, asking for a -commit message. + "Create a new patch before the patch at point, asking for a commit message. With a prefix argument, include a \"Signed-off-by:\" line at the end of the patch description. @@ -2624,7 +2635,7 @@ This works like `stgit-new' followed by `stgit-move'." (interactive "P") (stgit-assert-mode) (let ((patch (stgit-patch-at-point t))) - (case (stgit-patch->status patch) + (cl-case (stgit-patch->status patch) ((index work) (stgit-new add-sign)) ((applied top) (unless (and (stgit-index-empty-p) @@ -2691,7 +2702,7 @@ This works just like running `stgit-new' followed by `stgit-refresh'." (stgit-new add-sign t)) (defun stgit-create-patch-name (description) - "Create a patch name from a long description" + "Create a patch name from a long description." (let ((patch "")) (while (> (length description) 0) (cond ((string-match "\\`[a-zA-Z_-]+" description) @@ -2840,7 +2851,7 @@ deepest patch had before the squash." (rename-buffer "*StGit error*") (resize-temp-buffer-window) (switch-to-buffer-other-window stgit-buffer) - (error "stg squash failed"))))) + (error "Command 'stg squash' failed"))))) (defun stgit-confirm-squash () (interactive) @@ -2904,7 +2915,7 @@ When the command has finished, reload the stgit buffer." (let* ((patches (stgit-sort-patches (stgit-patches-marked-or-at-point nil 'allow-committed))) (patch-names (mapcar 'symbol-name patches)) - (hyphens (find-if (lambda (s) (string-match "^-" s)) patch-names)) + (hyphens (cl-find-if (lambda (s) (string-match "^-" s)) patch-names)) (program (if git-mode stgit-git-program stgit-stg-program)) (defaultcmd (concat program " " @@ -2946,10 +2957,10 @@ If HARD is non-nil, use the --hard flag." (stgit-assert-mode) (let ((cmd (if redo "redo" "undo"))) (stgit-capture-output nil - (if arg + (if hard (when (or (and (stgit-index-empty-p) (stgit-work-tree-empty-p)) - (y-or-n-p (format "Hard %s may overwrite index/work tree changes. Continue? " + (y-or-n-p (format "Hard %s may overwrite index/work tree changes. Continue? " cmd))) (stgit-run cmd "--hard")) (stgit-run cmd))))