emacs-diffs
[Top][All Lists]
Advanced

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

master db4dd28c21: In Tramp, use `string-empty-p' and `string-equal-igno


From: Michael Albinus
Subject: master db4dd28c21: In Tramp, use `string-empty-p' and `string-equal-ignore-case' consequently
Date: Wed, 27 Jul 2022 06:51:23 -0400 (EDT)

branch: master
commit db4dd28c21f95361de620c6e543d23da5d982fd5
Author: Michael Albinus <michael.albinus@gmx.de>
Commit: Michael Albinus <michael.albinus@gmx.de>

    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.
---
 lisp/net/tramp-cmds.el   | 2 +-
 lisp/net/tramp-compat.el | 9 ++++++++-
 lisp/net/tramp-gvfs.el   | 2 +-
 lisp/net/tramp-sh.el     | 4 ++--
 lisp/net/tramp.el        | 2 +-
 5 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/lisp/net/tramp-cmds.el b/lisp/net/tramp-cmds.el
index bd2dbf4a1e..5c8012e553 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 ef5b1f7ec9..bc32044451 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 d9afcf93c1..2f97b2cb91 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 b991de954c..172933859c 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 3f78c8d658..c123b2eac1 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



reply via email to

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