]> code.delx.au - gnu-emacs-elpa/commitdiff
multishell - settle known multishell-list sort instability issues.
authorKen Manheimer <ken.manheimer@gmail.com>
Sun, 31 Jan 2016 17:05:42 +0000 (12:05 -0500)
committerKen Manheimer <ken.manheimer@gmail.com>
Sun, 31 Jan 2016 17:05:42 +0000 (12:05 -0500)
Increment version to 1.1.2

multishell-list.el
multishell.el

index df4731e717408364c33d33f59bedf101c905ee5d..8177981ba1f5353d134be6e7a7232538d47e354a 100644 (file)
@@ -3,7 +3,7 @@
 ;; Copyright (C) 2016 Free Software Foundation, Inc. and Ken Manheimer
 
 ;; Author: Ken Manheimer <ken.manheimer@gmail.com>
 ;; Copyright (C) 2016 Free Software Foundation, Inc. and Ken Manheimer
 
 ;; Author: Ken Manheimer <ken.manheimer@gmail.com>
-;; Version: 1.1.1
+;; Version: 1.1.2
 ;; Created: 2016 -- first public availability
 ;; Keywords: processes
 ;; URL: https://github.com/kenmanheimer/EmacsMultishell
 ;; Created: 2016 -- first public availability
 ;; Keywords: processes
 ;; URL: https://github.com/kenmanheimer/EmacsMultishell
@@ -63,17 +63,16 @@ supplemented by our own when buffer is inactive.)"
          (revised (multishell-read-unbracketed-entry
                    (format "Edit shell spec for %s: " name)
                    nil
          (revised (multishell-read-unbracketed-entry
                    (format "Edit shell spec for %s: " name)
                    nil
-                   entry))
-         (revised-path (and revised (cadr (multishell-split-entry revised))))
+                   entry
+                   'no-record))
          (revised-name (multishell-name-from-entry revised))
          buffer)
     (when (not (string= revised entry))
          (revised-name (multishell-name-from-entry revised))
          buffer)
     (when (not (string= revised entry))
-      (multishell-delete-history-name name)
+      (multishell-replace-entry entry revised)
       (when (and (not (string= name revised-name))
                  (setq buffer (get-buffer (multishell-bracket name))))
         (with-current-buffer buffer
           (rename-buffer (multishell-bracket revised-name))))
       (when (and (not (string= name revised-name))
                  (setq buffer (get-buffer (multishell-bracket name))))
         (with-current-buffer buffer
           (rename-buffer (multishell-bracket revised-name))))
-      (multishell-register-name-to-path revised-name revised-path)
       (revert-buffer)
       (goto-char where))))
 
       (revert-buffer)
       (goto-char where))))
 
@@ -138,15 +137,6 @@ supplemented by our own when buffer is inactive.)"
         tabulated-list-entries #'multishell-list-entries)
   (tabulated-list-init-header))
 
         tabulated-list-entries #'multishell-list-entries)
   (tabulated-list-init-header))
 
