From b7ad0b40148bd5905497a4c05fced4e0b9099812 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Mon, 2 Jan 2023 13:52:25 +0200 Subject: [PATCH 01/18] ; Clarify doc strings of 'call-process' and 'call-process-region' * src/callproc.c (Fcall_process, Fcall_process_region): Document that the destination buffer can be specified by its name. (Bug#60477) --- src/callproc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/callproc.c b/src/callproc.c index 7208ceb5d2f..5e1e1a8cc0a 100644 --- a/src/callproc.c +++ b/src/callproc.c @@ -259,8 +259,8 @@ input come from an Emacs buffer, use `call-process-region' instead. Third argument DESTINATION specifies how to handle program's output. (\"Output\" here means both standard output and standard error output.) -If DESTINATION is a buffer, or t that stands for the current buffer, - it means insert output in that buffer before point. +If DESTINATION is a buffer or the name of a buffer, or t (which stands for +the current buffer), it means insert output in that buffer before point. If DESTINATION is nil, it means discard output; 0 means discard and don't wait for the program to terminate. If DESTINATION is `(:file FILE)', where FILE is a file name string, @@ -1055,6 +1055,7 @@ Insert output in BUFFER before point; t means current buffer; nil for BUFFER means discard it; 0 means discard and don't wait; and `(:file FILE)', where FILE is a file name string, means that it should be written to that file (if the file already exists it is overwritten). +BUFFER can be a string which is the name of a buffer. BUFFER can also have the form (REAL-BUFFER STDERR-FILE); in that case, REAL-BUFFER says what to do with standard output, as above, while STDERR-FILE says what to do with standard error in the child. From ff35ac9dfabf7ac33199c42bc56c8bb0f53eebc4 Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Thu, 29 Dec 2022 06:43:19 -0800 Subject: [PATCH 02/18] Fix default-port regression in erc-select-read-args * lisp/erc/erc.el (erc--warn-unencrypted): New function, likely temporary, to warn new users connecting interactively to the default server, "irc.libara.chat", via the default non-TLS port, 6667. (erc-select-read-args): Remove stray code from incomplete feature introduced by bug#56514. Ensure connecting always works with default port, which is non-TLS. Respect `erc-prompt-for-password' when user pastes URL containing password component into "server" prompt. Maybe add `erc--warn-unencrypted' as one-off hook for impending connection. * test/lisp/erc/erc-tests.el (erc-select-read-args): Always expect password prompt and sometimes a non-TLS port when `erc' called interactively. (Bug#60428.) --- lisp/erc/erc.el | 38 +++++++++++++++++++++++++++++--------- test/lisp/erc/erc-tests.el | 6 +++--- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index fe1201dd3a8..6315d5aa482 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -2161,6 +2161,23 @@ parameters SERVER and NICK." (setq input (concat "irc://" input))) input) +;; A temporary means of addressing the problem of ERC's namesake entry +;; point defaulting to a non-TLS connection with its default server +;; (bug#60428). +(defun erc--warn-unencrypted () + ;; Remove unconditionally to avoid wrong context due to races from + ;; simultaneous dialing or aborting (e.g., via `keybaord-quit'). + (remove-hook 'erc--server-post-connect-hook #'erc--warn-unencrypted) + (when (and (process-contact erc-server-process :nowait) + (equal erc-session-server erc-default-server) + (eql erc-session-port erc-default-port)) + ;; FIXME use the autoloaded `info' instead of `Info-goto-node' in + ;; `erc-button-alist'. + (require 'info nil t) + (erc-display-error-notice + nil (concat "This connection is unencrypted. Please use `erc-tls'" + " from now on. See Info:\"(erc) connecting\" for more.")))) + ;;;###autoload (defun erc-select-read-args () "Prompt the user for values of nick, server, port, and password." @@ -2171,10 +2188,7 @@ parameters SERVER and NICK." ;; For legacy reasons, also accept a URL without a scheme. (url (url-generic-parse-url (erc--ensure-url input))) (server (url-host url)) - (sp (and (or (string-suffix-p "s" (url-type url)) - (and (equal server erc-default-server) - (not (string-prefix-p "irc://" input)))) - 'ircs-u)) + (sp (and (string-suffix-p "s" (url-type url)) erc-default-port-tls)) (port (or (url-portspec url) (erc-compute-port (let ((d (erc-compute-port sp))) ; may be a string @@ -2187,13 +2201,19 @@ parameters SERVER and NICK." (let ((d (erc-compute-nick))) (read-string (format "Nickname (default is %S): " d) nil 'erc-nick-history-list d)))) - (passwd (or (url-password url) - (if erc-prompt-for-password - (read-passwd "Server password (optional): ") - (with-suppressed-warnings ((obsolete erc-password)) - erc-password))))) + (passwd (let* ((p (with-suppressed-warnings ((obsolete erc-password)) + (or (url-password url) erc-password))) + (m (if p + (format "Server password (default is %S): " p) + "Server password (optional): "))) + (if erc-prompt-for-password (read-passwd m nil p) p)))) (when (and passwd (string= "" passwd)) (setq passwd nil)) + (when (and (equal server erc-default-server) + (eql port erc-default-port) + (not (eql port erc-default-port-tls)) ; not `erc-tls' + (not (string-prefix-p "irc://" input))) ; not yanked URL + (add-hook 'erc--server-post-connect-hook #'erc--warn-unencrypted)) (list :server server :port port :nick nick :password passwd))) ;;;###autoload diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el index 6807b24bfc6..85506c3d27e 100644 --- a/test/lisp/erc/erc-tests.el +++ b/test/lisp/erc/erc-tests.el @@ -1001,11 +1001,11 @@ (ert-deftest erc-select-read-args () - (ert-info ("Defaults to TLS") + (ert-info ("Does not default to TLS") (should (equal (ert-simulate-keys "\r\r\r\r" (erc-select-read-args)) (list :server "irc.libera.chat" - :port 6697 + :port 6667 :nick (user-login-name) :password nil)))) @@ -1036,7 +1036,7 @@ :password nil)))) (ert-info ("Address includes nick and password") - (should (equal (ert-simulate-keys "nick:sesame@localhost:6667\r" + (should (equal (ert-simulate-keys "nick:sesame@localhost:6667\r\r" (erc-select-read-args)) (list :server "localhost" :port 6667 From 9599b054316db2e727e505fd9770f5a9faf173be Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Mon, 2 Jan 2023 14:58:37 +0100 Subject: [PATCH 03/18] ; Skip ruby-ts tests if grammar is not available * test/lisp/progmodes/ruby-ts-mode-tests.el: Properly skip tests if there is no grammar for ruby. --- test/lisp/progmodes/ruby-ts-mode-tests.el | 24 +++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/test/lisp/progmodes/ruby-ts-mode-tests.el b/test/lisp/progmodes/ruby-ts-mode-tests.el index f48d0bf6330..aa1ab1e2605 100644 --- a/test/lisp/progmodes/ruby-ts-mode-tests.el +++ b/test/lisp/progmodes/ruby-ts-mode-tests.el @@ -44,7 +44,7 @@ The whitespace before and including \"|\" on each line is removed." (apply 'format (replace-regexp-in-string "^[ \t]*|" "" s) args)) (ert-deftest ruby-ts-indent-simple () - (skip-unless (treesit-available-p)) + (skip-unless (treesit-ready-p 'ruby t)) (ruby-ts-should-indent-buffer "if foo | bar @@ -58,7 +58,7 @@ The whitespace before and including \"|\" on each line is removed." |")) (ert-deftest ruby-ts-align-to-stmt-keywords-t () - (skip-unless (treesit-available-p)) + (skip-unless (treesit-ready-p 'ruby t)) (let ((ruby-align-to-stmt-keywords t)) (ruby-ts-should-indent-buffer "foo = if bar? @@ -94,7 +94,7 @@ The whitespace before and including \"|\" on each line is removed." )) (ert-deftest ruby-ts-align-to-stmt-keywords-case () - (skip-unless (treesit-available-p)) + (skip-unless (treesit-ready-p 'ruby t)) (let ((ruby-align-to-stmt-keywords '(case))) (ruby-ts-should-indent-buffer "b = case a @@ -111,7 +111,7 @@ The whitespace before and including \"|\" on each line is removed." | end"))) (ert-deftest ruby-ts-add-log-current-method-examples () - (skip-unless (treesit-available-p)) + (skip-unless (treesit-ready-p 'ruby t)) (let ((pairs '(("foo" . "#foo") ("C.foo" . ".foo") ("self.foo" . ".foo") @@ -134,7 +134,7 @@ The whitespace before and including \"|\" on each line is removed." (format "M::C%s" value)))))))) (ert-deftest ruby-ts-add-log-current-method-outside-of-method () - (skip-unless (treesit-available-p)) + (skip-unless (treesit-ready-p 'ruby t)) (ruby-ts-with-temp-buffer (ruby-ts-test-string "module M | class C @@ -147,7 +147,7 @@ The whitespace before and including \"|\" on each line is removed." (should (string= (ruby-ts-add-log-current-function) "M::C")))) (ert-deftest ruby-ts-add-log-current-method-in-singleton-class () - (skip-unless (treesit-available-p)) + (skip-unless (treesit-ready-p 'ruby t)) (ruby-ts-with-temp-buffer (ruby-ts-test-string "class C | class << self @@ -160,7 +160,7 @@ The whitespace before and including \"|\" on each line is removed." (should (string= (ruby-ts-add-log-current-function) "C.foo")))) (ert-deftest ruby-ts-add-log-current-method-namespace-shorthand () - (skip-unless (treesit-available-p)) + (skip-unless (treesit-ready-p 'ruby t)) (ruby-ts-with-temp-buffer (ruby-ts-test-string "class C::D | def foo @@ -171,7 +171,7 @@ The whitespace before and including \"|\" on each line is removed." (should (string= (ruby-ts-add-log-current-function) "C::D#foo")))) (ert-deftest ruby-ts-add-log-current-method-after-inner-class () - (skip-unless (treesit-available-p)) + (skip-unless (treesit-ready-p 'ruby t)) (ruby-ts-with-temp-buffer (ruby-ts-test-string "module M | class C @@ -186,7 +186,7 @@ The whitespace before and including \"|\" on each line is removed." (should (string= (ruby-ts-add-log-current-function) "M::C#foo")))) (ert-deftest ruby-ts-add-log-current-method-after-inner-class-outside-methods () - (skip-unless (treesit-available-p)) + (skip-unless (treesit-ready-p 'ruby t)) (ruby-ts-with-temp-buffer (ruby-ts-test-string "module M | class C @@ -201,7 +201,7 @@ The whitespace before and including \"|\" on each line is removed." (should (string= (ruby-ts-add-log-current-function) "M::C")))) (ert-deftest ruby-ts-add-log-current-method-after-inner-class-outside-methods-with-text () - (skip-unless (treesit-available-p)) + (skip-unless (treesit-ready-p 'ruby t)) (ruby-ts-with-temp-buffer (ruby-ts-test-string "module M | class C @@ -215,7 +215,7 @@ The whitespace before and including \"|\" on each line is removed." (should (string= (ruby-ts-add-log-current-function) "M::C")))) (ert-deftest ruby-ts-add-log-current-method-after-endless-method () - (skip-unless (treesit-available-p)) + (skip-unless (treesit-ready-p 'ruby t)) (ruby-ts-with-temp-buffer (ruby-ts-test-string "module M | class C @@ -237,7 +237,7 @@ The whitespace before and including \"|\" on each line is removed." (defmacro ruby-ts-deftest-indent (file) `(ert-deftest ,(intern (format "ruby-ts-indent-test/%s" file)) () ;; :tags '(:expensive-test) - (skip-unless (treesit-available-p)) + (skip-unless (treesit-ready-p 'ruby t)) (let ((buf (find-file-noselect (ruby-ts-resource-file ,file)))) (unwind-protect (with-current-buffer buf From 3f7ea621b9008bc507048ee23466f3259b6b620d Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Mon, 2 Jan 2023 15:17:59 +0100 Subject: [PATCH 04/18] ; Fix typos in ruby-ts-mode.el --- lisp/progmodes/ruby-ts-mode.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el index 5c9a25c1fde..26d0fc49260 100644 --- a/lisp/progmodes/ruby-ts-mode.el +++ b/lisp/progmodes/ruby-ts-mode.el @@ -23,7 +23,7 @@ ;;; Commentary: -;; This file defines ruby-ts-mode which is a major mode for editting +;; This file defines ruby-ts-mode which is a major mode for editing ;; Ruby files that uses Tree Sitter to parse the language. More ;; information about Tree Sitter can be found in the ELisp Info pages ;; as well as this website: https://tree-sitter.github.io/tree-sitter/ @@ -150,7 +150,7 @@ These are currently unused") "parenthesized_statements" "interpolation") string-end) - "Regular expression of the nodes that can constain statements.") + "Regular expression of the nodes that can contain statements.") (defun ruby-ts--lineno (node) "Return line number of NODE's start." @@ -178,7 +178,7 @@ These are currently unused") Applies `font-lock-comment-delimiter-face' and `font-lock-comment-face' See `treesit-fontify-with-override' for values of OVERRIDE" - ;; Emperically it appears as if (treesit-node-start node) will be + ;; Empirically it appears as if (treesit-node-start node) will be ;; where the # character is at and (treesit-node-end node) will be ;; the end of the line (let* ((node-start (treesit-node-start node)) @@ -717,7 +717,7 @@ i.e. expr of def foo(args) = expr is returned." ((n-p-gp ,ruby-ts--method-regex "body_statement" ,ruby-ts--class-or-module-regex) (ruby-ts--bol ruby-ts--grand-parent-node) ruby-indent-level) - ;; Match the end of a class / modlue + ;; Match the end of a class / module ((match "end" ,ruby-ts--class-or-module-regex) parent 0) ;; A "do_block" has a "body_statement" child which has the From d26b523886ee52548648ca660fc2933eadf49a55 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Mon, 2 Jan 2023 17:02:05 +0200 Subject: [PATCH 05/18] Fix shrinking of the tab-bar * src/haikufns.c (haiku_change_tab_bar_height): * src/pgtkfns.c (pgtk_change_tab_bar_height): * src/nsfns.m (ns_change_tab_bar_height): * src/w32fns.c (w32_change_tab_bar_height): * src/xfns.c (x_change_tab_bar_height): Don't let the number of tab-bar lines degenerate to zero due to integer division. (Bug#60210) --- src/haikufns.c | 14 +++++++------- src/nsfns.m | 14 +++++++------- src/pgtkfns.c | 14 +++++++------- src/w32fns.c | 14 +++++++------- src/xfns.c | 14 +++++++------- 5 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/haikufns.c b/src/haikufns.c index 59332346dab..b591c143900 100644 --- a/src/haikufns.c +++ b/src/haikufns.c @@ -175,19 +175,17 @@ haiku_change_tool_bar_height (struct frame *f, int height) void haiku_change_tab_bar_height (struct frame *f, int height) { - int unit, old_height, lines; - Lisp_Object fullscreen; - - unit = FRAME_LINE_HEIGHT (f); - old_height = FRAME_TAB_BAR_HEIGHT (f); - fullscreen = get_frame_param (f, Qfullscreen); + int unit = FRAME_LINE_HEIGHT (f); + int old_height = FRAME_TAB_BAR_HEIGHT (f); /* This differs from the tool bar code in that the tab bar height is not rounded up. Otherwise, if redisplay_tab_bar decides to grow the tab bar by even 1 pixel, FRAME_TAB_BAR_LINES will be changed, leading to the tab bar height being incorrectly set upon the next call to x_set_font. (bug#59285) */ - lines = height / unit; + int lines = height / unit; + if (lines == 0 && height != 0) + lines = 1; /* Make sure we redisplay all windows in this frame. */ fset_redisplay (f); @@ -208,6 +206,8 @@ haiku_change_tab_bar_height (struct frame *f, int height) if (!f->tab_bar_resized) { + Lisp_Object fullscreen = get_frame_param (f, Qfullscreen); + /* As long as tab_bar_resized is false, effectively try to change F's native height. */ if (NILP (fullscreen) || EQ (fullscreen, Qfullwidth)) diff --git a/src/nsfns.m b/src/nsfns.m index 8c78657db50..8804a7df7cf 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -632,19 +632,17 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side. void ns_change_tab_bar_height (struct frame *f, int height) { - int unit, old_height, lines; - Lisp_Object fullscreen; - - unit = FRAME_LINE_HEIGHT (f); - old_height = FRAME_TAB_BAR_HEIGHT (f); - fullscreen = get_frame_param (f, Qfullscreen); + int unit = FRAME_LINE_HEIGHT (f); + int old_height = FRAME_TAB_BAR_HEIGHT (f); /* This differs from the tool bar code in that the tab bar height is not rounded up. Otherwise, if redisplay_tab_bar decides to grow the tab bar by even 1 pixel, FRAME_TAB_BAR_LINES will be changed, leading to the tab bar height being incorrectly set upon the next call to x_set_font. (bug#59285) */ - lines = height / unit; + int lines = height / unit; + if (lines == 0 && height != 0) + lines = 1; /* Make sure we redisplay all windows in this frame. */ fset_redisplay (f); @@ -665,6 +663,8 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side. if (!f->tab_bar_resized) { + Lisp_Object fullscreen = get_frame_param (f, Qfullscreen); + /* As long as tab_bar_resized is false, effectively try to change F's native height. */ if (NILP (fullscreen) || EQ (fullscreen, Qfullwidth)) diff --git a/src/pgtkfns.c b/src/pgtkfns.c index 57591d2693c..6b3a0459d36 100644 --- a/src/pgtkfns.c +++ b/src/pgtkfns.c @@ -473,19 +473,17 @@ pgtk_set_tab_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval) void pgtk_change_tab_bar_height (struct frame *f, int height) { - int unit, old_height, lines; - Lisp_Object fullscreen; - - unit = FRAME_LINE_HEIGHT (f); - old_height = FRAME_TAB_BAR_HEIGHT (f); - fullscreen = get_frame_param (f, Qfullscreen); + int unit = FRAME_LINE_HEIGHT (f); + int old_height = FRAME_TAB_BAR_HEIGHT (f); /* This differs from the tool bar code in that the tab bar height is not rounded up. Otherwise, if redisplay_tab_bar decides to grow the tab bar by even 1 pixel, FRAME_TAB_BAR_LINES will be changed, leading to the tab bar height being incorrectly set upon the next call to x_set_font. (bug#59285) */ - lines = height / unit; + int lines = height / unit; + if (lines == 0 && height != 0) + lines = 1; /* Make sure we redisplay all windows in this frame. */ fset_redisplay (f); @@ -506,6 +504,8 @@ pgtk_change_tab_bar_height (struct frame *f, int height) if (!f->tab_bar_resized) { + Lisp_Object fullscreen = get_frame_param (f, Qfullscreen); + /* As long as tab_bar_resized is false, effectively try to change F's native height. */ if (NILP (fullscreen) || EQ (fullscreen, Qfullwidth)) diff --git a/src/w32fns.c b/src/w32fns.c index 9d02e680fe8..192d3ddf27a 100644 --- a/src/w32fns.c +++ b/src/w32fns.c @@ -1717,19 +1717,17 @@ w32_set_tab_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval) void w32_change_tab_bar_height (struct frame *f, int height) { - int unit, old_height, lines; - Lisp_Object fullscreen; - - unit = FRAME_LINE_HEIGHT (f); - old_height = FRAME_TAB_BAR_HEIGHT (f); - fullscreen = get_frame_param (f, Qfullscreen); + int unit = FRAME_LINE_HEIGHT (f); + int old_height = FRAME_TAB_BAR_HEIGHT (f); /* This differs from the tool bar code in that the tab bar height is not rounded up. Otherwise, if redisplay_tab_bar decides to grow the tab bar by even 1 pixel, FRAME_TAB_BAR_LINES will be changed, leading to the tab bar height being incorrectly set upon the next call to x_set_font. (bug#59285) */ - lines = height / unit; + int lines = height / unit; + if (lines == 0 && height != 0) + lines = 1; /* Make sure we redisplay all windows in this frame. */ fset_redisplay (f); @@ -1758,6 +1756,8 @@ w32_change_tab_bar_height (struct frame *f, int height) if (!f->tab_bar_resized) { + Lisp_Object fullscreen = get_frame_param (f, Qfullscreen); + /* As long as tab_bar_resized is false, effectively try to change F's native height. */ if (NILP (fullscreen) || EQ (fullscreen, Qfullwidth)) diff --git a/src/xfns.c b/src/xfns.c index a1984f9e8f8..528ae61ca32 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -1758,19 +1758,17 @@ x_set_tab_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval) void x_change_tab_bar_height (struct frame *f, int height) { - int unit, old_height, lines; - Lisp_Object fullscreen; - - unit = FRAME_LINE_HEIGHT (f); - old_height = FRAME_TAB_BAR_HEIGHT (f); - fullscreen = get_frame_param (f, Qfullscreen); + int unit = FRAME_LINE_HEIGHT (f); + int old_height = FRAME_TAB_BAR_HEIGHT (f); /* This differs from the tool bar code in that the tab bar height is not rounded up. Otherwise, if redisplay_tab_bar decides to grow the tab bar by even 1 pixel, FRAME_TAB_BAR_LINES will be changed, leading to the tab bar height being incorrectly set upon the next call to x_set_font. (bug#59285) */ - lines = height / unit; + int lines = height / unit; + if (lines == 0 && height != 0) + lines = 1; /* Make sure we redisplay all windows in this frame. */ fset_redisplay (f); @@ -1791,6 +1789,8 @@ x_change_tab_bar_height (struct frame *f, int height) if (!f->tab_bar_resized) { + Lisp_Object fullscreen = get_frame_param (f, Qfullscreen); + /* As long as tab_bar_resized is false, effectively try to change F's native height. */ if (NILP (fullscreen) || EQ (fullscreen, Qfullwidth)) From a86a213e1ac6439557703ab6a3a1294160ffcdc2 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Mon, 2 Jan 2023 19:59:50 +0200 Subject: [PATCH 06/18] js-ts-mode: Move 'string-interpolation' to font-lock level 3 * lisp/progmodes/js.el (js-ts-mode): Move 'string-interpolation' to font-lock level 3. --- lisp/progmodes/js.el | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 501c0599e89..c5fdecae71b 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3817,9 +3817,8 @@ Currently there are `js-mode' and `js-ts-mode'." '(( comment definition) ( keyword string) ( assignment constant escape-sequence jsx number - pattern) - ( bracket delimiter function operator property - string-interpolation))) + pattern string-interpolation) + ( bracket delimiter function operator property))) ;; Imenu (setq-local treesit-simple-imenu-settings `(("Function" "\\`function_declaration\\'" nil nil) From f8f5202487c0909a253228e63a64ba17d9c459da Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Mon, 2 Jan 2023 20:42:52 +0200 Subject: [PATCH 07/18] (typescript/tsx-ts-mode): Split font-lock feature list into 4 values * lisp/progmodes/typescript-ts-mode.el (typescript-ts-mode) (tsx-ts-mode): Split font-lock feature list into 4 values. --- lisp/progmodes/typescript-ts-mode.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el index d3266134500..a0ba425b3e9 100644 --- a/lisp/progmodes/typescript-ts-mode.el +++ b/lisp/progmodes/typescript-ts-mode.el @@ -374,7 +374,8 @@ Argument LANGUAGE is either `typescript' or `tsx'." (setq-local treesit-font-lock-settings (typescript-ts-mode--font-lock-settings 'typescript)) (setq-local treesit-font-lock-feature-list - '((comment declaration keyword string escape-sequence) + '((comment declaration) + (keyword string escape-sequence) (constant expression identifier number pattern property) (bracket delimiter))) @@ -408,7 +409,8 @@ Argument LANGUAGE is either `typescript' or `tsx'." (setq-local treesit-font-lock-settings (typescript-ts-mode--font-lock-settings 'tsx)) (setq-local treesit-font-lock-feature-list - '((comment declaration keyword string escape-sequence) + '((comment declaration) + (keyword string escape-sequence) (constant expression identifier jsx number pattern property) (bracket delimiter))) From 809fbb0e8c419d670b045f506e90614ad00fda55 Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Mon, 2 Jan 2023 19:50:07 +0100 Subject: [PATCH 08/18] ; Update copyright notice in tramp-sh.el * lisp/net/tramp-sh.el (tramp-perl-encode, tramp-perl-decode): Remove copyright notice, Tramp is copyrighted by FSF anyway. --- lisp/net/tramp-sh.el | 2 -- 1 file changed, 2 deletions(-) diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 97867bf9999..ec8437176db 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -838,7 +838,6 @@ characters need to be doubled.") (defconst tramp-perl-encode "%p -e ' # This script contributed by Juanma Barranquero . -# Copyright (C) 2002-2022 Free Software Foundation, Inc. use strict; my %%trans = do { @@ -877,7 +876,6 @@ characters need to be doubled.") (defconst tramp-perl-decode "%p -e ' # This script contributed by Juanma Barranquero . -# Copyright (C) 2002-2022 Free Software Foundation, Inc. use strict; my %%trans = do { From aab8ddca5e1bbbca0ab3d2241c34ccde7ebd6e1e Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Mon, 2 Jan 2023 20:56:52 +0200 Subject: [PATCH 09/18] ; nt/INSTALL: Update for Emacs 29. --- nt/INSTALL | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/nt/INSTALL b/nt/INSTALL index 2d973816e37..3b465ba494c 100644 --- a/nt/INSTALL +++ b/nt/INSTALL @@ -7,7 +7,7 @@ The MSYS/MinGW build described here is supported on versions of Windows starting with Windows XP and newer. Building on Windows 2000 and Windows 9X is not supported (but the Emacs binary produced by this -build will run on Windows 9X and newer systems). +build should run on Windows 9X and newer systems). Do not use this recipe with Cygwin. For building on Cygwin, use the normal installation instructions, ../INSTALL. @@ -87,7 +87,7 @@ build will run on Windows 9X and newer systems). Git for Windows is available from this download page: - https://github.com/git-for-windows/git/releases + https://gitforwindows.org/ That page offers both 32-bit and 64-bit installations; pick the one suitable for your OS. In general, we recommend to install a 64-bit @@ -139,7 +139,7 @@ build will run on Windows 9X and newer systems). like to mess with manual installations. You can download it from here: - https://sourceforge.net/projects/mingw/files/Installer/mingw-get/ + https://osdn.net/projects/mingw/releases (This installer only supports packages downloaded from the MinGW site; for the rest you will still need the manual method.) @@ -203,13 +203,13 @@ build will run on Windows 9X and newer systems). MinGW runtime and Windows API distributions, to compile Emacs. You can find these on the MinGW download/Base page: - https://sourceforge.net/projects/mingw/files/MinGW/Base/ + https://osdn.net/projects/mingw/releases In general, install the latest stable versions of the following MinGW packages from that page: gcc, binutils, mingw-rt, w32api. You only need the 'bin' and the 'dll' tarballs of each of the above. - MinGW packages are distributed as .tar.lzma compressed archives. To + MinGW packages are distributed as .tar.xz compressed archives. To install the packages manually, we recommend to use the Windows port of the 'bsdtar' program to unpack the tarballs. 'bsdtar' is available as part of the 'libarchive' package from here: @@ -598,8 +598,7 @@ build will run on Windows 9X and newer systems). * Optional image library support In addition to its "native" image formats (pbm and xbm), Emacs can - handle other image types: xpm, tiff, gif, png, jpeg, webp and - experimental support for svg. + handle other image types: xpm, tiff, gif, png, jpeg, webp and svg. To build Emacs with support for them, the corresponding headers must be in the include path and libraries should be where the linker @@ -846,6 +845,20 @@ build will run on Windows 9X and newer systems). from the MSYS2 project. If HarfBuzz is not available, Emacs will use the Uniscribe shaping engine that is part of MS-Windows. +* Optional support for accessing SQLite databases + + Emacs can support built-in access to SQLite databases, if compiled + with the sqlite3 library. Prebuilt 32-bit binaries of that library + are available from the ezwinports site. + +* Optional support for tree-sitter + + Emacs can be built with the tree-sitter incremental parsing library, + which enables editing of program sources written in various + programming languages based on the tree-sitter parsers. Prebuilt + 32-bit binaries of the tree-sitter library DLL and of several + language grammar libraries are available from the ezwinports site. + This file is part of GNU Emacs. From 4ef12cfb1fc3f08fc17f0ed622ddfcb1d26cefc8 Mon Sep 17 00:00:00 2001 From: Yuan Fu Date: Mon, 2 Jan 2023 14:15:05 -0800 Subject: [PATCH 10/18] ; Fix tree-sitter manual title case * doc/lispref/elisp.texi: * doc/lispref/modes.texi: * doc/lispref/parsing.texi: Change to title case. --- doc/lispref/elisp.texi | 2 +- doc/lispref/modes.texi | 4 ++-- doc/lispref/parsing.texi | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/lispref/elisp.texi b/doc/lispref/elisp.texi index fd06409fd59..c7dc330441f 100644 --- a/doc/lispref/elisp.texi +++ b/doc/lispref/elisp.texi @@ -1370,7 +1370,7 @@ Parsing Program Source * Accessing Node Information:: Accessing node information. * Pattern Matching:: Pattern matching with query patterns. * Multiple Languages:: Parse text written in multiple languages. -* Tree-sitter major modes:: Develop major modes using tree-sitter. +* Tree-sitter Major Modes:: Develop major modes using tree-sitter. * Tree-sitter C API:: Compare the C API and the ELisp API. Syntax Descriptors diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi index 9cd20532de6..dffd6653369 100644 --- a/doc/lispref/modes.texi +++ b/doc/lispref/modes.texi @@ -2863,10 +2863,10 @@ matched by @var{regexp} and @var{pred} are not grouped under @var{name-fn} should be either @var{nil} or a function that takes a defun node and returns the name of that defun, e.g., the function name for a function definition. If @var{name-fn} is @var{nil}, -@code{treesit-defun-name} (@pxref{Tree-sitter major modes}) is used +@code{treesit-defun-name} (@pxref{Tree-sitter Major Modes}) is used instead. -@code{treesit-major-mode-setup} (@pxref{Tree-sitter major modes}) +@code{treesit-major-mode-setup} (@pxref{Tree-sitter Major Modes}) automatically sets up Imenu if this variable is non-@code{nil}. @end defvar diff --git a/doc/lispref/parsing.texi b/doc/lispref/parsing.texi index 1ed59526a61..19a22c121de 100644 --- a/doc/lispref/parsing.texi +++ b/doc/lispref/parsing.texi @@ -45,7 +45,7 @@ source files that mix multiple programming languages. * Accessing Node Information:: Accessing node information. * Pattern Matching:: Pattern matching with query patterns. * Multiple Languages:: Parse text written in multiple languages. -* Tree-sitter major modes:: Develop major modes using tree-sitter. +* Tree-sitter Major Modes:: Develop major modes using tree-sitter. * Tree-sitter C API:: Compare the C API and the ELisp API. @end menu @@ -1675,7 +1675,7 @@ language of the buffer text at @var{pos}. This variable is used by @code{treesit-language-at}. @end defvar -@node Tree-sitter major modes +@node Tree-sitter Major Modes @section Developing major modes with tree-sitter @cindex major mode, developing with tree-sitter From aef869e74f47bbe00c8cf0cb02cea20aa0c33a6d Mon Sep 17 00:00:00 2001 From: Yuan Fu Date: Mon, 2 Jan 2023 14:15:36 -0800 Subject: [PATCH 11/18] ; Update tree-sitter manual * doc/lispref/positions.texi (List Motion): Replace treesit-defun-prefer-top-level with treesit-defun-tactic. --- doc/lispref/positions.texi | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/doc/lispref/positions.texi b/doc/lispref/positions.texi index 68e948bacd8..f47720184a3 100644 --- a/doc/lispref/positions.texi +++ b/doc/lispref/positions.texi @@ -848,25 +848,14 @@ The value of this variable is a regexp matching the node type of defun nodes. (For ``node'' and ``node type'', @pxref{Parsing Program Source}.) For example, @code{python-mode} sets this variable to a regexp that -matches either @code{function_definition} or @code{class_definition}. +matches either @code{"function_definition"} or @code{"class_definition"}. @end defvar -@defvar treesit-defun-prefer-top-level -If this variable is non-@code{nil}, Emacs skips nested defuns, when it -looks for beginning and end of a defun, and prefers to go to the -top-level defun instead. - -In some languages, a defun could be nested in another one. By default, -Emacs stops at the first defun it encounters. But if this variable's -value is @code{t}, whenever Emacs finds a defun node, it tries to go -up the parse tree until it finds the top-level defun. - -This variable can also be a list of cons cells of the form -@w{@code{(@var{from} . @var{to}))}}, where @var{from} and @var{to} are -regexps matching tree-sitter node types. When Emacs finds a defun -node whose type matches any of the @var{from} regexps in the list, it -then tries to go up the parse tree until it finds a higher-level node -matching the corresponding @var{to} regexp. +@defvar treesit-defun-tactic +This variable determines how does Emacs treat nested defuns. If the +value is @code{top-level}, navigation functions only move across +top-level defuns, if the value is @code{nested}, navigation functions +recognize nested defuns. @end defvar @node Skipping Characters From 68e68dfeefe0ac64d4ec6c31d046ae5957741109 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jostein=20Kj=C3=B8nigsen?= Date: Mon, 2 Jan 2023 21:26:36 +0100 Subject: [PATCH 12/18] Improve fontification consistency in js-ts-mode (bug#60503) * lisp/progmodes/js.el (js--treesit-font-lock-settings): Highlight declared parameters in functions, methods and arrow-expressions as variables. --- lisp/progmodes/js.el | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index c5fdecae71b..050472002bb 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3521,6 +3521,15 @@ This function is intended for use in `after-change-functions'." (method_definition name: (property_identifier) @font-lock-function-name-face) + (method_definition + parameters: (formal_parameters (identifier) @font-lock-variable-name-face)) + + (arrow_function + parameters: (formal_parameters (identifier) @font-lock-variable-name-face)) + + (function_declaration + parameters: (formal_parameters (identifier) @font-lock-variable-name-face)) + (variable_declarator name: (identifier) @font-lock-variable-name-face) From dfdf9c21cbe7896d03da011773e636fc287d97db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jostein=20Kj=C3=B8nigsen?= Date: Mon, 2 Jan 2023 20:56:41 +0100 Subject: [PATCH 13/18] Fontification improvements in typescript-ts-mode (bug#60500) - highlight method-definitins in interfaces. - only highlight variable-declarations, not variables everywhere (consistency with other modes). - move highlighting of method invocations to level 4 * lisp/progmodes/typescript-ts-mode.el: (typescript-ts-mode--font-lock-settings): Update rules. (typescript-ts-mode, tsx-ts-mode): Update feature list. --- lisp/progmodes/typescript-ts-mode.el | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el index a0ba425b3e9..e0583f4b05c 100644 --- a/lisp/progmodes/typescript-ts-mode.el +++ b/lisp/progmodes/typescript-ts-mode.el @@ -167,6 +167,8 @@ Argument LANGUAGE is either `typescript' or `tsx'." (method_definition name: (property_identifier) @font-lock-function-name-face) + (method_signature + name: (property_identifier) @font-lock-function-name-face) (required_parameter (identifier) @font-lock-variable-name-face) (optional_parameter (identifier) @font-lock-variable-name-face) @@ -211,10 +213,8 @@ Argument LANGUAGE is either `typescript' or `tsx'." (enum_assignment name: (property_identifier) @font-lock-type-face) - (assignment_expression - left: [(identifier) @font-lock-variable-name-face - (member_expression - property: (property_identifier) @font-lock-variable-name-face)]) + (variable_declarator + name: (identifier) @font-lock-variable-name-face) (for_in_statement left: (identifier) @font-lock-variable-name-face) @@ -242,10 +242,6 @@ Argument LANGUAGE is either `typescript' or `tsx'." name: (property_identifier) @font-lock-property-face) (public_field_definition name: (property_identifier) @font-lock-property-face) - (member_expression - object: (identifier) @font-lock-variable-name-face) - (member_expression - property: (_) @font-lock-property-face) (pair key: (property_identifier) @font-lock-variable-name-face) @@ -263,9 +259,11 @@ Argument LANGUAGE is either `typescript' or `tsx'." left: [(identifier) @font-lock-function-name-face (member_expression property: (property_identifier) @font-lock-function-name-face)] - right: [(function) (arrow_function)]) + right: [(function) (arrow_function)])) - (call_expression + :language language + :feature 'function + '((call_expression function: [(identifier) @font-lock-function-name-face (member_expression @@ -377,7 +375,7 @@ Argument LANGUAGE is either `typescript' or `tsx'." '((comment declaration) (keyword string escape-sequence) (constant expression identifier number pattern property) - (bracket delimiter))) + (function bracket delimiter))) (treesit-major-mode-setup))) @@ -412,7 +410,7 @@ Argument LANGUAGE is either `typescript' or `tsx'." '((comment declaration) (keyword string escape-sequence) (constant expression identifier jsx number pattern property) - (bracket delimiter))) + (function bracket delimiter))) (treesit-major-mode-setup))) From 1a9a1fdebf648cc1f614089f385d2a9c6cbabc5b Mon Sep 17 00:00:00 2001 From: Theodor Thornhill Date: Mon, 2 Jan 2023 13:46:25 +0100 Subject: [PATCH 14/18] Improve fontification in java-ts-mode (bug#60492) * lisp/progmodes/java-ts-mode.el (java-ts-mode--font-lock-settings): Add expression_statement with only identifier support. --- lisp/progmodes/java-ts-mode.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index 8d6b244c135..96d8045bd61 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -240,7 +240,9 @@ (method_invocation name: (identifier) @font-lock-function-name-face) - (argument_list (identifier) @font-lock-variable-name-face)) + (argument_list (identifier) @font-lock-variable-name-face) + + (expression_statement (identifier) @font-lock-variable-name-face)) :language 'java :feature 'bracket From 9e6536e4d96e2280b8ed76e9e83369659a347e02 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Mon, 2 Jan 2023 23:26:39 +0200 Subject: [PATCH 15/18] ruby-ts-mode: Standardize the string literal highlights * lisp/progmodes/ruby-ts-mode.el (ruby-ts--font-lock-settings): Use font-lock-string-face for %w() and `...`. Use font-lock-constant-face (just like we do for symbol literals) for symbol array literals, %i(). Combine the matchers for string content and heredocs. --- lisp/progmodes/ruby-ts-mode.el | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el index 26d0fc49260..92c8f93a799 100644 --- a/lisp/progmodes/ruby-ts-mode.el +++ b/lisp/progmodes/ruby-ts-mode.el @@ -253,16 +253,17 @@ values of OVERRIDE" :feature 'string '((delimited_symbol [ ":\"" "\"" ] @font-lock-string-face) (string "\"" @font-lock-string-face) - (string_array [ "%w(" ")" ] @font-lock-delimiter-face) - (subshell "`" @font-lock-delimiter-face) - (symbol_array [ "%i(" ")"] @font-lock-delimiter-face)) + (string_array ["%w(" ")"] @font-lock-string-face) + (subshell "`" @font-lock-string-face) + (symbol_array ["%i(" ")"] @font-lock-constant-face)) :language language :feature 'string - '((string_content) @font-lock-string-face - (heredoc_beginning) @font-lock-string-face - (heredoc_content) @font-lock-string-face - (heredoc_end) @font-lock-string-face) + '([(string_content) + (heredoc_beginning) + (heredoc_content) + (heredoc_end)] + @font-lock-string-face) :language language :feature 'interpolation From 9b24417dda83087edb5b8bb5d2daf158c70b4193 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Tue, 3 Jan 2023 00:41:25 +0200 Subject: [PATCH 16/18] ruby-ts--font-lock-settings: Use more standard faces * lisp/progmodes/ruby-ts-mode.el (ruby-ts--font-lock-settings): Use more standard faces for regexp literals and string interpolation delimiters (following js-ts-mode). --- lisp/progmodes/ruby-ts-mode.el | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el index 92c8f93a799..96596cb5daf 100644 --- a/lisp/progmodes/ruby-ts-mode.el +++ b/lisp/progmodes/ruby-ts-mode.el @@ -237,8 +237,10 @@ values of OVERRIDE" ;; Also before 'operator because % and / are operators :language language :feature 'regexp - '((regex "/" @font-lock-regexp-grouping-construct) - (regex _ (string_content) @font-lock-regexp-grouping-backslash)) + ;; TODO: We probably need a separate face for regexps everywhere. + ;; Maybe another one for regexp delimiters as well. + '((regex "/" @font-lock-string-face) + (regex _ (string_content) @font-lock-string-face)) :language language :feature 'operator @@ -267,8 +269,8 @@ values of OVERRIDE" :language language :feature 'interpolation - '((interpolation "#{" @font-lock-doc-face) - (interpolation "}" @font-lock-doc-face)) + '((interpolation "#{" @font-lock-delimiter-face) + (interpolation "}" @font-lock-delimiter-face)) :language language :feature 'type From 94e330243e14200ba6b45e696e6a80c611438dec Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Tue, 3 Jan 2023 02:26:00 +0200 Subject: [PATCH 17/18] ruby-ts-mode: Indentation fixes * lisp/progmodes/ruby-ts-mode.el (ruby-ts--align-keywords): Fix for 'def' (which was misread as 'method' in the check). (ruby-ts--indent-rules): Indent the curly block closer the same way as the 'do ... end' closer. --- lisp/progmodes/ruby-ts-mode.el | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el index 96596cb5daf..6fb6f71991c 100644 --- a/lisp/progmodes/ruby-ts-mode.el +++ b/lisp/progmodes/ruby-ts-mode.el @@ -355,8 +355,11 @@ Otherwise return start of PRED." (lambda (node parent bol &rest rest) (let* ((pred-node (funcall pred node parent bol rest)) (temp (treesit-node-start pred-node)) - (keyword (treesit-node-type pred-node)) - (bol (ruby-smie--indent-to-stmt-p keyword))) + (type (treesit-node-type pred-node)) + (bol (ruby-smie--indent-to-stmt-p + (if (equal type "method") + "def" + type)))) (when temp (if bol (save-excursion @@ -736,7 +739,7 @@ i.e. expr of def foo(args) = expr is returned." ((match "end" "do_block") parent-bol 0) ((n-p-gp "block_body" "block" nil) parent-bol ruby-indent-level) ((n-p-gp nil "block_body" "block") (ruby-ts--bol ruby-ts--grand-parent-node) ruby-indent-level) - ((match "}" "block") (ruby-ts--bol ruby-ts--grand-parent-node) 0) + ((match "}" "block") parent-bol 0) ;; Chained strings ((match "string" "chained_string") first-sibling 0) From 6dd3e352f44eb402c9b76c8f6e5bef032317cc55 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Tue, 3 Jan 2023 03:10:49 +0200 Subject: [PATCH 18/18] Extract common code into ruby-base-mode to derive from * lisp/progmodes/ruby-mode.el (ruby-base-mode): New major base mode, to set up common vars and hooks. (ruby-mode-variables): Delete. Move most code to ruby-base-mode. And some -- to ruby-mode body. (ruby-mode): Derive from ruby-base-mode. Also move some setup to there. * lisp/progmodes/ruby-ts-mode.el (ruby-ts-mode): Derive from ruby-base-mode. Remove duplicating settings. --- lisp/progmodes/ruby-mode.el | 61 +++++++++++++++++++--------------- lisp/progmodes/ruby-ts-mode.el | 12 +------ 2 files changed, 35 insertions(+), 38 deletions(-) diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index 14cdf0a1a26..2e8d335f151 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el @@ -899,24 +899,6 @@ This only affects the output of the command `ruby-toggle-block'." (while (and (setq state (apply #'ruby-parse-partial end state)) (>= (nth 2 state) 0) (< (point) end)))))) -(defun ruby-mode-variables () - "Set up initial buffer-local variables for Ruby mode." - (setq indent-tabs-mode ruby-indent-tabs-mode) - (smie-setup ruby-smie-grammar #'ruby-smie-rules - :forward-token #'ruby-smie--forward-token - :backward-token #'ruby-smie--backward-token) - (unless ruby-use-smie - (setq-local indent-line-function #'ruby-indent-line)) - (setq-local comment-start "# ") - (setq-local comment-end "") - (setq-local comment-column ruby-comment-column) - (setq-local comment-start-skip "#+ *") - (setq-local parse-sexp-ignore-comments t) - (setq-local parse-sexp-lookup-properties t) - (setq-local paragraph-start (concat "$\\|" page-delimiter)) - (setq-local paragraph-separate paragraph-start) - (setq-local paragraph-ignore-fill-prefix t)) - (defun ruby--insert-coding-comment (encoding) "Insert a magic coding comment for ENCODING. The style of the comment is controlled by `ruby-encoding-magic-comment-style'." @@ -2629,29 +2611,54 @@ If there is no Rubocop config file, Rubocop will be passed a flag "Value for `prettify-symbols-alist' in `ruby-mode'.") ;;;###autoload -(define-derived-mode ruby-mode prog-mode "Ruby" - "Major mode for editing Ruby code." - (ruby-mode-variables) +(define-derived-mode ruby-base-mode prog-mode "Ruby" + "Generic major mode for editing Ruby. - (setq-local imenu-create-index-function #'ruby-imenu-create-index) - (setq-local add-log-current-defun-function #'ruby-add-log-current-method) - (setq-local beginning-of-defun-function #'ruby-beginning-of-defun) - (setq-local end-of-defun-function #'ruby-end-of-defun) +This mode is intended to be inherited by concrete major modes. +Currently there are `ruby-mode' and `ruby-ts-mode'." + (setq indent-tabs-mode ruby-indent-tabs-mode) + + (setq-local comment-start "# ") + (setq-local comment-end "") + (setq-local comment-column ruby-comment-column) + (setq-local comment-start-skip "#+ *") + + (setq-local parse-sexp-ignore-comments t) + (setq-local parse-sexp-lookup-properties t) + + (setq-local paragraph-start (concat "$\\|" page-delimiter)) + (setq-local paragraph-separate paragraph-start) + (setq-local paragraph-ignore-fill-prefix t) ;; `outline-regexp' contains the first part of `ruby-indent-beg-re' (setq-local outline-regexp (concat "^\\s *" (regexp-opt '("class" "module" "def")) "\\_>")) (setq-local outline-level (lambda () (1+ (/ (current-indentation) - ruby-indent-level)))) + ruby-indent-level)))) (add-hook 'after-save-hook #'ruby-mode-set-encoding nil 'local) (add-hook 'electric-indent-functions #'ruby--electric-indent-p nil 'local) (add-hook 'flymake-diagnostic-functions #'ruby-flymake-auto nil 'local) + (setq-local prettify-symbols-alist ruby--prettify-symbols-alist)) + +;;;###autoload +(define-derived-mode ruby-mode ruby-base-mode "Ruby" + "Major mode for editing Ruby code." + (smie-setup ruby-smie-grammar #'ruby-smie-rules + :forward-token #'ruby-smie--forward-token + :backward-token #'ruby-smie--backward-token) + (unless ruby-use-smie + (setq-local indent-line-function #'ruby-indent-line)) + + (setq-local imenu-create-index-function #'ruby-imenu-create-index) + (setq-local add-log-current-defun-function #'ruby-add-log-current-method) + (setq-local beginning-of-defun-function #'ruby-beginning-of-defun) + (setq-local end-of-defun-function #'ruby-end-of-defun) + (setq-local font-lock-defaults '((ruby-font-lock-keywords) nil nil ((?_ . "w")))) - (setq-local prettify-symbols-alist ruby--prettify-symbols-alist) (setq-local syntax-propertize-function #'ruby-syntax-propertize)) diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el index 6fb6f71991c..c086214a11d 100644 --- a/lisp/progmodes/ruby-ts-mode.el +++ b/lisp/progmodes/ruby-ts-mode.el @@ -898,21 +898,11 @@ leading double colon is not added." "C-c C-f" #'ruby-find-library-file) ;;;###autoload -(define-derived-mode ruby-ts-mode prog-mode "Ruby" +(define-derived-mode ruby-ts-mode ruby-base-mode "Ruby" "Major mode for editing Ruby, powered by tree-sitter." :group 'ruby :syntax-table ruby-mode-syntax-table - (setq indent-tabs-mode ruby-indent-tabs-mode) - - (setq-local paragraph-start (concat "$\\|" page-delimiter)) - (setq-local paragraph-separate paragraph-start) - (setq-local paragraph-ignore-fill-prefix t) - - (setq-local comment-start "# ") - (setq-local comment-end "") - (setq-local comment-start-skip "#+ *") - (unless (treesit-ready-p 'ruby) (error "Tree-sitter for Ruby isn't available"))