aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Kangas2023-01-23 01:34:43 +0100
committerStefan Kangas2023-01-23 01:34:43 +0100
commit080595682f73a920b9c9bf3eba10548ccc652e79 (patch)
treeb234331cde5d788bf1b9022392332c5fdc5ebcc0
parent1c58f3d7fb298f9ee6aa8554d6537d13cb1944a5 (diff)
parentb875c9bf67ebf858648a00307c370d7a196aab56 (diff)
downloademacs-080595682f73a920b9c9bf3eba10548ccc652e79.tar.gz
emacs-080595682f73a920b9c9bf3eba10548ccc652e79.zip
Merge from origin/emacs-29
b875c9bf67e Fix file-regular-p in Tramp 63fa225d443 Merge branch 'emacs-29' of git.savannah.gnu.org:/srv/git/... 9f5d6c541e5 ; * doc/emacs/custom.texi (Init Rebinding): Fix wording i... a91b435d0d5 ; Reword user documentation on binding keys in Lisp 0400de6a7de Fix typo in c-ts-mode (bug#60932)
-rw-r--r--doc/emacs/custom.texi49
-rw-r--r--lisp/net/tramp.el12
-rw-r--r--test/lisp/net/tramp-archive-tests.el3
-rw-r--r--test/lisp/net/tramp-tests.el22
4 files changed, 72 insertions, 14 deletions
diff --git a/doc/emacs/custom.texi b/doc/emacs/custom.texi
index 91df15a21d7..ee818a74b57 100644
--- a/doc/emacs/custom.texi
+++ b/doc/emacs/custom.texi
@@ -1887,23 +1887,31 @@ command is less work to invoke when you really want to.
1887you can specify them in your initialization file by writing Lisp code. 1887you can specify them in your initialization file by writing Lisp code.
1888@xref{Init File}, for a description of the initialization file. 1888@xref{Init File}, for a description of the initialization file.
1889 1889
1890@findex kbd 1890@findex keymap-global-set
1891 There are several ways to write a key binding using Lisp. The 1891 The recommended way to write a key binding using Lisp is to use
1892simplest is to use the @code{kbd} function, which converts a textual 1892either the @code{keymap-global-set} or the @code{keymap-set}
1893representation of a key sequence---similar to how we have written key 1893functions. For example, here's how to bind @kbd{C-z} to the
1894sequences in this manual---into a form that can be passed as an 1894@code{shell} command in the global keymap (@pxref{Interactive Shell}):
1895argument to @code{keymap-global-set}. For example, here's how to bind
1896@kbd{C-z} to the @code{shell} command (@pxref{Interactive Shell}):
1897 1895
1898@example 1896@example
1899(keymap-global-set "C-z" 'shell) 1897(keymap-global-set "C-z" 'shell)
1900@end example 1898@end example
1901 1899
1900@cindex key sequence syntax
1902@noindent 1901@noindent
1903The single-quote before the command name, @code{shell}, marks it as a 1902The first argument to @code{keymap-global-set} describes the key
1903sequence. It is a string made of a series of characters separated
1904by spaces, with each character corresponding to a key. Keys with
1905modifiers can be specified by prepending the modifier, such as
1906@samp{C-} for Control, or @samp{M-} for Meta. Special keys, such as
1907@key{TAB} and @key{RET}, can be specified within angle brackets as in
1908@kbd{@key{TAB}} and @kbd{@key{RET}}.
1909
1910 The single-quote before the command name that is being bound to the
1911key sequence, @code{shell} in the above example, marks it as a
1904constant symbol rather than a variable. If you omit the quote, Emacs 1912constant symbol rather than a variable. If you omit the quote, Emacs
1905would try to evaluate @code{shell} as a variable. This probably 1913would try to evaluate @code{shell} as a variable. This will probably
1906causes an error; it certainly isn't what you want. 1914cause an error; it certainly isn't what you want.
1907 1915
1908 Here are some additional examples, including binding function keys 1916 Here are some additional examples, including binding function keys
1909and mouse events: 1917and mouse events:
@@ -1920,6 +1928,27 @@ and mouse events:
1920 Language and coding systems may cause problems with key bindings for 1928 Language and coding systems may cause problems with key bindings for
1921non-@acronym{ASCII} characters. @xref{Init Non-ASCII}. 1929non-@acronym{ASCII} characters. @xref{Init Non-ASCII}.
1922 1930
1931@findex global-set-key
1932@findex define-key
1933 Alternatively, you can use the low level functions @code{define-key}
1934and @code{global-set-key}. For example, to bind @kbd{C-z} to the
1935@code{shell} command, as in the above example, using these low-level
1936functions, use:
1937
1938@example
1939(global-set-key (kbd "C-z") 'shell)
1940@end example
1941
1942@findex kbd
1943@noindent
1944There are various ways to specify the key sequence but the simplest is
1945to use the function @code{kbd} as shown in the example above.
1946@code{kbd} takes a single string argument that is a textual
1947representation of a key sequence, and converts it into a form suitable
1948for low-level functions such as @code{global-set-key}. For more
1949details about binding keys using Lisp, @pxref{Keymaps,,, elisp, The
1950Emacs Lisp Reference Manual}.
1951
1923@findex keymap-set 1952@findex keymap-set
1924@findex keymap-unset 1953@findex keymap-unset
1925 As described in @ref{Local Keymaps}, major modes and minor modes can 1954 As described in @ref{Local Keymaps}, major modes and minor modes can
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index fab1962d2b7..5e2428bb034 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -4045,9 +4045,15 @@ Let-bind it when necessary.")
4045 "Like `file-regular-p' for Tramp files." 4045 "Like `file-regular-p' for Tramp files."
4046 (and (file-exists-p filename) 4046 (and (file-exists-p filename)
4047 ;; Sometimes, `file-attributes' does not return a proper value 4047 ;; Sometimes, `file-attributes' does not return a proper value
4048 ;; even if `file-exists-p' does. 4048 ;; even if `file-exists-p' does. Protect by `ignore-errors',
4049 (when-let ((attr (file-attributes filename))) 4049 ;; because `file-truename' could raise an error for cyclic
4050 (eq ?- (aref (file-attribute-modes attr) 0))))) 4050 ;; symlinks.
4051 (ignore-errors
4052 (when-let ((attr (file-attributes filename)))
4053 (cond
4054 ((eq ?- (aref (file-attribute-modes attr) 0)))
4055 ((eq ?l (aref (file-attribute-modes attr) 0))
4056 (file-regular-p (file-truename filename))))))))
4051 4057
4052(defun tramp-handle-file-remote-p (filename &optional identification connected) 4058(defun tramp-handle-file-remote-p (filename &optional identification connected)
4053 "Like `file-remote-p' for Tramp files." 4059 "Like `file-remote-p' for Tramp files."
diff --git a/test/lisp/net/tramp-archive-tests.el b/test/lisp/net/tramp-archive-tests.el
index 8fe1dbd8d0b..94ef40a1116 100644
--- a/test/lisp/net/tramp-archive-tests.el
+++ b/test/lisp/net/tramp-archive-tests.el
@@ -685,6 +685,7 @@ This tests also `access-file', `file-readable-p' and `file-regular-p'."
685 ;; Symlink. 685 ;; Symlink.
686 (should (file-exists-p tmp-name2)) 686 (should (file-exists-p tmp-name2))
687 (should (file-symlink-p tmp-name2)) 687 (should (file-symlink-p tmp-name2))
688 (should (file-regular-p tmp-name2))
688 (setq attr (file-attributes tmp-name2)) 689 (setq attr (file-attributes tmp-name2))
689 (should (string-equal (car attr) (file-name-nondirectory tmp-name1))) 690 (should (string-equal (car attr) (file-name-nondirectory tmp-name1)))
690 691
@@ -775,12 +776,14 @@ This tests also `file-executable-p', `file-writable-p' and `set-file-modes'."
775 (unwind-protect 776 (unwind-protect
776 (progn 777 (progn
777 (should (file-exists-p tmp-name1)) 778 (should (file-exists-p tmp-name1))
779 (should (file-regular-p tmp-name1))
778 (should (string-equal tmp-name1 (file-truename tmp-name1))) 780 (should (string-equal tmp-name1 (file-truename tmp-name1)))
779 ;; `make-symbolic-link' is not implemented. 781 ;; `make-symbolic-link' is not implemented.
780 (should-error 782 (should-error
781 (make-symbolic-link tmp-name1 tmp-name2) 783 (make-symbolic-link tmp-name1 tmp-name2)
782 :type 'file-error) 784 :type 'file-error)
783 (should (file-symlink-p tmp-name2)) 785 (should (file-symlink-p tmp-name2))
786 (should (file-regular-p tmp-name2))
784 (should 787 (should
785 (string-equal 788 (string-equal
786 ;; This is "/foo.txt". 789 ;; This is "/foo.txt".
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 0932a53f4b1..60545e7270f 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -3513,6 +3513,9 @@ This tests also `access-file', `file-readable-p',
3513 (access-file tmp-name1 "error") 3513 (access-file tmp-name1 "error")
3514 :type 'file-missing) 3514 :type 'file-missing)
3515 3515
3516 (should-not (file-exists-p tmp-name1))
3517 (should-not (file-readable-p tmp-name1))
3518 (should-not (file-regular-p tmp-name1))
3516 ;; `file-ownership-preserved-p' should return t for 3519 ;; `file-ownership-preserved-p' should return t for
3517 ;; non-existing files. 3520 ;; non-existing files.
3518 (when test-file-ownership-preserved-p 3521 (when test-file-ownership-preserved-p
@@ -3597,7 +3600,7 @@ This tests also `access-file', `file-readable-p',
3597 (should (file-exists-p tmp-name1)) 3600 (should (file-exists-p tmp-name1))
3598 (should (file-readable-p tmp-name1)) 3601 (should (file-readable-p tmp-name1))
3599 (should-not (file-regular-p tmp-name1)) 3602 (should-not (file-regular-p tmp-name1))
3600 (should-not (access-file tmp-name1 "")) 3603 (should-not (access-file tmp-name1 "error"))
3601 (when test-file-ownership-preserved-p 3604 (when test-file-ownership-preserved-p
3602 (should (file-ownership-preserved-p tmp-name1 'group))) 3605 (should (file-ownership-preserved-p tmp-name1 'group)))
3603 (setq attr (file-attributes tmp-name1)) 3606 (setq attr (file-attributes tmp-name1))
@@ -3936,7 +3939,10 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3936 (tramp--test-ignore-make-symbolic-link-error 3939 (tramp--test-ignore-make-symbolic-link-error
3937 (write-region "foo" nil tmp-name1) 3940 (write-region "foo" nil tmp-name1)
3938 (should (file-exists-p tmp-name1)) 3941 (should (file-exists-p tmp-name1))
3942 (should (file-regular-p tmp-name1))
3939 (make-symbolic-link tmp-name1 tmp-name2) 3943 (make-symbolic-link tmp-name1 tmp-name2)
3944 (should (file-exists-p tmp-name2))
3945 (should (file-regular-p tmp-name2))
3940 (should 3946 (should
3941 (string-equal 3947 (string-equal
3942 (funcall 3948 (funcall
@@ -3987,6 +3993,8 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3987 (string-equal tmp-name1 (file-symlink-p tmp-name3)))) 3993 (string-equal tmp-name1 (file-symlink-p tmp-name3))))
3988 ;; Check directory as newname. 3994 ;; Check directory as newname.
3989 (make-directory tmp-name4) 3995 (make-directory tmp-name4)
3996 (should (file-directory-p tmp-name4))
3997 (should-not (file-regular-p tmp-name4))
3990 (when (tramp--test-expensive-test-p) 3998 (when (tramp--test-expensive-test-p)
3991 (should-error 3999 (should-error
3992 (make-symbolic-link tmp-name1 tmp-name4) 4000 (make-symbolic-link tmp-name1 tmp-name4)
@@ -4000,6 +4008,8 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4000 (file-symlink-p tmp-name5))) 4008 (file-symlink-p tmp-name5)))
4001 ;; Check, that files in symlinked directories still work. 4009 ;; Check, that files in symlinked directories still work.
4002 (make-symbolic-link tmp-name4 tmp-name6) 4010 (make-symbolic-link tmp-name4 tmp-name6)
4011 (should (file-symlink-p tmp-name6))
4012 (should-not (file-regular-p tmp-name6))
4003 (write-region "foo" nil (expand-file-name "foo" tmp-name6)) 4013 (write-region "foo" nil (expand-file-name "foo" tmp-name6))
4004 (delete-file (expand-file-name "foo" tmp-name6)) 4014 (delete-file (expand-file-name "foo" tmp-name6))
4005 (should-not (file-exists-p (expand-file-name "foo" tmp-name4))) 4015 (should-not (file-exists-p (expand-file-name "foo" tmp-name4)))
@@ -4061,9 +4071,11 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4061 (tramp--test-ignore-make-symbolic-link-error 4071 (tramp--test-ignore-make-symbolic-link-error
4062 (write-region "foo" nil tmp-name1) 4072 (write-region "foo" nil tmp-name1)
4063 (should (file-exists-p tmp-name1)) 4073 (should (file-exists-p tmp-name1))
4074 (should (file-regular-p tmp-name1))
4064 (should (string-equal tmp-name1 (file-truename tmp-name1))) 4075 (should (string-equal tmp-name1 (file-truename tmp-name1)))
4065 (make-symbolic-link tmp-name1 tmp-name2) 4076 (make-symbolic-link tmp-name1 tmp-name2)
4066 (should (file-symlink-p tmp-name2)) 4077 (should (file-symlink-p tmp-name2))
4078 (should (file-regular-p tmp-name2))
4067 (should-not (string-equal tmp-name2 (file-truename tmp-name2))) 4079 (should-not (string-equal tmp-name2 (file-truename tmp-name2)))
4068 (should 4080 (should
4069 (string-equal (file-truename tmp-name1) (file-truename tmp-name2))) 4081 (string-equal (file-truename tmp-name1) (file-truename tmp-name2)))
@@ -4073,6 +4085,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4073 (let ((default-directory ert-remote-temporary-file-directory)) 4085 (let ((default-directory ert-remote-temporary-file-directory))
4074 (make-symbolic-link (file-name-nondirectory tmp-name1) tmp-name2)) 4086 (make-symbolic-link (file-name-nondirectory tmp-name1) tmp-name2))
4075 (should (file-symlink-p tmp-name2)) 4087 (should (file-symlink-p tmp-name2))
4088 (should (file-regular-p tmp-name2))
4076 (should-not (string-equal tmp-name2 (file-truename tmp-name2))) 4089 (should-not (string-equal tmp-name2 (file-truename tmp-name2)))
4077 (should 4090 (should
4078 (string-equal (file-truename tmp-name1) (file-truename tmp-name2))) 4091 (string-equal (file-truename tmp-name1) (file-truename tmp-name2)))
@@ -4087,6 +4100,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4087 (funcall (if quoted #'file-name-unquote #'identity) penguin) 4100 (funcall (if quoted #'file-name-unquote #'identity) penguin)
4088 tmp-name2) 4101 tmp-name2)
4089 (should (file-symlink-p tmp-name2)) 4102 (should (file-symlink-p tmp-name2))
4103 (should-not (file-regular-p tmp-name2))
4090 (should 4104 (should
4091 (string-equal 4105 (string-equal
4092 (file-truename tmp-name2) 4106 (file-truename tmp-name2)
@@ -4096,6 +4110,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4096 (unless (tramp--test-windows-nt-p) 4110 (unless (tramp--test-windows-nt-p)
4097 (make-symbolic-link tmp-name1 tmp-name3) 4111 (make-symbolic-link tmp-name1 tmp-name3)
4098 (should (file-symlink-p tmp-name3)) 4112 (should (file-symlink-p tmp-name3))
4113 (should-not (file-regular-p tmp-name3))
4099 (should-not (string-equal tmp-name3 (file-truename tmp-name3))) 4114 (should-not (string-equal tmp-name3 (file-truename tmp-name3)))
4100 ;; `file-truename' returns a quoted file name for `tmp-name3'. 4115 ;; `file-truename' returns a quoted file name for `tmp-name3'.
4101 ;; We must unquote it. 4116 ;; We must unquote it.
@@ -4124,6 +4139,8 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4124 (make-symbolic-link 4139 (make-symbolic-link
4125 tmp-name3 4140 tmp-name3
4126 (setq tmp-name3 (tramp--test-make-temp-name nil quoted)))) 4141 (setq tmp-name3 (tramp--test-make-temp-name nil quoted))))
4142 (should-not (file-regular-p tmp-name2))
4143 (should-not (file-regular-p tmp-name3))
4127 (should 4144 (should
4128 (string-equal 4145 (string-equal
4129 (file-truename tmp-name2) 4146 (file-truename tmp-name2)
@@ -4154,6 +4171,8 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4154 (tramp--test-ignore-make-symbolic-link-error 4171 (tramp--test-ignore-make-symbolic-link-error
4155 (make-symbolic-link tmp-name2 tmp-name1) 4172 (make-symbolic-link tmp-name2 tmp-name1)
4156 (should (file-symlink-p tmp-name1)) 4173 (should (file-symlink-p tmp-name1))
4174 (should-not (file-regular-p tmp-name1))
4175 (should-not (file-regular-p tmp-name2))
4157 (if (tramp--test-smb-p) 4176 (if (tramp--test-smb-p)
4158 ;; The symlink command of "smbclient" detects the 4177 ;; The symlink command of "smbclient" detects the
4159 ;; cycle already. 4178 ;; cycle already.
@@ -4162,6 +4181,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4162 :type 'file-error) 4181 :type 'file-error)
4163 (make-symbolic-link tmp-name1 tmp-name2) 4182 (make-symbolic-link tmp-name1 tmp-name2)
4164 (should (file-symlink-p tmp-name2)) 4183 (should (file-symlink-p tmp-name2))
4184 (should-not (file-regular-p tmp-name2))
4165 (should-error 4185 (should-error
4166 (file-truename tmp-name1) 4186 (file-truename tmp-name1)
4167 :type 'file-error)))) 4187 :type 'file-error))))