emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/gited 9989d95 05/73: Fix sort of columns when gited-hid


From: Stefan Monnier
Subject: [elpa] externals/gited 9989d95 05/73: Fix sort of columns when gited-hide-details-mode is enabled
Date: Sun, 29 Nov 2020 00:00:27 -0500 (EST)

branch: externals/gited
commit 9989d95167e8f96a53f7b90c644e3b946baba46c
Author: Tino Calancha <tino.calancha@gmail.com>
Commit: Tino Calancha <tino.calancha@gmail.com>

    Fix sort of columns when gited-hide-details-mode is enabled
    
    When gited-hide-details-mode is enabled, and we want to sort
    by another column, disable gited-hide-details-mode
    and enable it after all columns have being printed out.
    * gited.el (gited--advice-sort-by-column): New defun.  Use it
    to advice `tabulated-list-col-sort'.
    (gited-list-branches): Use gited-branch-exists-p.
    * .travis.yml: Gited requires Emacs version >= 24.4.
---
 .travis.yml |  2 +-
 gited.el    | 36 ++++++++++++++++++++++++++----------
 2 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 098eca7..8f189c2 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,7 +6,7 @@ notifications:
     on_failure: always
 
 env:
-  - EVM_EMACS=emacs-24.3-travis
+# - EVM_EMACS=emacs-24.3-travis # advice-add requires >= 24.4
   - EVM_EMACS=emacs-24.4-travis
   - EVM_EMACS=emacs-24.5-travis
   - EVM_EMACS=emacs-git-snapshot-travis
diff --git a/gited.el b/gited.el
index 9bb18a2..6244872 100644
--- a/gited.el
+++ b/gited.el
@@ -10,9 +10,9 @@
 ;; Compatibility: GNU Emacs: 24.4
 ;; Version: 0.2.0
 ;; Package-Requires: ((emacs "24.4") (cl-lib "0.5"))
-;; Last-Updated: Sun Jun 04 12:00:04 JST 2017
+;; Last-Updated: Sun Jun 04 12:46:33 JST 2017
 ;;           By: calancha
-;;     Update #: 637
+;;     Update #: 638
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;
@@ -141,14 +141,15 @@
 ;;
 ;;  Non-interactive functions defined here:
 ;;
-;;   `gited--bisect-after-run', `gited--bisect-executable-p',
-;;   `gited--case-ref-kind', `gited--check-unmerged-marked-branches',
-;;   `gited--clean-previous-patches', `gited--fill-branch-alist',
-;;   `gited--fontify-current-row', `gited--get-branches-from-command',
-;;   `gited--get-column', `gited--get-merged-branches',
-;;   `gited--get-patch-or-commit-buffers', `gited--get-unmerged-branches',
-;;   `gited--goto-column', `gited--goto-first-branch',
-;;   `gited--handle-new-or-delete-files', `gited--list-format-init',
+;;   `gited--advice-sort-by-column', `gited--bisect-after-run',
+;;   `gited--bisect-executable-p', `gited--case-ref-kind',
+;;   `gited--check-unmerged-marked-branches', `gited--clean-previous-patches',
+;;   `gited--fill-branch-alist', `gited--fontify-current-row',
+;;   `gited--get-branches-from-command', `gited--get-column',
+;;   `gited--get-merged-branches', `gited--get-patch-or-commit-buffers',
+;;   `gited--get-unmerged-branches', `gited--goto-column',
+;;   `gited--goto-first-branch', `gited--handle-new-or-delete-files',
+;;   `gited--list-files', `gited--list-format-init',
 ;;   `gited--mark-branches-in-region',
 ;;   `gited--mark-merged-or-unmerged-branches',
 ;;   `gited--mark-merged-or-unmerged-branches-spec', `gited--merged-branch-p',
@@ -191,6 +192,7 @@
 ;;   `gited-modified-branch', `gited-section-highlight',
 ;;   `gited-status-branch-local', `gited-status-tag'.
 ;;
+;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 ;;; Code:
@@ -3238,6 +3240,20 @@ Mode to edit Git branches as Dired."
   (add-hook 'tabulated-list-revert-hook 'gited-tabulated-list-entries nil t)
   (setq tabulated-list-sort-key (or tabulated-list-sort-key '("Date"))))
 
+;; We need this advice to sort by one of the last columns
+;; when `gited-hide-details-mode' is enabled.
+(defun gited--advice-sort-by-column (orig-fun &rest args)
+  (if (not (derived-mode-p 'gited-mode))
+      (apply orig-fun args)
+    (cond (gited-hide-details-mode
+           (gited-hide-details-mode 0)
+           (apply orig-fun args)
+           (gited-hide-details-mode 1))
+          (t (apply orig-fun args)))
+    (when (gited-branch-exists-p gited-current-branch)
+      (gited-fontify-current-branch))))
+
+(advice-add 'tabulated-list-col-sort :around 'gited--advice-sort-by-column)
 
 (provide 'gited)
 ;;; gited.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]