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

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

[elpa] master d5d7782: * packages/multishell: Break cyclic require; use


From: Stefan Monnier
Subject: [elpa] master d5d7782: * packages/multishell: Break cyclic require; use lexical and cl-lib
Date: Tue, 27 Feb 2018 14:48:31 -0500 (EST)

branch: master
commit d5d7782ddef6701d12328401d65f7e46025395e4
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>

    * packages/multishell: Break cyclic require; use lexical and cl-lib
    
    * multishell.el: Don't require 'multishell-list'.
    (multishell-implement-command-key-choice): Rewrite so the compiler
    understands that multishell-activate-command-key is only used if
    it's bound.
    (multishell-track-dirchange): Remove unused var 'name'.
    
    * multishell-list.el: Require 'multishell' in the normal way.
    (multishell-list-delete): Don't pass unused 'arg'.
    (multishell-list--collate-row-strings-as-numbers): Rename from
    multishell-collate-row-strings-as-numbers.
    (multishell-list-cull-dups): 'mapcar' => 'dolist'.
    (multishell-list): 'progv' => 'cl-progv'.
---
 packages/multishell/multishell-list.el | 38 ++++++++++++++++++----------------
 packages/multishell/multishell.el      | 26 ++++++++++-------------
 2 files changed, 31 insertions(+), 33 deletions(-)

diff --git a/packages/multishell/multishell-list.el 
b/packages/multishell/multishell-list.el
index 9300494..25a86d1 100644
--- a/packages/multishell/multishell-list.el
+++ b/packages/multishell/multishell-list.el
@@ -1,6 +1,6 @@
-;;; multishell-list.el --- tabulated-list-mode for multishell shell buffers
+;;; multishell-list.el --- tabulated-list-mode for multishell shell buffers  
-*- lexical-binding:t -*-
 
-;; Copyright (C) 2016 Free Software Foundation, Inc. and Ken Manheimer
+;; Copyright (C) 2016-2018 Free Software Foundation, Inc. and Ken Manheimer
 
 ;; Author: Ken Manheimer <address@hidden>
 ;; Version: 1.1.5
