]> git.eshelyaron.com Git - emacs.git/commitdiff
Use lexical-bind in Tramp
authorMichael Albinus <michael.albinus@gmx.de>
Thu, 23 Mar 2017 13:58:04 +0000 (14:58 +0100)
committerMichael Albinus <michael.albinus@gmx.de>
Thu, 23 Mar 2017 13:58:04 +0000 (14:58 +0100)
* lisp/net/tramp*.el: Add lexical-binding cookie.  Move declarations up.

* lisp/net/tramp-adb.el (tramp-adb-parse-device-names): Use `push'
rather than `add-to-list'.
(tramp-adb-get-device): Remove unused variable.

* lisp/net/tramp-gvfs.el (tramp-gvfs-parse-device-names): Remove unused
variable.

* lisp/net/tramp.el (auto-save-file-name-transforms): Declare.
(tramp-find-file-name-coding-system-alist): Use `push' rather
than `add-to-list'.

* test/lisp/net/tramp-tests.el: Add lexical-binding cookie.
Require 'dired.  Move declarations up.
(tramp-test32-make-nearby-temp-file): Wrap `make-nearby-temp-file'
and `temporary-file-directory' calls with `with-no-warnings'.
(tramp-test35-asynchronous-requests): Mark unused variable.

12 files changed:
lisp/net/tramp-adb.el
lisp/net/tramp-cache.el
lisp/net/tramp-cmds.el
lisp/net/tramp-compat.el
lisp/net/tramp-ftp.el
lisp/net/tramp-gvfs.el
lisp/net/tramp-sh.el
lisp/net/tramp-smb.el
lisp/net/tramp-uu.el
lisp/net/tramp.el
lisp/net/trampver.el
test/lisp/net/tramp-tests.el

index bf89ab3712385c3b9fa0276e887722f93714e287..4191c3ec93a5ea42ea71f0afbb672dac74871483 100644 (file)
@@ -1,4 +1,4 @@
-;;; tramp-adb.el --- Functions for calling Android Debug Bridge from Tramp
+;;; tramp-adb.el --- Functions for calling Android Debug Bridge from Tramp  -*- lexical-binding:t -*-
 
 ;; Copyright (C) 2011-2017 Free Software Foundation, Inc.
 
