From 4701e0663ee53f1c4b1e1e4c5fee9e597671800b Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sun, 16 Jun 2019 18:29:21 +0300 Subject: [PATCH 1/8] Improve wording of documentation of click events * doc/lispref/commands.texi (Click Events, Accessing Mouse): Improve and clarify wording. (Bug#36232) --- doc/lispref/commands.texi | 70 +++++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 33 deletions(-) diff --git a/doc/lispref/commands.texi b/doc/lispref/commands.texi index 1eb580e1e0f..ad31240beff 100644 --- a/doc/lispref/commands.texi +++ b/doc/lispref/commands.texi @@ -1395,9 +1395,9 @@ The time at which the event occurred, as an integer number of milliseconds since a system-dependent initial time. @item @var{object} -Either @code{nil} if there is no string-type text property at the -click position, or a cons cell of the form (@var{string} -. @var{string-pos}) if there is one: +Either @code{nil}, which means the click occurred on buffer text, or a +cons cell of the form @w{(@var{string} . @var{string-pos})} if there +is a string from a text property or an overlay at the click position. @table @asis @item @var{string} @@ -1428,15 +1428,15 @@ clicks on margins, @var{col} is measured from the left edge of the margin area and @var{row} is measured from the top of the margin area. @item @var{image} -This is the image object on which the click occurred. It is either -@code{nil} if there is no image at the position clicked on, or it is -an image object as returned by @code{find-image} if click was in an image. +If there is an image at the click location, this is the image object +as returned by @code{find-image} (@pxref{Defining Images}); otherwise +this is @code{nil}. @item @var{dx}, @var{dy} -These are the pixel coordinates of the click, relative to -the top left corner of @var{object}, which is @code{(0 . 0)}. If -@var{object} is @code{nil}, the coordinates are relative to the top -left corner of the character glyph clicked on. +These are the pixel coordinates of the click, relative to the top left +corner of @var{object}, which is @code{(0 . 0)}. If @var{object} is +@code{nil}, which stands for a buffer, the coordinates are relative to +the top left corner of the character glyph clicked on. @item @var{width}, @var{height} These are the pixel width and height of @var{object} or, if this is @@ -2038,8 +2038,8 @@ position such events have. @defun posnp object This function returns non-@code{nil} if @var{object} is a mouse -position list, in either of the formats documented in @ref{Click -Events}); and @code{nil} otherwise. +position list, in the format documented in @ref{Click Events}); and +@code{nil} otherwise. @end defun @cindex mouse position list, accessing @@ -2067,8 +2067,8 @@ is undefined. @defun posn-x-y position Return the pixel-based x and y coordinates in @var{position}, as a -cons cell @code{(@var{x} . @var{y})}. These coordinates are relative -to the window given by @code{posn-window}. +cons cell @w{@code{(@var{x} . @var{y})}}. These coordinates are +relative to the window given by @code{posn-window}. This example shows how to convert the window-relative coordinates in the text area of a window into frame-relative coordinates: @@ -2086,11 +2086,11 @@ POSITION is assumed to lie in a window text area." @end defun @defun posn-col-row position -This function returns a cons cell @code{(@var{col} . @var{row})}, +This function returns a cons cell @w{@code{(@var{col} . @var{row})}}, containing the estimated column and row corresponding to buffer -position in @var{position}. The return value is given in units of the -frame's default character width and default line height (including -spacing), as computed from the @var{x} and @var{y} values +position described by @var{position}. The return value is given in +units of the frame's default character width and default line height +(including spacing), as computed from the @var{x} and @var{y} values corresponding to @var{position}. (So, if the actual characters have non-default sizes, the actual row and column may differ from these computed values.) @@ -2102,7 +2102,7 @@ Lines}), it is @emph{not} included in the @var{row} count. @defun posn-actual-col-row position Return the actual row and column in @var{position}, as a cons cell -@code{(@var{col} . @var{row})}. The values are the actual row and +@w{@code{(@var{col} . @var{row})}}. The values are the actual row and column numbers in the window given by @var{position}. @xref{Click Events}, for details. The function returns @code{nil} if @var{position} does not include actual position values; in that case @@ -2115,33 +2115,37 @@ character units, use @code{posn-col-row} instead. @end defun @defun posn-string position -Return the string object in @var{position}, either @code{nil}, or a -cons cell @code{(@var{string} . @var{string-pos})}. +Return the string object described by @var{position}, either +@code{nil} (which means @var{position} describes buffer text), or a +cons cell @w{@code{(@var{string} . @var{string-pos})}}. @end defun @defun posn-image position -Return the image object in @var{position}, either @code{nil}, or an -image @code{(image ...)}. +Return the image object in @var{position}, either @code{nil} (if +there's no image at @var{position}), or an image spec @w{@code{(image +@dots{})}}. @end defun @defun posn-object position -Return the image or string object in @var{position}, either -@code{nil}, an image @code{(image ...)}, or a cons cell -@code{(@var{string} . @var{string-pos})}. +Return the image or string object described by @var{position}, either +@code{nil} (which means @var{position} describes buffer text), an +image @w{@code{(image @dots{})}}, or a cons cell +@w{@code{(@var{string} . @var{string-pos})}}. @end defun @defun posn-object-x-y position Return the pixel-based x and y coordinates relative to the upper left -corner of the object in @var{position} as a cons cell @code{(@var{dx} -. @var{dy})}. If the @var{position} is on buffer text, return the -relative position of the buffer-text character closest to that -position. +corner of the object described by @var{position}, as a cons cell +@w{@code{(@var{dx} . @var{dy})}}. If the @var{position} describes +buffer text, return the relative coordinates of the buffer-text character +closest to that position. @end defun @defun posn-object-width-height position -Return the pixel width and height of the object in @var{position} as a -cons cell @code{(@var{width} . @var{height})}. If the @var{position} -is a buffer position, return the size of the character at that position. +Return the pixel width and height of the object described by +@var{position}, as a cons cell @code{(@var{width} . @var{height})}. +If the @var{position} describes a buffer position, return the size of +the character at that position. @end defun @cindex timestamp of a mouse event From fcf6cc3177a2404eea82a5e3f4b7118e22ca5094 Mon Sep 17 00:00:00 2001 From: Juanma Barranquero Date: Sun, 16 Jun 2019 21:57:44 +0200 Subject: [PATCH 2/8] Fix problem with wdired test when symlinks cannot be created. * test/lisp/wdired-tests.el (wdired-test-symlink-name): Skip test if 'make-symbolic-link' fails for whatever reason; that's not what's being tested. --- test/lisp/wdired-tests.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/lisp/wdired-tests.el b/test/lisp/wdired-tests.el index dc67796cded..b0beb3c040c 100644 --- a/test/lisp/wdired-tests.el +++ b/test/lisp/wdired-tests.el @@ -86,7 +86,11 @@ only the name before the link arrow." (let ((buf (find-file-noselect test-dir))) (unwind-protect (with-current-buffer buf - (make-symbolic-link "./bar/baz" link-name) + (skip-unless + ;; This check is for wdired, not symbolic links, so skip + ;; it when make-symbolic-link fails for any reason (like + ;; insufficient privileges). + (ignore-errors (make-symbolic-link "./bar/baz" link-name) t)) (revert-buffer) (let* ((file-name (dired-get-filename)) (dir-part (file-name-directory file-name)) From 9d48979ca8000f4d29fdfcdfec63d3ee53024ac4 Mon Sep 17 00:00:00 2001 From: Juanma Barranquero Date: Mon, 17 Jun 2019 02:48:21 +0200 Subject: [PATCH 3/8] Fix Python tests depending on system-type * test/lisp/progmodes/python-tests.el (python-virt-bin): New function. (python-shell-calculate-exec-path-2) (python-shell-calculate-exec-path-3) (python-shell-calculate-exec-path-4) (python-shell-with-environment-1, python-shell-with-environment-2): Use it. --- test/lisp/progmodes/python-tests.el | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el index 3ce27a687da..bea44bede9e 100644 --- a/test/lisp/progmodes/python-tests.el +++ b/test/lisp/progmodes/python-tests.el @@ -134,6 +134,16 @@ default to `point-min' and `point-max' respectively." (overlay-end overlay)))) (buffer-substring-no-properties (point-min) (point-max))))) +(defun python-virt-bin (&optional virt-root) + "Return the virtualenv bin dir, starting from VIRT-ROOT. +If nil, VIRT-ROOT defaults to `python-shell-virtualenv-root'. +POSIX and Windows systems have different defauls." + (expand-file-name + (concat + (file-name-as-directory (or virt-root + python-shell-virtualenv-root)) + (if (eq system-type 'windows-nt) "Scripts" "bin")))) + ;;; Tests for your tests, so you can test while you test. @@ -2664,7 +2674,7 @@ if x: (python-shell-virtualenv-root "/env") (new-exec-path (python-shell-calculate-exec-path))) (should (equal new-exec-path - (list (expand-file-name "/env/bin") "/path0"))))) + (list (python-virt-bin) "/path0"))))) (ert-deftest python-shell-calculate-exec-path-3 () "Test complete `python-shell-virtualenv-root' modification." @@ -2673,7 +2683,7 @@ if x: (python-shell-virtualenv-root "/env") (new-exec-path (python-shell-calculate-exec-path))) (should (equal new-exec-path - (list (expand-file-name "/env/bin") + (list (python-virt-bin) "/path1" "/path2" "/path0"))))) (ert-deftest python-shell-calculate-exec-path-4 () @@ -2684,7 +2694,7 @@ if x: (python-shell-virtualenv-root "/env") (new-exec-path (python-shell-calculate-exec-path))) (should (equal new-exec-path - (list (expand-file-name "/env/bin") + (list (python-virt-bin) "/path1" "/path2" "/path0"))))) (ert-deftest python-shell-calculate-exec-path-5 () @@ -2714,7 +2724,7 @@ if x: (python-shell-virtualenv-root "/env")) (python-shell-with-environment (should (equal exec-path - (list (expand-file-name "/env/bin") + (list (python-virt-bin) "/path1" "/path2" "/path0"))) (should (not (getenv "PYTHONHOME"))) (should (string= (getenv "VIRTUAL_ENV") "/env"))) @@ -2730,7 +2740,7 @@ if x: (python-shell-virtualenv-root "/env")) (python-shell-with-environment (should (equal (python-shell-calculate-exec-path) - (list (expand-file-name "/env/bin") + (list (python-virt-bin) "/path1" "/path2" "/remote1" "/remote2"))) (let ((process-environment (python-shell-calculate-process-environment))) (should (not (getenv "PYTHONHOME"))) From 81535eeadb5b9b964dd195b2720de2b1fc432c6e Mon Sep 17 00:00:00 2001 From: Juanma Barranquero Date: Mon, 17 Jun 2019 03:12:45 +0200 Subject: [PATCH 4/8] * test/lisp/progmodes/python-tests.el (python-virt-bin): Doc fix. --- test/lisp/progmodes/python-tests.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el index bea44bede9e..a44724f1dca 100644 --- a/test/lisp/progmodes/python-tests.el +++ b/test/lisp/progmodes/python-tests.el @@ -137,7 +137,7 @@ default to `point-min' and `point-max' respectively." (defun python-virt-bin (&optional virt-root) "Return the virtualenv bin dir, starting from VIRT-ROOT. If nil, VIRT-ROOT defaults to `python-shell-virtualenv-root'. -POSIX and Windows systems have different defauls." +The name of this directory depends on `system-type'." (expand-file-name (concat (file-name-as-directory (or virt-root From 04477adedcee0d023dabc46a652f1673a2e9bd95 Mon Sep 17 00:00:00 2001 From: Robert Pluim Date: Wed, 19 Jun 2019 08:52:50 +0200 Subject: [PATCH 5/8] Check that length of data returned by sysctl is non-zero The length of the data returned by sysctl can be zero, which was not checked for. This could cause crashes, e.g. when querying non-existent processes. (Bug#36279) * src/sysdep.c (list_system_processes) [DARWIN_OS || __FreeBSD__]: (system_process_attributes) [__FreeBSD__]: (system_process_attributes) [DARWIN_OS]: * src/filelock.c (get_boot_time) [CTL_KERN && KERN_BOOTTIME]: Check for zero length data returned by sysctl. --- src/filelock.c | 2 +- src/sysdep.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/filelock.c b/src/filelock.c index 81d98f36fa4..bcd5bff563d 100644 --- a/src/filelock.c +++ b/src/filelock.c @@ -152,7 +152,7 @@ get_boot_time (void) mib[1] = KERN_BOOTTIME; size = sizeof (boottime_val); - if (sysctl (mib, 2, &boottime_val, &size, NULL, 0) >= 0) + if (sysctl (mib, 2, &boottime_val, &size, NULL, 0) >= 0 && size != 0) { boot_time = boottime_val.tv_sec; return boot_time; diff --git a/src/sysdep.c b/src/sysdep.c index 1e35e06b633..b2aecc0ddac 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -3014,11 +3014,11 @@ list_system_processes (void) Lisp_Object proclist = Qnil; - if (sysctl (mib, 3, NULL, &len, NULL, 0) != 0) + if (sysctl (mib, 3, NULL, &len, NULL, 0) != 0 || len == 0) return proclist; procs = xmalloc (len); - if (sysctl (mib, 3, procs, &len, NULL, 0) != 0) + if (sysctl (mib, 3, procs, &len, NULL, 0) != 0 || len == 0) { xfree (procs); return proclist; @@ -3618,7 +3618,7 @@ system_process_attributes (Lisp_Object pid) CONS_TO_INTEGER (pid, int, proc_id); mib[3] = proc_id; - if (sysctl (mib, 4, &proc, &proclen, NULL, 0) != 0) + if (sysctl (mib, 4, &proc, &proclen, NULL, 0) != 0 || proclen == 0) return attrs; attrs = Fcons (Fcons (Qeuid, make_fixnum_or_float (proc.ki_uid)), attrs); @@ -3740,7 +3740,7 @@ system_process_attributes (Lisp_Object pid) mib[2] = KERN_PROC_ARGS; len = MAXPATHLEN; - if (sysctl (mib, 4, args, &len, NULL, 0) == 0) + if (sysctl (mib, 4, args, &len, NULL, 0) == 0 && len != 0) { int i; for (i = 0; i < len; i++) @@ -3798,7 +3798,7 @@ system_process_attributes (Lisp_Object pid) CONS_TO_INTEGER (pid, int, proc_id); mib[3] = proc_id; - if (sysctl (mib, 4, &proc, &proclen, NULL, 0) != 0) + if (sysctl (mib, 4, &proc, &proclen, NULL, 0) != 0 || proclen == 0) return attrs; uid = proc.kp_eproc.e_ucred.cr_uid; From 572e34bb6fcbbbde2325b679fef64ee26e78ce8a Mon Sep 17 00:00:00 2001 From: Juanma Barranquero Date: Fri, 21 Jun 2019 21:41:47 +0200 Subject: [PATCH 6/8] Rename 'make-symbolic-link' argument NEWNAME to LINKNAME * src/fileio.c (Fmake_symbolic_link): Fix docstring. * doc/lispref/files.texi (Changing Files): Doc fix. --- doc/lispref/files.texi | 8 ++++---- src/fileio.c | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi index 380e0543ddd..ebe2fdd6a0c 100644 --- a/doc/lispref/files.texi +++ b/doc/lispref/files.texi @@ -1759,12 +1759,12 @@ default file permissions (see @code{set-default-file-modes} below), if SELinux context are not copied over in either case. @end deffn -@deffn Command make-symbolic-link target newname &optional ok-if-already-exists +@deffn Command make-symbolic-link target linkname &optional ok-if-already-exists @pindex ln @kindex file-already-exists This command makes a symbolic link to @var{target}, named -@var{newname}. This is like the shell command @samp{ln -s -@var{target} @var{newname}}. The @var{target} argument +@var{linkname}. This is like the shell command @samp{ln -s +@var{target} @var{linkname}}. The @var{target} argument is treated only as a string; it need not name an existing file. If @var{ok-if-already-exists} is an integer, indicating interactive use, then leading @samp{~} is expanded and leading @samp{/:} is @@ -1774,7 +1774,7 @@ If @var{target} is a relative file name, the resulting symbolic link is interpreted relative to the directory containing the symbolic link. @xref{Relative File Names}. -If both @var{target} and @var{newname} have remote file name syntax, +If both @var{target} and @var{linkname} have remote file name syntax, and if both remote identifications are equal, the symbolic link points to the local file name part of @var{target}. diff --git a/src/fileio.c b/src/fileio.c index ba7caddc978..47619c0b7cd 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -2474,13 +2474,13 @@ This is what happens in interactive use with M-x. */) DEFUN ("make-symbolic-link", Fmake_symbolic_link, Smake_symbolic_link, 2, 3, "FMake symbolic link to file: \nGMake symbolic link to file %s: \np", - doc: /* Make a symbolic link to TARGET, named NEWNAME. -If NEWNAME is a directory name, make a like-named symbolic link under -NEWNAME. + doc: /* Make a symbolic link to TARGET, named LINKNAME. +If LINKNAME is a directory name, make a like-named symbolic link under +LINKNAME. -Signal a `file-already-exists' error if a file NEWNAME already exists +Signal a `file-already-exists' error if a file LINKNAME already exists unless optional third argument OK-IF-ALREADY-EXISTS is non-nil. -An integer third arg means request confirmation if NEWNAME already +An integer third arg means request confirmation if LINKNAME already exists, and expand leading "~" or strip leading "/:" in TARGET. This happens for interactive use with M-x. */) (Lisp_Object target, Lisp_Object linkname, Lisp_Object ok_if_already_exists) From 06b35b2f922150a11d6b4b5c68a40e9957a69e52 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Tue, 25 Jun 2019 18:57:30 -0400 Subject: [PATCH 7/8] ; * lisp/frame.el: Enhance add-variable-watcher commentary. --- lisp/frame.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lisp/frame.el b/lisp/frame.el index 30f6ca91ba6..6dc72669685 100644 --- a/lisp/frame.el +++ b/lisp/frame.el @@ -2489,7 +2489,9 @@ See also `toggle-frame-maximized'." (mapc (lambda (var) ;; Using symbol-function here tells the watcher machinery to ;; call the C function set-buffer-redisplay directly, thus - ;; avoiding a potential GC. + ;; avoiding a potential GC. This isn't strictly necessary, + ;; but it's a nice way to exercise the direct subr-calling + ;; machinery. (add-variable-watcher var (symbol-function 'set-buffer-redisplay))) '(line-spacing overline-margin From e62ad04963982ea9cc7622b32484778845bc2ec1 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sun, 23 Jun 2019 21:27:43 -0400 Subject: [PATCH 8/8] Fix sgml-mode handling of quotes within parens (Bug#36347) * lisp/textmodes/sgml-mode.el (sgml-syntax-propertize): Use syntax-ppss-table if set. This is only needed on the release branch, on master the caller (syntax-propertize) already does this. (sgml-mode): Set syntax-ppss-table to sgml-tag-syntax-table. This correctly classifies parens as punctuation, so they won't confuse the parser. * test/lisp/textmodes/sgml-mode-tests.el (sgml-tests--quotes-syntax): New test copied from master, with two cases added for this bug. --- lisp/textmodes/sgml-mode.el | 10 ++++++---- test/lisp/textmodes/sgml-mode-tests.el | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index 128e58810e5..c9724e0e3f7 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -357,10 +357,11 @@ Any terminating `>' or `/' is not matched.") (defun sgml-syntax-propertize (start end) "Syntactic keywords for `sgml-mode'." (goto-char start) - (sgml-syntax-propertize-inside end) - (funcall - (syntax-propertize-rules sgml-syntax-propertize-rules) - start end)) + (with-syntax-table (or syntax-ppss-table (syntax-table)) + (sgml-syntax-propertize-inside end) + (funcall + (syntax-propertize-rules sgml-syntax-propertize-rules) + start end))) (defun sgml-syntax-propertize-inside (end) (let ((ppss (syntax-ppss))) @@ -568,6 +569,7 @@ Do \\[describe-key] on the following bindings to discover what they do. sgml-font-lock-keywords-2) nil t)) (setq-local syntax-propertize-function #'sgml-syntax-propertize) + (setq-local syntax-ppss-table sgml-tag-syntax-table) (setq-local facemenu-add-face-function 'sgml-mode-facemenu-add-face-function) (setq-local sgml-xml-mode (sgml-xml-guess)) (unless sgml-xml-mode diff --git a/test/lisp/textmodes/sgml-mode-tests.el b/test/lisp/textmodes/sgml-mode-tests.el index 7318a667b36..0000b352ff0 100644 --- a/test/lisp/textmodes/sgml-mode-tests.el +++ b/test/lisp/textmodes/sgml-mode-tests.el @@ -130,5 +130,27 @@ The point is set to the beginning of the buffer." (sgml-delete-tag 1) (should (string= "Winter is comin'" (buffer-string))))) +(ert-deftest sgml-tests--quotes-syntax () + (dolist (str '("a\"b c'd" + "a'b c\"d" + "\"a'" + "'a\"" + "\"a'\"" + "'a\"'" + "a\"b c'd" + ;;"c>'d" Fixed in master. + "" + "" + "(')" + "(\")" + )) + (with-temp-buffer + (sgml-mode) + (insert str) + (ert-info ((format "%S" str) :prefix "Test case: ") + ;; Check that last tag is parsed as a tag. + (should (= 1 (car (syntax-ppss (1- (point-max)))))) + (should (= 0 (car (syntax-ppss (point-max))))))))) + (provide 'sgml-mode-tests) ;;; sgml-mode-tests.el ends here