-(defvar multishell-list-already-re-reverting nil
-  "Don't set - internal for `multishell-list-revert-buffer-kludge'.")
-(defun multishell-list-revert-buffer-kludge ()
-  "Double revert for kludge workaround of untable sorting."
-  (if (not multishell-list-already-re-reverting)
-      (let ((multishell-list-already-re-reverting t))
-        (revert-buffer))))
-(add-hook 'tabulated-list-revert-hook 'multishell-list-revert-buffer-kludge)
-
 (define-key multishell-list-mode-map (kbd "d") 'multishell-list-delete)
 (define-key multishell-list-mode-map (kbd "\C-k") 'multishell-list-delete)
 (define-key multishell-list-mode-map (kbd "k") 'multishell-list-delete)
 (define-key multishell-list-mode-map (kbd "d") 'multishell-list-delete)
 (define-key multishell-list-mode-map (kbd "\C-k") 'multishell-list-delete)
 (define-key multishell-list-mode-map (kbd "k") 'multishell-list-delete)
index 283be374a6b20522af1817781073df2e3f1c24d6..55408645b73122b508d599b1b36577ed29ef4122 100644 (file)
@@ -3,7 +3,7 @@
 ;; Copyright (C) 1999-2016 Free Software Foundation, Inc. and Ken Manheimer
 
 ;; Author: Ken Manheimer <ken.manheimer@gmail.com>
 ;; Copyright (C) 1999-2016 Free Software Foundation, Inc. and Ken Manheimer
 
 ;; Author: Ken Manheimer <ken.manheimer@gmail.com>
-;; Version: 1.1.1
+;; Version: 1.1.2
 ;; Created: 1999 -- first public availability
 ;; Keywords: processes
 ;; URL: https://github.com/kenmanheimer/EmacsMultishell
 ;; Created: 1999 -- first public availability
 ;; Keywords: processes
 ;; URL: https://github.com/kenmanheimer/EmacsMultishell
 ;;
 ;; Change Log:
 ;;
 ;;
 ;; Change Log:
 ;;
+;; * 2016-01-31 1.1.2 Ken Manheimer:
+;;   - Settle puzzling instability of multishell-all-entries
+;;     - The accumulations was putting items going from more to less active
+;;       categories to be put at the end, not beginning.
+;;     - Also, using history for prompting changes history - implement
+;;       no-record option to avoid this when needed.
+;;   - Implement simple edit-in-place multishell-replace-entry and use in
+;;     multishell-list-edit-entry.
+;;   - Remove now (hopefully) unnecessary multishell-list-revert-buffer-kludge.
 ;; * 2016-01-30 1.1.1 Ken Manheimer:
 ;;   - shake out initial multishell-list glitches:
 ;;     - (Offer to) delete shell buffer, if present, when deleting entry.
 ;; * 2016-01-30 1.1.1 Ken Manheimer:
 ;;   - shake out initial multishell-list glitches:
 ;;     - (Offer to) delete shell buffer, if present, when deleting entry.
 (require 'savehist)
 (require 'multishell-list)
 
 (require 'savehist)
 (require 'multishell-list)
 
-(defvar multishell-version "1.1.1")
+(defvar multishell-version "1.1.2")
 (defun multishell-version (&optional here)
   "Return string describing the loaded multishell version."
   (interactive "P")
 (defun multishell-version (&optional here)
   "Return string describing the loaded multishell version."
   (interactive "P")
@@ -272,6 +281,20 @@ Promote added/changed entry to the front of the list."
     (setq multishell-history (push (concat name path)
                                    multishell-history))))
 
     (setq multishell-history (push (concat name path)
                                    multishell-history))))
 
+(defun multishell-replace-entry (entry revised)
+  "Replace every instance of ENTRY in `multishell-history' with REVISED.
+
+Revised entry is situated where former one was.
+
+Returns non-nil iff any changes were made."
+  (let ((candidates multishell-history)
+        did-revisions)
+    (while (setq candidates (member entry candidates))
+      (setcar candidates revised
+              did-revisions t)
+      (setq candidates (cdr candidates)))
+    did-revisions))
+
 (defun multishell-history-entries (name)
   "Return `multishell-history' entry that starts with NAME, or nil if none."
   (let (got)
 (defun multishell-history-entries (name)
   "Return `multishell-history' entry that starts with NAME, or nil if none."
   (let (got)
@@ -295,9 +318,13 @@ historical shells, collectively, using `multishell-list' - see below.
 Customize-group `multishell' to set up a key binding and tweak behaviors.
 
 Manage your collection of current and historical shells by
 Customize-group `multishell' to set up a key binding and tweak behaviors.
 
 Manage your collection of current and historical shells by
-recursively invoking \\[multishell-pop-to-shell] at either of the
-`multishell-pop-to-shell' universal argument prompts, or at any time via
-\\[multishell-list]. Hit ? in the listing buffer for editing commands.
+recursively invoking \\[multishell-pop-to-shell] at the
+`multishell-pop-to-shell' universal argument prompts, eg:
+
+  \\[universal-argument] \\[multishell-pop-to-shell] \\[multishell-pop-to-shell]
+
+\(That will be just a few keys if you do the above
+customization.) Hit ? in the listing buffer for editing commands.
 
 ==== Basic operation:
 
 
 ==== Basic operation:
 
@@ -567,20 +594,28 @@ completions."
                     active-names (push name active-names))
             (setq present (push entry present)))
         (setq past (push entry past))))
                     active-names (push name active-names))
             (setq present (push entry present)))
         (setq past (push entry past))))
-    (setq multishell-history (append active-entries present past))
+    ;; Reverse present and past lists
+    (setq multishell-history (append (reverse active-entries)
+                                     (reverse present)
+                                     (reverse past)))
     (if active-duplicated
         (append multishell-history active-names)
       multishell-history)))
 
     (if active-duplicated
         (append multishell-history active-names)
       multishell-history)))
 
-(defun multishell-read-unbracketed-entry (prompt default &optional initial)
+(defun multishell-read-unbracketed-entry (prompt default
+                                                 &optional initial no-record)
   "PROMPT for shell buffer name, sans asterisks. Indicate DEFAULT in prompt.
 
 Optional INITIAL is preliminary value to be edited.
 
   "PROMPT for shell buffer name, sans asterisks. Indicate DEFAULT in prompt.
 
 Optional INITIAL is preliminary value to be edited.
 
+Optional NO-RECORD prevents changes to `multishell-history'
+across the activity.
+
 Input and completion can include associated path, if any.
 
 Return what's provided, if anything, else nil."
 Input and completion can include associated path, if any.
 
 Return what's provided, if anything, else nil."
-  (let* ((candidates (multishell-all-entries 'active-duplicated))
+  (let* ((was-multishell-history multishell-history)
+         (candidates (multishell-all-entries 'active-duplicated))
          (got (completing-read prompt
                                ;; COLLECTION:
                                (reverse candidates)
          (got (completing-read prompt
                                ;; COLLECTION:
                                (reverse candidates)
@@ -592,6 +627,8 @@ Return what's provided, if anything, else nil."
                                initial
                                ;; HIST:
                                'multishell-history)))
                                initial
                                ;; HIST:
                                'multishell-history)))
+    (when no-record
+      (setq multishell-history was-multishell-history))
     (if (not (string= got ""))
         got
       nil)))
     (if (not (string= got ""))
         got
       nil)))