@@ -11,6 +11,8 @@
 ;; See multishell.el for commentary, change log, etc.
 
 (require 'tabulated-list)
+(require 'multishell)
+(eval-when-compile (require 'cl-lib))
 
 (defgroup multishell-list nil
   "Show a menu of all shell buffers in a buffer."
@@ -65,9 +67,9 @@ switch to the buffer but don't activate (or deactivate) it 
it."
     (with-current-buffer list-buffer
       (revert-buffer))))
 
-(defun multishell-list-delete (&optional arg)
+(defun multishell-list-delete (&optional _arg)
   "Remove current shell entry, and prompt for buffer-removal if present."
-  (interactive "P")
+  (interactive)
   (let* ((entry (tabulated-list-get-id))
          (name (multishell-name-from-entry entry))
          (name-bracketed (multishell-bracket name))
@@ -200,7 +202,9 @@ Provide for concluding minibuffer interaction if we're in 
completing mode."
               (not (string= (tabulated-list-get-id) entry)))
     (forward-line 1)))
 
-(defun multishell-collate-row-strings-as-numbers (a b)
+(define-obsolete-function-alias 'multishell-collate-row-strings-as-numbers
+  #'multishell-list--collate-row-strings-as-numbers "multishell 1.1.6")
+(defun multishell-list--collate-row-strings-as-numbers (a b)
   (let ((a (aref (cadr a) 0))
         (b (aref (cadr b) 0)))
     (> (string-to-number a) (string-to-number b))))
@@ -238,7 +242,7 @@ Initial sort is from most to least recently used:
 \\{multishell-list-mode-map\}"
   (setq tabulated-list-format
         [;; (name width sort '(:right-align nil :pad-right nil))
-         ("#" 0 multishell-collate-row-strings-as-numbers :pad-right 1)
+         ("#" 0 multishell-list--collate-row-strings-as-numbers :pad-right 1)
          ("! " 1 t :pad-right 1)
          ("Name" 15 t)
          ("Hops" 30 t)
@@ -253,15 +257,14 @@ Initial sort is from most to least recently used:
 For duplicates, we prefer the ones that have paths."
   (let ((tally (make-hash-table :test #'equal))
         got name name-order-reversed already)
-    (mapcar #'(lambda (entry)
-                (setq name (multishell-name-from-entry entry)
-                      already (gethash name tally nil))
-                (when (not already)
-                  (push name name-order-reversed))
-                (when (or (not already) (< (length already) (length entry)))
-                  ;; Add new or replace shorter prior entry for name:
-                  (puthash name entry tally)))
-            entries)
+    (dolist (entry entries)
+      (setq name (multishell-name-from-entry entry)
+            already (gethash name tally nil))
+      (when (not already)
+        (push name name-order-reversed))
+      (when (or (not already) (< (length already) (length entry)))
+        ;; Add new or replace shorter prior entry for name:
+        (puthash name entry tally)))
     (dolist (name name-order-reversed)
       (push (gethash name tally) got))
     got))
@@ -294,11 +297,11 @@ You can get to the shells listing by recursively invoking
         (set-buffer buffer)
       (pop-to-buffer buffer))
     (multishell-list-mode)
-    (progv
+    (cl-progv
         ;; Temporarily assign multishell-history only when completing:
         (when completing '(multishell-history))
         (when completing
-          (list (multishell-list-cull-dups (mapcar 'substring-no-properties
+          (list (multishell-list-cull-dups (mapcar #'substring-no-properties
                                                    completing))))
       (tabulated-list-print))
     (when completing
@@ -307,6 +310,5 @@ You can get to the shells listing by recursively invoking
       (multishell-list-goto-item-by-entry from-entry))))
 
 (provide 'multishell-list)
-(require 'multishell)
 
 ;;; multishell-list.el ends here
diff --git a/packages/multishell/multishell.el 
b/packages/multishell/multishell.el
index 54d0436..9dc8517 100644
--- a/packages/multishell/multishell.el
+++ b/packages/multishell/multishell.el
@@ -1,11 +1,12 @@
-;;; multishell.el --- Easily use multiple shell buffers, local and remote.
+;;; multishell.el --- Easily use multiple shell buffers, local and remote  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1999-2016 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2016, 2018 Free Software Foundation, Inc.
 
 ;; Author: Ken Manheimer <address@hidden>
 ;; Version: 1.1.5
 ;; Created: 1999 -- first public availability
 ;; Keywords: processes
+;; Package-Requires: ((cl-lib "0.5"))
 ;; URL: https://github.com/kenmanheimer/EmacsMultishell
 ;;
 ;;; Commentary:
@@ -157,7 +158,6 @@
 (require 'comint)
 (require 'shell)
 (require 'savehist)
-(require 'multishell-list)
 
 (defvar multishell-version "1.1.5")
 (defun multishell-version (&optional here)
@@ -197,15 +197,12 @@ If optional UNBIND is true, globally unbind the key.
 
 * `multishell-activate-command-key' - Set this to get the binding or not.
 * `multishell-command-key' - The key to use for the binding, if appropriate."
-  (cond (unbind
-         (when (and (boundp 'multishell-command-key) multishell-command-key)
-           (global-unset-key multishell-command-key)))
-        ((not (and (boundp 'multishell-activate-command-key)
-                   (boundp 'multishell-command-key)))
-         nil)
-        ((and multishell-activate-command-key multishell-command-key)
-         (setq multishell--responsible-for-command-key t)
-         (global-set-key multishell-command-key 'multishell-pop-to-shell))))
+  (when (bound-and-true-p multishell-command-key)
+    (if unbind
+        (global-unset-key multishell-command-key)
+      (when (bound-and-true-p multishell-activate-command-key)
+        (setq multishell--responsible-for-command-key t)
+        (global-set-key multishell-command-key 'multishell-pop-to-shell)))))
 
 (defcustom multishell-activate-command-key nil
   "Set this to impose the `multishell-command-key' binding.
@@ -213,12 +210,12 @@ If optional UNBIND is true, globally unbind the key.
 You can instead manually bind `multishell-pop-to-shell' using emacs
 lisp, eg: (global-set-key \"\\M- \" \\='multishell-pop-to-shell)."
   :type 'boolean
-  :set 'multishell-activate-command-key-setter)
+  :set #'multishell-activate-command-key-setter)
 
 ;; Implement the key customization whenever the package is loaded:
 (if (fboundp 'with-eval-after-load)
     (with-eval-after-load "multishell"
-                         (multishell-implement-command-key-choice))
+      (multishell-implement-command-key-choice))
   (eval-after-load "multishell"
     '(multishell-implement-command-key-choice)))
 
@@ -736,7 +733,6 @@ and path nil if none is resolved."
   (let* ((entries (multishell-history-entries name)))
     (dolist (entry entries)
       (let* ((name-path (multishell-split-entry entry))
-             (name (car name-path))
              (path (or (cadr name-path) "")))
         (when path
           (let* ((old-localname (or (file-remote-p path 'localname)



reply via email to

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