unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] Allow hiding stashes from vc-dir
@ 2019-10-15 12:48 Robert Pluim
  2019-10-15 12:54 ` Lars Ingebrigtsen
                   ` (2 more replies)
  0 siblings, 3 replies; 28+ messages in thread
From: Robert Pluim @ 2019-10-15 12:48 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 237 bytes --]

For various reasons I tend to have a lot of stashes hanging around,
which magit can autohide for you. vc-dir doesnʼt have such an option,
and has no commands for doing things with stashes anyway, so I came up
with the following. 


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-vc-git-allow-not-showing-git-stash-list-in-vc-dir.patch --]
[-- Type: text/x-patch, Size: 4416 bytes --]

From b02f05fc569f3946366ac2ede27349cd09618265 Mon Sep 17 00:00:00 2001
From: Robert Pluim <rpluim@gmail.com>
Date: Tue, 5 Feb 2019 10:51:42 +0100
Subject: [PATCH] vc-git: allow not showing git stash list in vc-dir
To: emacs-devel@gnu.org

* lisp/vc/vc-git.el (vc-git-show-stash): New variable.
(vc-git-dir-extra-headers): Only show stash list when
vc-git-show-stash is t.
---
 etc/NEWS          |  3 +++
 lisp/vc/vc-git.el | 49 ++++++++++++++++++++++++++---------------------
 2 files changed, 30 insertions(+), 22 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 271cc6e044..8c3993474c 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -733,6 +733,9 @@ The default value is 'find-dired-sort-by-filename'.
 *** New command 'log-edit-generate-changelog-from-diff', bound to C-c C-w.
 This generates ChangeLog entries from the VC fileset diff.
 
+*** New customizable variable 'vc-git-show-stash'.
+Default t, set it to nil to hide stashes in 'vc-dir' when using git.
+
 *** Recording ChangeLog entries doesn't require an actual file.
 If a ChangeLog file doesn't exist, and if the new variable
 'add-log-dont-create-changelog-file' is non-nil (which is the
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 9715aea1fd..615474cd76 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -192,6 +192,11 @@ vc-git-grep-template
   :type 'string
   :version "27.1")
 
+(defcustom vc-git-show-stash t
+  "Whether to show the git stash list."
+  :type 'boolean
+  :version "27.1")
+
 ;; History of Git commands.
 (defvar vc-git-history nil)
 
@@ -655,7 +660,7 @@ vc-git-dir-extra-headers
   (let ((str (with-output-to-string
                (with-current-buffer standard-output
                  (vc-git--out-ok "symbolic-ref" "HEAD"))))
-	(stash (vc-git-stash-list))
+	(stash (when vc-git-show-stash (vc-git-stash-list)))
 	(stash-help-echo "Use M-x vc-git-stash to create stashes.")
 	branch remote remote-url)
     (if (string-match "^\\(refs/heads/\\)?\\(.+\\)$" str)
@@ -688,30 +693,30 @@ vc-git-dir-extra-headers
 	(propertize "Remote     : " 'face 'font-lock-type-face)
 	(propertize remote-url
 		    'face 'font-lock-variable-name-face)))
-     "\n"
      ;; For now just a heading, key bindings can be added later for various bisect actions
      (when (file-exists-p (expand-file-name ".git/BISECT_START" (vc-git-root dir)))
-       (propertize  "Bisect     : in progress\n" 'face 'font-lock-warning-face))
+       (propertize  "\nBisect     : in progress" 'face 'font-lock-warning-face))
      (when (file-exists-p (expand-file-name ".git/rebase-apply" (vc-git-root dir)))
-       (propertize  "Rebase     : in progress\n" 'face 'font-lock-warning-face))
-     (if stash
-       (concat
-	(propertize "Stash      :\n" 'face 'font-lock-type-face
-		    'help-echo stash-help-echo)
-	(mapconcat
-	 (lambda (x)
-	   (propertize x
-		       'face 'font-lock-variable-name-face
-		       'mouse-face 'highlight
-		       'help-echo "mouse-3: Show stash menu\nRET: Show stash\nA: Apply stash\nP: Apply and remove stash (pop)\nC-k: Delete stash"
-		       'keymap vc-git-stash-map))
-	 stash "\n"))
-       (concat
-	(propertize "Stash      : " 'face 'font-lock-type-face
-		    'help-echo stash-help-echo)
-	(propertize "Nothing stashed"
-		    'help-echo stash-help-echo
-		    'face 'font-lock-variable-name-face))))))
+       (propertize  "\nRebase     : in progress" 'face 'font-lock-warning-face))
+     (when vc-git-show-stash
+       (if stash
+           (concat
+            (propertize "\nStash      :\n" 'face 'font-lock-type-face
+                        'help-echo stash-help-echo)
+            (mapconcat
+             (lambda (x)
+               (propertize x
+                           'face 'font-lock-variable-name-face
+                           'mouse-face 'highlight
+                           'help-echo "mouse-3: Show stash menu\nRET: Show stash\nA: Apply stash\nP: Apply and remove stash (pop)\nC-k: Delete stash"
+                           'keymap vc-git-stash-map))
+             stash "\n"))
+         (concat
+          (propertize "\nStash      : " 'face 'font-lock-type-face
+                      'help-echo stash-help-echo)
+          (propertize "Nothing stashed"
+                      'help-echo stash-help-echo
+                      'face 'font-lock-variable-name-face)))))))
 
 (defun vc-git-branches ()
   "Return the existing branches, as a list of strings.
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2019-10-21  9:38 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-15 12:48 [PATCH] Allow hiding stashes from vc-dir Robert Pluim
2019-10-15 12:54 ` Lars Ingebrigtsen
2019-10-15 13:06 ` Eli Zaretskii
2019-10-15 14:02   ` Robert Pluim
2019-10-15 16:19     ` Eli Zaretskii
2019-10-15 18:09   ` Juri Linkov
2019-10-16  1:28     ` Lars Ingebrigtsen
2019-10-16  8:57       ` Robert Pluim
2019-10-17 16:26         ` Robert Pluim
2019-10-18  3:14           ` Lars Ingebrigtsen
2019-10-18  8:39             ` Robert Pluim
2019-10-18  9:01               ` Eli Zaretskii
2019-10-18  9:25                 ` Robert Pluim
2019-10-18  9:31                   ` Eli Zaretskii
2019-10-18 10:18                     ` Robert Pluim
2019-10-18 12:22                       ` Eli Zaretskii
2019-10-18 13:43                         ` Robert Pluim
2019-10-19  3:19                           ` Stefan Monnier
2019-10-21  9:38                             ` Robert Pluim
2019-10-19  8:18                           ` Andreas Schwab
2019-10-18 13:22           ` Stefan Monnier
2019-10-18 14:07             ` Robert Pluim
2019-10-19  3:16               ` Stefan Monnier
2019-10-19  8:15               ` Lars Ingebrigtsen
2019-10-21  9:38                 ` Robert Pluim
2019-10-15 14:40 ` Michael Albinus
2019-10-15 16:25   ` Eli Zaretskii
2019-10-16 10:18     ` Michael Albinus

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).