diff options
author | Stefan Kangas <stefankangas@gmail.com> | 2023-01-03 06:30:17 +0100 |
---|---|---|
committer | Stefan Kangas <stefankangas@gmail.com> | 2023-01-03 06:30:17 +0100 |
commit | 55e41707ea727ea4b5c4d3c85f68b62e32dcdfb5 (patch) | |
tree | 436b76d5358aa17d126090d63691a7661cc93f20 /lisp | |
parent | 2ee6012b3faaf12710ec63626795148caeef0f6a (diff) | |
parent | 6dd3e352f44eb402c9b76c8f6e5bef032317cc55 (diff) | |
download | emacs-55e41707ea727ea4b5c4d3c85f68b62e32dcdfb5.tar.gz emacs-55e41707ea727ea4b5c4d3c85f68b62e32dcdfb5.tar.bz2 emacs-55e41707ea727ea4b5c4d3c85f68b62e32dcdfb5.zip |
Merge from origin/emacs-29
6dd3e352f44 Extract common code into ruby-base-mode to derive from
94e330243e1 ruby-ts-mode: Indentation fixes
9b24417dda8 ruby-ts--font-lock-settings: Use more standard faces
9e6536e4d96 ruby-ts-mode: Standardize the string literal highlights
1a9a1fdebf6 Improve fontification in java-ts-mode (bug#60492)
dfdf9c21cbe Fontification improvements in typescript-ts-mode (bug#60500)
68e68dfeefe Improve fontification consistency in js-ts-mode (bug#60503)
aef869e74f4 ; Update tree-sitter manual
4ef12cfb1fc ; Fix tree-sitter manual title case
aab8ddca5e1 ; nt/INSTALL: Update for Emacs 29.
809fbb0e8c4 ; Update copyright notice in tramp-sh.el
f8f5202487c (typescript/tsx-ts-mode): Split font-lock feature list in...
a86a213e1ac js-ts-mode: Move 'string-interpolation' to font-lock level 3
d26b523886e Fix shrinking of the tab-bar
3f7ea621b90 ; Fix typos in ruby-ts-mode.el
9599b054316 ; Skip ruby-ts tests if grammar is not available
ff35ac9dfab Fix default-port regression in erc-select-read-args
b7ad0b40148 ; Clarify doc strings of 'call-process' and 'call-process...
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/erc/erc.el | 38 | ||||
-rw-r--r-- | lisp/net/tramp-sh.el | 2 | ||||
-rw-r--r-- | lisp/progmodes/java-ts-mode.el | 4 | ||||
-rw-r--r-- | lisp/progmodes/js.el | 14 | ||||
-rw-r--r-- | lisp/progmodes/ruby-mode.el | 61 | ||||
-rw-r--r-- | lisp/progmodes/ruby-ts-mode.el | 54 | ||||
-rw-r--r-- | lisp/progmodes/typescript-ts-mode.el | 28 |
7 files changed, 116 insertions, 85 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/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 51fc58a5a96..1ba2a92e21c 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 <lektu@terra.es>. -# 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 <lektu@terra.es>. -# Copyright (C) 2002-2022 Free Software Foundation, Inc. use strict; my %%trans = do { diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index 2d3ffccb3d0..87a4e2b90f8 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 diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 732598877a5..8a2a5f886ec 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) @@ -3822,9 +3831,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) 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 5c9a25c1fde..c086214a11d 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)) @@ -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 @@ -253,21 +255,22 @@ 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 - '((interpolation "#{" @font-lock-doc-face) - (interpolation "}" @font-lock-doc-face)) + '((interpolation "#{" @font-lock-delimiter-face) + (interpolation "}" @font-lock-delimiter-face)) :language language :feature 'type @@ -352,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 @@ -717,7 +723,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 @@ -733,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) @@ -892,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")) diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el index 9ad820ef2f8..f2e27395a55 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 @@ -379,9 +377,10 @@ 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))) + (function bracket delimiter))) (treesit-major-mode-setup))) @@ -413,9 +412,10 @@ 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))) + (function bracket delimiter))) (treesit-major-mode-setup))) |