@@ -209,7 +209,7 @@ pass to the OPERATION."
        (tramp-message v 6 "\n%s" (buffer-string))
        (goto-char (point-min))
        (while (search-forward-regexp "^\\(\\S-+\\)[[:space:]]+device$" nil t)
-         (add-to-list 'result (list nil (match-string 1))))
+         (push (list nil (match-string 1)) result))
 
        ;; Replace ":" by "#".
        (mapc
@@ -1060,8 +1060,7 @@ E.g. a host name \"192.168.1.1#5555\" returns \"192.168.1.1:5555\"
   ;; unwanted entries first.
   (tramp-flush-connection-property nil)
   (with-tramp-connection-property (tramp-get-connection-process vec) "device"
-    (let* ((method (tramp-file-name-method vec))
-          (host (tramp-file-name-host vec))
+    (let* ((host (tramp-file-name-host vec))
           (port (tramp-file-name-port vec))
           (devices (mapcar 'cadr (tramp-adb-parse-device-names nil))))
       (replace-regexp-in-string
index ce7df02e0947c269c298d1cc58dadd9787fa6a7d..64268cfc25a8888451a9f959ea4195d2ac9d5d2d 100644 (file)
@@ -1,4 +1,4 @@
-;;; tramp-cache.el --- file information caching for Tramp
+;;; tramp-cache.el --- file information caching for Tramp  -*- lexical-binding:t -*-
 
 ;; Copyright (C) 2000, 2005-2017 Free Software Foundation, Inc.
 
index 576f9b1eadccdcb64c6c1315f2e22daf900a9a3e..c41b5b5659ef593a73d0de3d31b03c435da857b4 100644 (file)
@@ -1,4 +1,4 @@
-;;; tramp-cmds.el --- Interactive commands for Tramp
+;;; tramp-cmds.el --- Interactive commands for Tramp  -*- lexical-binding:t -*-
 
 ;; Copyright (C) 2007-2017 Free Software Foundation, Inc.
 
index 8e5b3e45d13d54475065e071b4a81e7ff12bb29c..8f346eb44099ba58ad630ee8d5763e506642ff6c 100644 (file)
@@ -1,4 +1,4 @@
-;;; tramp-compat.el --- Tramp compatibility functions
+;;; tramp-compat.el --- Tramp compatibility functions  -*- lexical-binding:t -*-
 
 ;; Copyright (C) 2007-2017 Free Software Foundation, Inc.
 
index 85e4f2b0f0cc484981d9d6cce6eea8283839d4bf..231383fde3d1338e22b2d1b631107849850280b5 100644 (file)
@@ -1,4 +1,4 @@
-;;; tramp-ftp.el --- Tramp convenience functions for Ange-FTP
+;;; tramp-ftp.el --- Tramp convenience functions for Ange-FTP  -*- lexical-binding:t -*-
 
 ;; Copyright (C) 2002-2017 Free Software Foundation, Inc.
 
index 7725d40f198bd83ed80dfd0bc92cf20739b607ba..561f6c8f79d2979059eccdeb09b5b69071d9cc2a 100644 (file)
@@ -1,4 +1,4 @@
-;;; tramp-gvfs.el --- Tramp access functions for GVFS daemon
+;;; tramp-gvfs.el --- Tramp access functions for GVFS daemon  -*- lexical-binding:t -*-
 
 ;; Copyright (C) 2009-2017 Free Software Foundation, Inc.
 
@@ -1874,12 +1874,9 @@ This uses \"avahi-browse\" in case D-Bus is not enabled in Avahi."
       (lambda (x)
        (let* ((list (split-string x ";"))
               (host (nth 6 list))
-              (port (nth 8 list))
               (text (tramp-compat-funcall
                      'split-string (nth 9 list) "\" \"" 'omit "\""))
               user)
-;        (when (and port (not (string-equal port "0")))
-;          (setq host (format "%s%s%s" host tramp-prefix-port-regexp port)))
          ;; A user is marked in a TXT field like "u=guest".
          (while text
            (when (string-match "u=\\(.+\\)$" (car text))
index af27d3e28ec964c6f3b28ef2181b9210089ebc8f..486e002facf6afcd5b7b6c41835391f484ffb1f7 100644 (file)
@@ -1,4 +1,4 @@
-;;; tramp-sh.el --- Tramp access functions for (s)sh-like connections
+;;; tramp-sh.el --- Tramp access functions for (s)sh-like connections  -*- lexical-binding:t -*-
 
 ;; Copyright (C) 1998-2017 Free Software Foundation, Inc.
 
@@ -33,6 +33,9 @@
 (eval-when-compile
   (require 'cl)
   (require 'dired))
+
+(declare-function dired-remove-file "dired-aux")
+(defvar dired-compress-file-suffixes)
 (defvar vc-handled-backends)
 (defvar vc-bzr-program)
 (defvar vc-git-program)
@@ -2593,9 +2596,6 @@ The method used must be an out-of-band method."
 
 ;; Dired.
 
-(defvar dired-compress-file-suffixes)
-(declare-function dired-remove-file "dired-aux")
-
 (defun tramp-sh-handle-dired-compress-file (file)
   "Like `dired-compress-file' for Tramp files."
   ;; Code stolen mainly from dired-aux.el.
index 91f69567573f41df2c7cf7269bbdf18c9eaed2ac..eaa8ac655e056a837d3a7f94e059ac8e39c032ac 100644 (file)
@@ -1,4 +1,4 @@
-;;; tramp-smb.el --- Tramp access functions for SMB servers
+;;; tramp-smb.el --- Tramp access functions for SMB servers  -*- lexical-binding:t -*-
 
 ;; Copyright (C) 2002-2017 Free Software Foundation, Inc.
 
index 0aa2cc099249419bfcdb81cc5635b498d1998d43..5e5f05da4a8a8e22844ffc7cc13a5ac72e3276b1 100644 (file)
@@ -1,4 +1,4 @@
-;;; tramp-uu.el --- uuencode in Lisp
+;;; tramp-uu.el --- uuencode in Lisp  -*- lexical-binding:t -*-
 
 ;; Copyright (C) 2002-2017 Free Software Foundation, Inc.
 
index fdd4661decb2da86ece3aaf6d802f749c54908ae..a9254693adb725590c77a4b8fdc71e08cba7dfae 100644 (file)
@@ -1,4 +1,4 @@
-;;; tramp.el --- Transparent Remote Access, Multiple Protocol
+;;; tramp.el --- Transparent Remote Access, Multiple Protocol  -*- lexical-binding:t -*-
 
 ;; Copyright (C) 1998-2017 Free Software Foundation, Inc.
 
 ;; Pacify byte-compiler.
 (eval-when-compile
   (require 'cl))
+(defvar auto-save-file-name-transforms)
 (defvar eshell-path-env)
+(defvar ls-lisp-use-insert-directory-program)
+(defvar outline-regexp)
 
 ;;; User Customizable Internal Variables:
 
@@ -1374,8 +1377,6 @@ Point must be at the beginning of a header line.
 The outline level is equal to the verbosity of the Tramp message."
   (1+ (string-to-number (match-string 1))))
 
-(defvar outline-regexp)
-
 (defun tramp-get-debug-buffer (vec)
   "Get the debug buffer for VEC."
   (with-current-buffer
@@ -1871,13 +1872,12 @@ temporary file names.  If `file-coding-system-alist' contains an
 expression, which matches more than the file name suffix, the
 coding system might not be determined.  This function repairs it."
   (let (result)
-    (dolist (elt file-coding-system-alist result)
+    (dolist (elt file-coding-system-alist (nreverse result))
       (when (and (consp elt) (string-match (car elt) filename))
        ;; We found a matching entry in `file-coding-system-alist'.
        ;; So we add a similar entry, but with the temporary file name
        ;; as regexp.
-       (add-to-list
-        'result (cons (regexp-quote tmpname) (cdr elt)) 'append)))))
+       (push (cons (regexp-quote tmpname) (cdr elt)) result)))))
 
 ;;;###autoload
 (progn (defun tramp-run-real-handler (operation args)
@@ -2328,9 +2328,9 @@ not in completion mode."
       (when elt
        (string-match tramp-prefix-regexp elt)
        (setq elt (replace-match (concat tramp-prefix-format hop) nil nil elt))
-       (add-to-list
-        'result1
-        (substring elt (length (tramp-drop-volume-letter directory))))))
+       (push
+        (substring elt (length (tramp-drop-volume-letter directory)))
+        result1)))
 
     ;; Complete local parts.
     (append
@@ -2955,8 +2955,6 @@ User is always nil."
             backup-directory-alist)))
       (tramp-run-real-handler 'find-backup-file-name (list filename)))))
 
-(defvar ls-lisp-use-insert-directory-program)
-
 (defun tramp-handle-insert-directory
   (filename switches &optional wildcard full-directory-p)
   "Like `insert-directory' for Tramp files."
index 35ad2f0acffefca78e6c348a4d68f24d3832d6a4..35b5eb6728ac444af6d3ce86f3a3f0b07cd7ac72 100644 (file)
@@ -1,4 +1,4 @@
-;;; trampver.el --- Transparent Remote Access, Multiple Protocol
+;;; trampver.el --- Transparent Remote Access, Multiple Protocol  -*- lexical-binding:t -*-
 ;;; lisp/trampver.el.  Generated from trampver.el.in by configure.
 
 ;; Copyright (C) 2003-2017 Free Software Foundation, Inc.
index 45b4ff2f5ab771cf8d9f2303b7bad7c8b3de9a01..2a4ef740a04d02ed2bba2e97796c7cbcf055c6aa 100644 (file)
@@ -1,4 +1,4 @@
-;;; tramp-tests.el --- Tests of remote file access
+;;; tramp-tests.el --- Tests of remote file access  -*- lexical-binding:t -*-
 
 ;; Copyright (C) 2013-2017 Free Software Foundation, Inc.
 
@@ -37,6 +37,7 @@
 
 ;;; Code:
 
+(require 'dired)
 (require 'ert)
 (require 'tramp)
 (require 'vc)
 (require 'vc-git)
 (require 'vc-hg)
 
-(autoload 'dired-uncache "dired")
 (declare-function tramp-find-executable "tramp-sh")
 (declare-function tramp-get-remote-path "tramp-sh")
 (declare-function tramp-get-remote-stat "tramp-sh")
 (declare-function tramp-get-remote-perl "tramp-sh")
+(defvar auto-save-file-name-transforms)
 (defvar tramp-copy-size-limit)
 (defvar tramp-persistency-file-name)
 (defvar tramp-remote-process-environment)
@@ -2083,17 +2084,20 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
   (skip-unless
    (and (fboundp 'make-nearby-temp-file) (fboundp 'temporary-file-directory)))
 
+  ;; `make-nearby-temp-file' and `temporary-file-directory' exists
+  ;; since Emacs 26.  We don't want to see compiler warnings for older
+  ;; Emacsen."
   (let ((default-directory tramp-test-temporary-file-directory)
        tmp-file)
     ;; The remote host shall know a temporary file directory.
-    (should (stringp (temporary-file-directory)))
+    (should (stringp (with-no-warnings (temporary-file-directory))))
     (should
      (string-equal
       (file-remote-p default-directory)
-      (file-remote-p (temporary-file-directory))))
+      (file-remote-p (with-no-warnings (temporary-file-directory)))))
 
     ;; The temporary file shall be located on the remote host.
-    (setq tmp-file (make-nearby-temp-file "tramp-test"))
+    (setq tmp-file (with-no-warnings (make-nearby-temp-file "tramp-test")))
     (should (file-exists-p tmp-file))
     (should (file-regular-p tmp-file))
     (should
@@ -2103,7 +2107,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
     (delete-file tmp-file)
     (should-not (file-exists-p tmp-file))
 
-    (setq tmp-file (make-nearby-temp-file "tramp-test" 'dir))
+    (setq tmp-file (with-no-warnings (make-nearby-temp-file "tramp-test" 'dir)))
     (should (file-exists-p tmp-file))
     (should (file-directory-p tmp-file))
     (delete-directory tmp-file)
@@ -2582,7 +2586,7 @@ process sentinels.  They shall not disturb each other."
            ;; Create temporary buffers.  The number of buffers
            ;; corresponds to the number of processes; it could be
            ;; increased in order to make pressure on Tramp.
-           (dotimes (i 5)
+           (dotimes (_i 5)
              (add-to-list 'buffers (generate-new-buffer "*temp*")))
 
            ;; Open asynchronous processes.  Set process sentinel.