Use lexical-bind in Tramp

* 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.
This commit is contained in:
Michael Albinus 2017-03-23 14:58:04 +01:00
parent e472cfe8f3
commit e1392faae5
12 changed files with 35 additions and 37 deletions

View 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

View 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.

View 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.

View 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.

View 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.

View 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))

View 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.

View 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.

View 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.

View 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.
@ -60,7 +60,10 @@
;; 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."

View 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.

View 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)
@ -44,11 +45,11 @@
(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.