From: Michael Albinus Date: Wed, 27 Jul 2022 10:51:11 +0000 (+0200) Subject: In Tramp, use `string-empty-p' and `string-equal-ignore-case' consequently X-Git-Tag: emacs-29.0.90~1447^2~727 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=db4dd28c21f95361de620c6e543d23da5d982fd5;p=emacs.git In Tramp, use `string-empty-p' and `string-equal-ignore-case' consequently * lisp/net/tramp.el (tramp-find-method): * lisp/net/tramp-cmds.el (tramp-change-syntax): * lisp/net/tramp-sh.el (tramp-sh-get-signal-strings) (tramp-open-connection-setup-interactive-shell): Use `string-empty-p'. * lisp/net/tramp-compat.el (tramp-compat-string-equal-ignore-case): New defalias. * lisp/net/tramp-gvfs.el (tramp-gvfs-handler-mounted-unmounted): Use it. --- diff --git a/lisp/net/tramp-cmds.el b/lisp/net/tramp-cmds.el index bd2dbf4a1e0..5c8012e553b 100644 --- a/lisp/net/tramp-cmds.el +++ b/lisp/net/tramp-cmds.el @@ -46,7 +46,7 @@ SYNTAX can be one of the symbols `default' (default), (let ((input (completing-read "Enter Tramp syntax: " (tramp-syntax-values) nil t (symbol-name tramp-syntax)))) - (unless (string-equal input "") + (unless (string-empty-p input) (list (intern input))))) (when syntax (customize-set-variable 'tramp-syntax syntax))) diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el index ef5b1f7ec90..bc32044451c 100644 --- a/lisp/net/tramp-compat.el +++ b/lisp/net/tramp-compat.el @@ -312,6 +312,13 @@ CONDITION can also be a list of error conditions." (if (>= n (length list)) list (nbutlast list (- (length list) n))))))) +;; Function `string-equal-ignore-case' is new in Emacs 29.1. +(defalias 'tramp-compat-string-equal-ignore-case + (if (fboundp 'string-equal-ignore-case) + #'string-equal-ignore-case + (lambda (string1 string2) + (eq t (compare-strings string1 nil nil string2 nil nil t))))) + (dolist (elt (all-completions "tramp-compat-" obarray 'functionp)) (put (intern elt) 'tramp-suppress-trace t)) @@ -328,6 +335,6 @@ CONDITION can also be a list of error conditions." ;; parentheses with a backslash in docstrings anymore. ;; ;; * Starting with Emacs 27.1, there's `make-empty-file'. Could be -;; used instead of `write-region'. +;; used instead of `(write-region "" ...)'. ;;; tramp-compat.el ends here diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el index d9afcf93c19..2f97b2cb916 100644 --- a/lisp/net/tramp-gvfs.el +++ b/lisp/net/tramp-gvfs.el @@ -1889,7 +1889,7 @@ Their full names are \"org.gtk.vfs.MountTracker.mounted\" and v 6 "%s %s" signal-name (tramp-gvfs-stringify-dbus-message mount-info)) (tramp-flush-file-property v "/" "list-mounts") - (if (string-equal (downcase signal-name) "unmounted") + (if (tramp-compat-string-equal-ignore-case signal-name "unmounted") (tramp-flush-file-properties v "/") ;; Set mountpoint and location. (tramp-set-file-property v "/" "fuse-mountpoint" fuse-mountpoint) diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index b991de954c6..172933859c1 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -3115,7 +3115,7 @@ implementation will be used." (with-current-buffer (tramp-get-connection-buffer vec) (goto-char (point-min)) (buffer-substring (point-at-bol) (point-at-eol))))) - (if (string-equal res "") + (if (string-empty-p res) (format "Signal %d" i) res))) result)) @@ -4434,7 +4434,7 @@ process to set up. VEC specifies the connection." (copy-sequence tramp-remote-process-environment)))) (setq item (split-string item "=" 'omit)) (setcdr item (string-join (cdr item) "=")) - (if (and (stringp (cdr item)) (not (string-equal (cdr item) ""))) + (if (and (stringp (cdr item)) (not (string-empty-p (cdr item)))) (push (format "%s %s" (car item) (cdr item)) vars) (push (car item) unset))) (when vars diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 3f78c8d6583..c123b2eac18 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -1558,7 +1558,7 @@ of `process-file', `start-file-process', or `shell-command'." This is METHOD, if non-nil. Otherwise, do a lookup in `tramp-default-method-alist' and `tramp-default-method'." (when (and method - (or (string-equal method "") + (or (string-empty-p method) (string-equal method tramp-default-method-marker))) (setq method nil)) (let ((result