commit f7b3546c8ee630bae6ae326d46847f4dcac58835 (HEAD, refs/remotes/origin/master) Author: Theodor Thornhill Date: Mon Jan 16 08:36:49 2023 +0100 Rename variables from last change * lisp/progmodes/js.el (js--treesit-sentence-nodes): Rename variable from 'js--treesit-sentence-type-regexp'. (js-ts-mode): Refer to it. * lisp/progmodes/typescript-ts-mode.el (typescript-ts-mode--sentence-nodes): Rename variable from 'typescript-ts-mode--sentence-type-regexp'. (typescript-ts-base-mode, tsx-ts-mode): Refer to it. diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index f6103d43eea..fa3b4687ef2 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3789,7 +3789,7 @@ js-mode ;;(syntax-propertize (point-max)) ) -(defvar js--treesit-sentence-type-regexp +(defvar js--treesit-sentence-nodes '("import_statement" "debugger_statement" "expression_statement" @@ -3855,7 +3855,7 @@ js-ts-mode (setq-local treesit-defun-name-function #'js--treesit-defun-name) (setq-local treesit-sentence-type-regexp - (regexp-opt js--treesit-sentence-type-regexp)) + (regexp-opt js--treesit-sentence-nodes)) ;; Fontification. (setq-local treesit-font-lock-settings js--treesit-font-lock-settings) diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el index be84caa7b26..cd631d048ea 100644 --- a/lisp/progmodes/typescript-ts-mode.el +++ b/lisp/progmodes/typescript-ts-mode.el @@ -312,7 +312,7 @@ typescript-ts-mode--font-lock-settings :override t '((escape_sequence) @font-lock-escape-face))) -(defvar typescript-ts-mode--sentence-type-regexp +(defvar typescript-ts-mode--sentence-nodes '("import_statement" "debugger_statement" "expression_statement" @@ -369,7 +369,7 @@ typescript-ts-base-mode (setq-local treesit-defun-name-function #'js--treesit-defun-name) (setq-local treesit-sentence-type-regexp - (regexp-opt typescript-ts-mode--sentence-type-regexp)) + (regexp-opt typescript-ts-mode--sentence-nodes)) ;; Imenu (same as in `js-ts-mode'). (setq-local treesit-simple-imenu-settings @@ -432,7 +432,7 @@ tsx-ts-mode ;; Navigation (setq-local treesit-sentence-type-regexp (regexp-opt (append - typescript-ts-mode--sentence-type-regexp + typescript-ts-mode--sentence-nodes '("jsx_element" "jsx_self_closing_element")))) commit 70477be3e38d7bd5243e5d2f66577d8fbe8d1010 Author: Theodor Thornhill Date: Sun Jan 15 22:14:51 2023 +0100 Add treesit-sentence-type-regexp * lisp/progmodes/js.el (js--treesit-sentence-type-regexp): New defvar with sentence nodes. (js-ts-mode): Use the new defvar for treesit-sentence-type-regexp. * lisp/progmodes/typescript-ts-mode.el (typescript-ts-mode--sentence-type-regexp): New defvar with sentence nodes. * lisp/progmodes/typescript-ts-mode.el (typescript-ts-base-mode): Use the new defvar for treesit-sentence-type-regexp. (tsx-ts-mode): Extend treesit-sentence-type-regexp with jsx nodes. diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 902d4fa7ab3..f6103d43eea 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3789,6 +3789,31 @@ js-mode ;;(syntax-propertize (point-max)) ) +(defvar js--treesit-sentence-type-regexp + '("import_statement" + "debugger_statement" + "expression_statement" + "if_statement" + "switch_statement" + "for_statement" + "for_in_statement" + "while_statement" + "do_statement" + "try_statement" + "with_statement" + "break_statement" + "continue_statement" + "return_statement" + "throw_statement" + "empty_statement" + "labeled_statement" + "variable_declaration" + "lexical_declaration" + "jsx_element" + "jsx_self_closing_element") + "Nodes that designate sentences in JavaScript. +See `treesit-sentence-type-regexp' for more information.") + ;;;###autoload (define-derived-mode js-ts-mode js-base-mode "JavaScript" "Major mode for editing JavaScript. @@ -3828,6 +3853,10 @@ js-ts-mode "function_declaration" "lexical_declaration"))) (setq-local treesit-defun-name-function #'js--treesit-defun-name) + + (setq-local treesit-sentence-type-regexp + (regexp-opt js--treesit-sentence-type-regexp)) + ;; Fontification. (setq-local treesit-font-lock-settings js--treesit-font-lock-settings) (setq-local treesit-font-lock-feature-list diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el index 0786150d906..be84caa7b26 100644 --- a/lisp/progmodes/typescript-ts-mode.el +++ b/lisp/progmodes/typescript-ts-mode.el @@ -312,6 +312,30 @@ typescript-ts-mode--font-lock-settings :override t '((escape_sequence) @font-lock-escape-face))) +(defvar typescript-ts-mode--sentence-type-regexp + '("import_statement" + "debugger_statement" + "expression_statement" + "if_statement" + "switch_statement" + "for_statement" + "for_in_statement" + "while_statement" + "do_statement" + "try_statement" + "with_statement" + "break_statement" + "continue_statement" + "return_statement" + "throw_statement" + "empty_statement" + "labeled_statement" + "variable_declaration" + "lexical_declaration" + "property_signature") + "Nodes that designate sentences in TypeScript. +See `treesit-sentence-type-regexp' for more information.") + ;;;###autoload (add-to-list 'auto-mode-alist '("\\.ts\\'" . typescript-ts-mode)) @@ -344,6 +368,9 @@ typescript-ts-base-mode "lexical_declaration"))) (setq-local treesit-defun-name-function #'js--treesit-defun-name) + (setq-local treesit-sentence-type-regexp + (regexp-opt typescript-ts-mode--sentence-type-regexp)) + ;; Imenu (same as in `js-ts-mode'). (setq-local treesit-simple-imenu-settings `(("Function" "\\`function_declaration\\'" nil nil) @@ -402,6 +429,13 @@ tsx-ts-mode (setq-local treesit-simple-indent-rules (typescript-ts-mode--indent-rules 'tsx)) + ;; Navigation + (setq-local treesit-sentence-type-regexp + (regexp-opt (append + typescript-ts-mode--sentence-type-regexp + '("jsx_element" + "jsx_self_closing_element")))) + ;; Font-lock. (setq-local treesit-font-lock-settings (typescript-ts-mode--font-lock-settings 'tsx)) commit 9ec60fde2e8b2b144a04d05031a83469abe7846f Merge: 4d37504c432 0052aa54f6b Author: Michael Albinus Date: Sun Jan 15 18:50:00 2023 +0100 Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs commit 4d37504c432aad019a68698e590912a538c09d36 Author: Michael Albinus Date: Sun Jan 15 18:49:37 2023 +0100 Improve Tramp robustness * lisp/net/tramp-cmds.el (tramp-cleanup-connection): Protect `delete-process'. * test/lisp/net/tramp-tests.el (tramp-test29-start-file-process) (tramp-test30-make-process): Don't test disabled process filter. diff --git a/lisp/net/tramp-cmds.el b/lisp/net/tramp-cmds.el index dc967dccf68..6627ef47ee2 100644 --- a/lisp/net/tramp-cmds.el +++ b/lisp/net/tramp-cmds.el @@ -127,7 +127,7 @@ tramp-cleanup-connection (or (not keep-processes) (eq key (tramp-get-process vec)))) (tramp-flush-connection-properties key) - (delete-process key))) + (ignore-errors (delete-process key)))) ;; Remove buffers. (dolist diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 6172535a655..168933b6b46 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -4852,8 +4852,8 @@ tramp-test29-start-file-process ;; Cleanup. (ignore-errors (delete-process proc))) - ;; Disabled process filter. "sshfs" does not cooperate. - (unless (tramp--test-sshfs-p) + ;; Disabled process filter. It doesn't work reliable. + (unless t (unwind-protect (with-temp-buffer (setq command '("cat") @@ -5046,8 +5046,8 @@ tramp-test30-make-process ;; Cleanup. (ignore-errors (delete-process proc))) - ;; Disabled process filter. "sshfs" does not cooperate. - (unless (tramp--test-sshfs-p) + ;; Disabled process filter. It doesn't work reliable. + (unless t (unwind-protect (with-temp-buffer (setq command '("cat") commit ead86da14bffe1ce7471745bc9f443b7001f362a Author: Michael Albinus Date: Sun Jan 15 17:50:17 2023 +0100 Upgrade to length* functions in Tramp * lisp/net/tramp-compat.el (tramp-compat-replace-regexp-in-region): Move up. (tramp-compat-length<, tramp-compat-length>) (tramp-compat-length=): New defaliases. (tramp-compat-file-name-unquote, tramp-compat-take) (tramp-compat-ntake): Use them. * lisp/net/tramp.el (tramp-string-empty-or-nil-p): New defsubst. (tramp-find-host, tramp-buffer-name, tramp-make-tramp-file-name) (tramp-completion-make-tramp-file-name, tramp-debug-buffer-name) (tramp-completion-handle-file-name-all-completions) (tramp-handle-directory-file-name) (tramp-handle-expand-file-name) (tramp-handle-file-name-as-directory) (tramp-handle-file-name-completion) (tramp-direct-async-process-p, tramp-call-process) (tramp-read-passwd): * lisp/net/tramp-adb.el (tramp-adb-get-device) (tramp-adb-execute-adb-command, tramp-adb-maybe-open-connection): * lisp/net/tramp-archive.el (tramp-archive-handle-directory-file-name): * lisp/net/tramp-gvfs.el (tramp-gvfs-handle-expand-file-name) (tramp-gvfs-monitor-process-filter) (tramp-gvfs-handle-get-home-directory) (tramp-gvfs-handler-askpassword) (tramp-gvfs-maybe-open-connection, tramp-get-media-devices): * lisp/net/tramp-rclone.el (tramp-rclone-maybe-open-connection): * lisp/net/tramp-sh.el (tramp-sh-handle-file-directory-p) (tramp-sh-handle-insert-directory) (tramp-sh-handle-expand-file-name, tramp-sh-handle-make-process) (tramp-sh-gio-monitor-process-filter, tramp-set-remote-path) (tramp-open-connection-setup-interactive-shell) (tramp-maybe-open-connection, tramp-make-copy-program-file-name): * lisp/net/tramp-smb.el (tramp-smb-handle-copy-directory) (tramp-smb-handle-expand-file-name, tramp-smb-handle-file-acl) (tramp-smb-handle-insert-directory) (tramp-smb-handle-set-file-acl) (tramp-smb-handle-get-home-directory) (tramp-smb-maybe-open-connection): * lisp/net/tramp-sudoedit.el (tramp-sudoedit-handle-expand-file-name) (tramp-sudoedit-handle-file-name-all-completions): Use the new functions. * test/lisp/net/tramp-archive-tests.el (tramp-archive-test43-file-system-info): * test/lisp/net/tramp-tests.el (tramp-test26-file-name-completion) (tramp-test31-memory-info, tramp-test35-remote-path) (tramp-test43-file-system-info): Use new compat functions. diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index 493a9fb39a9..29b9f894ec3 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el @@ -1078,11 +1078,12 @@ tramp-adb-get-device (format "%s:%s" host port)) ;; An empty host name shall be mapped as well, when there ;; is exactly one entry in `devices'. - ((and (zerop (length host)) (= (length devices) 1)) + ((and (tramp-string-empty-or-nil-p host) + (tramp-compat-length= devices 1)) (car devices)) ;; Try to connect device. ((and tramp-adb-connect-if-not-connected - (not (zerop (length host))) + (tramp-compat-length> host 0) (tramp-adb-execute-adb-command vec "connect" (tramp-compat-string-replace @@ -1099,7 +1100,7 @@ tramp-adb-execute-adb-command "Execute an adb command. Insert the result into the connection buffer. Return nil on error and non-nil on success." - (when (and (> (length (tramp-file-name-host vec)) 0) + (when (and (tramp-compat-length> (tramp-file-name-host vec) 0) ;; The -s switch is only available for ADB device commands. (not (member (car args) '("connect" "disconnect")))) (setq args (append (list "-s" (tramp-adb-get-device vec)) args))) @@ -1226,7 +1227,7 @@ tramp-adb-maybe-open-connection (unless (process-live-p p) (save-match-data (when (and p (processp p)) (delete-process p)) - (if (zerop (length device)) + (if (tramp-string-empty-or-nil-p device) (tramp-error vec 'file-error "Device %s not connected" host)) (with-tramp-progress-reporter vec 3 "Opening adb shell connection" (let* ((coding-system-for-read 'utf-8-dos) ; Is this correct? diff --git a/lisp/net/tramp-archive.el b/lisp/net/tramp-archive.el index a2add1ed73a..3b1d568c127 100644 --- a/lisp/net/tramp-archive.el +++ b/lisp/net/tramp-archive.el @@ -598,7 +598,7 @@ tramp-archive-handle-copy-file (defun tramp-archive-handle-directory-file-name (directory) "Like `directory-file-name' for file archives." (with-parsed-tramp-archive-file-name directory nil - (if (and (not (zerop (length localname))) + (if (and (tramp-compat-length> localname 0) (eq (aref localname (1- (length localname))) ?/) (not (string= localname "/"))) (substring directory 0 -1) diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el index 6a2654ee474..95d22c4e144 100644 --- a/lisp/net/tramp-compat.el +++ b/lisp/net/tramp-compat.el @@ -178,6 +178,48 @@ 'tramp-compat-file-name-concat (car components)) (cdr components))))))) +;; Function `replace-regexp-in-region' is new in Emacs 28.1. +(defalias 'tramp-compat-replace-regexp-in-region + (if (fboundp 'replace-regexp-in-region) + #'replace-regexp-in-region + (lambda (regexp replacement &optional start end) + (if start + (when (< start (point-min)) + (error "Start before start of buffer")) + (setq start (point))) + (if end + (when (> end (point-max)) + (error "End after end of buffer")) + (setq end (point-max))) + (save-excursion + (let ((matches 0) + (case-fold-search nil)) + (goto-char start) + (while (re-search-forward regexp end t) + (replace-match replacement t) + (setq matches (1+ matches))) + (and (not (zerop matches)) + matches)))))) + +;; `length<', `length>' and `length=' are added to Emacs 28.1. +(defalias 'tramp-compat-length< + (if (fboundp 'length<) + #'length< + (lambda (sequence length) + (< (length sequence) length)))) + +(defalias 'tramp-compat-length> + (if (fboundp 'length>) + #'length> + (lambda (sequence length) + (> (length sequence) length)))) + +(defalias 'tramp-compat-length= + (if (fboundp 'length=) + #'length= + (lambda (sequence length) + (= (length sequence) length)))) + ;; `permission-denied' is introduced in Emacs 29.1. (defconst tramp-permission-denied (if (get 'permission-denied 'error-conditions) 'permission-denied 'file-error) @@ -205,7 +247,7 @@ 'tramp-compat-take #'take (lambda (n list) (when (and (natnump n) (> n 0)) - (if (>= n (length list)) + (if (tramp-compat-length< list n) list (butlast list (- (length list) n))))))) ;; Function `ntake' is new in Emacs 29.1. @@ -214,7 +256,7 @@ 'tramp-compat-ntake #'ntake (lambda (n list) (when (and (natnump n) (> n 0)) - (if (>= n (length list)) + (if (tramp-compat-length< list n) list (nbutlast list (- (length list) n))))))) ;; Function `string-equal-ignore-case' is new in Emacs 29.1. @@ -234,29 +276,6 @@ 'tramp-compat-auth-source-netrc-parse-all (autoload 'netrc-parse "netrc") (netrc-parse file)))) -;; Function `replace-regexp-in-region' is new in Emacs 28.1. -(defalias 'tramp-compat-replace-regexp-in-region - (if (fboundp 'replace-regexp-in-region) - #'replace-regexp-in-region - (lambda (regexp replacement &optional start end) - (if start - (when (< start (point-min)) - (error "Start before start of buffer")) - (setq start (point))) - (if end - (when (> end (point-max)) - (error "End after end of buffer")) - (setq end (point-max))) - (save-excursion - (let ((matches 0) - (case-fold-search nil)) - (goto-char start) - (while (re-search-forward regexp end t) - (replace-match replacement t) - (setq matches (1+ matches))) - (and (not (zerop matches)) - matches)))))) - (dolist (elt (all-completions "tramp-compat-" obarray 'functionp)) (put (intern elt) 'tramp-suppress-trace t)) diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el index cca7a5fe247..ea774d0b9b7 100644 --- a/lisp/net/tramp-gvfs.el +++ b/lisp/net/tramp-gvfs.el @@ -1154,7 +1154,8 @@ tramp-gvfs-handle-expand-file-name ;; If DIR is not given, use DEFAULT-DIRECTORY or "/". (setq dir (or dir default-directory "/")) ;; Handle empty NAME. - (when (zerop (length name)) (setq name ".")) + (when (string-empty-p name) + (setq name ".")) ;; Unless NAME is absolute, concat DIR and NAME. (unless (file-name-absolute-p name) (setq name (tramp-compat-file-name-concat dir name))) @@ -1169,7 +1170,7 @@ tramp-gvfs-handle-expand-file-name (let ((uname (match-string 1 localname)) (fname (match-string 2 localname)) hname) - (when (zerop (length uname)) + (when (tramp-string-empty-or-nil-p uname) (setq uname user)) (when (setq hname (tramp-get-home-directory v uname)) (setq localname (concat hname fname))))) @@ -1530,7 +1531,7 @@ tramp-gvfs-monitor-process-filter 'file-notify-callback (list proc action file file1))))) ;; Save rest of the string. - (when (zerop (length string)) (setq string nil)) + (when (string-empty-p string) (setq string nil)) (when string (tramp-message proc 10 "Rest string:\n%s" string)) (process-put proc 'rest-string string))) @@ -1611,7 +1612,7 @@ tramp-gvfs-handle-get-home-directory (let ((localname (tramp-get-connection-property vec "default-location")) result) (cond - ((zerop (length localname)) + ((tramp-string-empty-or-nil-p localname) (tramp-get-connection-property (tramp-get-process vec) "share")) ;; Google-drive. ((not (string-prefix-p "/" localname)) @@ -1743,11 +1744,11 @@ tramp-gvfs-handler-askpassword (condition-case nil (with-parsed-tramp-file-name filename l - (when (and (zerop (length user)) + (when (and (tramp-string-empty-or-nil-p user) (not (zerop (logand flags tramp-gvfs-password-need-username)))) (setq user (read-string "User name: "))) - (when (and (zerop (length domain)) + (when (and (tramp-string-empty-or-nil-p domain) (not (zerop (logand flags tramp-gvfs-password-need-domain)))) (setq domain (read-string "Domain name: "))) @@ -2184,7 +2185,7 @@ tramp-gvfs-maybe-open-connection (with-tramp-progress-reporter vec 3 - (if (zerop (length user)) + (if (tramp-string-empty-or-nil-p user) (format "Opening connection for %s using %s" host method) (format "Opening connection for %s@%s using %s" user host method)) @@ -2234,7 +2235,7 @@ tramp-gvfs-maybe-open-connection (with-timeout ((or (tramp-get-method-parameter vec 'tramp-connection-timeout) tramp-connection-timeout) - (if (zerop (length (tramp-file-name-user vec))) + (if (tramp-string-empty-or-nil-p (tramp-file-name-user vec)) (tramp-error vec 'file-error "Timeout reached mounting %s using %s" host method) @@ -2413,7 +2414,7 @@ tramp-get-media-devices ;; Adapt default host name, supporting /mtp:: when possible. (setq tramp-default-host-alist (append - `(("mtp" nil ,(if (= (length devices) 1) (car devices) ""))) + `(("mtp" nil ,(if (tramp-compat-length= devices 1) (car devices) ""))) (delete (assoc "mtp" tramp-default-host-alist) tramp-default-host-alist))))) diff --git a/lisp/net/tramp-rclone.el b/lisp/net/tramp-rclone.el index 4018fa3aa29..b28f9f64952 100644 --- a/lisp/net/tramp-rclone.el +++ b/lisp/net/tramp-rclone.el @@ -361,7 +361,7 @@ tramp-rclone-maybe-open-connection (let ((host (tramp-file-name-host vec))) (when (rassoc `(,host) (tramp-rclone-parse-device-names nil)) - (if (zerop (length host)) + (if (tramp-string-empty-or-nil-p host) (tramp-error vec 'file-error "Storage %s not connected" host)) ;; We need a process bound to the connection buffer. Therefore, ;; we create a dummy process. Maybe there is a better solution? diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 4647600071c..acbb6aea135 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -1736,7 +1736,7 @@ tramp-sh-handle-file-directory-p ;; Sometimes, when a connection is not established yet, it is ;; desirable to return t immediately for "/method:foo:". It can ;; be expected that this is always a directory. - (or (zerop (length localname)) + (or (tramp-string-empty-or-nil-p localname) (with-tramp-file-property v localname "file-directory-p" (if-let ((truename (tramp-get-file-property v localname "file-truename")) @@ -2349,7 +2349,7 @@ tramp-do-copy-or-rename-file-out-of-band copy-program copy-args copy-env copy-keep-date listener spec options source target remote-copy-program remote-copy-args p) - (if (and v1 v2 (zerop (length (tramp-scp-direct-remote-copying v1 v2)))) + (if (and v1 v2 (string-empty-p (tramp-scp-direct-remote-copying v1 v2))) ;; Both are Tramp files. We cannot use direct remote copying. (let* ((dir-flag (file-directory-p filename)) @@ -2684,9 +2684,9 @@ tramp-sh-handle-insert-directory (tramp-get-ls-command v) switches (if (or wildcard - (zerop (length - (tramp-run-real-handler - #'file-name-nondirectory (list localname))))) + (tramp-string-empty-or-nil-p + (tramp-run-real-handler + #'file-name-nondirectory (list localname)))) "" (tramp-shell-quote-argument (tramp-run-real-handler @@ -2803,7 +2803,8 @@ tramp-sh-handle-expand-file-name ;; If DIR is not given, use `default-directory' or "/". (setq dir (or dir default-directory "/")) ;; Handle empty NAME. - (when (zerop (length name)) (setq name ".")) + (when (string-empty-p name) + (setq name ".")) ;; On MS Windows, some special file names are not returned properly ;; by `file-name-absolute-p'. If `tramp-syntax' is `simplified', ;; there could be the false positive "/:". @@ -2838,7 +2839,7 @@ tramp-sh-handle-expand-file-name ;; the default user name for tilde expansion is not ;; appropriate either, because ssh and companions might ;; use a user name from the config file. - (when (and (zerop (length uname)) + (when (and (tramp-string-empty-or-nil-p uname) (string-match-p (rx bos "su" (? "do") eos) method)) (setq uname user)) (when (setq hname (tramp-get-home-directory v uname)) @@ -2939,7 +2940,7 @@ tramp-sh-handle-make-process (heredoc (and (not (bufferp stderr)) (stringp program) (string-match-p (rx "sh" eol) program) - (= (length args) 2) + (tramp-compat-length= args 2) (string-equal "-c" (car args)) ;; Don't if there is a quoted string. (not @@ -2949,7 +2950,7 @@ tramp-sh-handle-make-process ;; When PROGRAM is nil, we just provide a tty. (args (if (not heredoc) args (let ((i 250)) - (while (and (< i (length (cadr args))) + (while (and (not (tramp-compat-length< (cadr args) i)) (string-match " " (cadr args) i)) (setcdr args @@ -3931,7 +3932,7 @@ tramp-sh-gio-monitor-process-filter ;; Save rest of the string. (while (string-match (rx bol "\n") string) (setq string (replace-match "" nil nil string))) - (when (zerop (length string)) (setq string nil)) + (when (string-empty-p string) (setq string nil)) (when string (tramp-message proc 10 "Rest string:\n%s" string)) (process-put proc 'rest-string string))) @@ -4176,7 +4177,7 @@ tramp-set-remote-path 'noerror))) tmpfile chunk chunksize) (tramp-message vec 5 "Setting $PATH environment variable") - (if (< (length command) pipe-buf) + (if (tramp-compat-length< command pipe-buf) (tramp-send-command vec command) ;; Use a temporary file. We cannot use `write-region' because ;; setting the remote path happens in the early connection @@ -4565,7 +4566,7 @@ tramp-open-connection-setup-interactive-shell ;; Set `remote-tty' process property. (let ((tty (tramp-send-command-and-read vec "echo \\\"`tty`\\\"" 'noerror))) - (unless (zerop (length tty)) + (unless (string-empty-p tty) (process-put proc 'remote-tty tty) (tramp-set-connection-property proc "remote-tty" tty))) @@ -5138,7 +5139,7 @@ tramp-maybe-open-connection (unless (process-live-p p) (with-tramp-progress-reporter vec 3 - (if (zerop (length (tramp-file-name-user vec))) + (if (tramp-string-empty-or-nil-p (tramp-file-name-user vec)) (format "Opening connection %s for %s using %s" process-name (tramp-file-name-host vec) @@ -5511,7 +5512,7 @@ tramp-make-copy-program-file-name (cond ((tramp-get-method-parameter vec 'tramp-remote-copy-program) localname) - ((zerop (length user)) (format "%s:%s" host localname)) + ((tramp-string-empty-or-nil-p user) (format "%s:%s" host localname)) (t (format "%s@%s:%s" user host localname))))) (defun tramp-method-out-of-band-p (vec size) diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el index d6f3cca9733..b3f0344f818 100644 --- a/lisp/net/tramp-smb.el +++ b/lisp/net/tramp-smb.el @@ -487,9 +487,9 @@ tramp-smb-handle-copy-directory (args (list (concat "//" host "/" share) "-E")) (options tramp-smb-options)) - (if (not (zerop (length user))) - (setq args (append args (list "-U" user))) - (setq args (append args (list "-N")))) + (if (tramp-string-empty-or-nil-p user) + (setq args (append args (list "-N"))) + (setq args (append args (list "-U" user)))) (when domain (setq args (append args (list "-W" domain)))) (when port (setq args (append args (list "-p" port)))) @@ -712,7 +712,8 @@ tramp-smb-handle-expand-file-name ;; If DIR is not given, use DEFAULT-DIRECTORY or "/". (setq dir (or dir default-directory "/")) ;; Handle empty NAME. - (when (zerop (length name)) (setq name ".")) + (when (string-empty-p name) + (setq name ".")) ;; Unless NAME is absolute, concat DIR and NAME. (unless (file-name-absolute-p name) (setq name (tramp-compat-file-name-concat dir name))) @@ -727,7 +728,7 @@ tramp-smb-handle-expand-file-name (let ((uname (match-string 1 localname)) (fname (match-string 2 localname)) hname) - (when (zerop (length uname)) + (when (tramp-string-empty-or-nil-p uname) (setq uname user)) (when (setq hname (tramp-get-home-directory v uname)) (setq localname (concat hname fname))))) @@ -781,9 +782,9 @@ tramp-smb-handle-file-acl (args (list (concat "//" host "/" share) "-E")) (options tramp-smb-options)) - (if (not (zerop (length user))) - (setq args (append args (list "-U" user))) - (setq args (append args (list "-N")))) + (if (tramp-string-empty-or-nil-p user) + (setq args (append args (list "-N"))) + (setq args (append args (list "-U" user)))) (when domain (setq args (append args (list "-W" domain)))) (when port (setq args (append args (list "-p" port)))) @@ -1071,7 +1072,7 @@ tramp-smb-handle-insert-directory (setq entries (delq nil - (if (or wildcard (zerop (length base))) + (if (or wildcard (string-empty-p base)) ;; Check for matching entries. (mapcar (lambda (x) @@ -1096,7 +1097,7 @@ tramp-smb-handle-insert-directory (when (tramp-compat-string-search "F" switches) (mapc (lambda (x) - (unless (zerop (length (car x))) + (unless (string-empty-p (car x)) (cond ((char-equal ?d (string-to-char (nth 1 x))) (setcar x (concat (car x) "/"))) @@ -1116,7 +1117,7 @@ tramp-smb-handle-insert-directory ;; Print entries. (mapc (lambda (x) - (unless (zerop (length (nth 0 x))) + (unless (string-empty-p (nth 0 x)) (let ((attr (when (tramp-smb-get-stat-capability v) (ignore-errors @@ -1409,9 +1410,9 @@ tramp-smb-handle-set-file-acl "\n" "," acl-string))) (options tramp-smb-options)) - (if (not (zerop (length user))) - (setq args (append args (list "-U" user))) - (setq args (append args (list "-N")))) + (if (tramp-string-empty-or-nil-p user) + (setq args (append args (list "-N"))) + (setq args (append args (list "-U" user)))) (when domain (setq args (append args (list "-W" domain)))) (when port (setq args (append args (list "-p" port)))) @@ -1561,7 +1562,7 @@ tramp-smb-handle-get-home-directory user identified by VEC. If there is no user specified in either VEC or USER, or if there is no home directory, return nil." (let ((user (or user (tramp-file-name-user vec)))) - (unless (zerop (length user)) + (unless (tramp-string-empty-or-nil-p user) (concat "/" user)))) (defun tramp-smb-handle-write-region @@ -1959,9 +1960,9 @@ tramp-smb-maybe-open-connection (t (setq args (list "-g" "-L" host )))) - (if (not (zerop (length user))) - (setq args (append args (list "-U" user))) - (setq args (append args (list "-N")))) + (if (tramp-string-empty-or-nil-p user) + (setq args (append args (list "-N"))) + (setq args (append args (list "-U" user)))) (when domain (setq args (append args (list "-W" domain)))) (when port (setq args (append args (list "-p" port)))) @@ -1976,7 +1977,8 @@ tramp-smb-maybe-open-connection (with-tramp-progress-reporter vec 3 (format "Opening connection for //%s%s/%s" - (if (not (zerop (length user))) (concat user "@") "") + (if (tramp-string-empty-or-nil-p user) + "" (concat user "@")) host (or share "")) (let* (coding-system-for-read diff --git a/lisp/net/tramp-sudoedit.el b/lisp/net/tramp-sudoedit.el index 2660dbb1fac..ce080918e0f 100644 --- a/lisp/net/tramp-sudoedit.el +++ b/lisp/net/tramp-sudoedit.el @@ -363,7 +363,8 @@ tramp-sudoedit-handle-expand-file-name ;; If DIR is not given, use `default-directory' or "/". (setq dir (or dir default-directory "/")) ;; Handle empty NAME. - (when (zerop (length name)) (setq name ".")) + (when (string-empty-p name) + (setq name ".")) ;; Unless NAME is absolute, concat DIR and NAME. (unless (file-name-absolute-p name) (setq name (tramp-compat-file-name-concat dir name))) @@ -374,7 +375,7 @@ tramp-sudoedit-handle-expand-file-name ;; Tilde expansion if necessary. We cannot accept "~/", because ;; under sudo "~/" is expanded to the local user home directory ;; but to the root home directory. - (when (zerop (length localname)) + (when (tramp-string-empty-or-nil-p localname) (setq localname "~")) (unless (file-name-absolute-p localname) (setq localname (format "~%s/%s" user localname))) @@ -383,7 +384,7 @@ tramp-sudoedit-handle-expand-file-name (let ((uname (match-string 1 localname)) (fname (match-string 2 localname)) hname) - (when (zerop (length uname)) + (when (tramp-string-empty-or-nil-p uname) (setq uname user)) (when (setq hname (tramp-get-home-directory v uname)) (setq localname (concat hname fname))))) @@ -471,7 +472,7 @@ tramp-sudoedit-handle-file-name-all-completions (with-tramp-file-property v localname "file-name-all-completions" (tramp-sudoedit-send-command v "ls" "-a1" "--quoting-style=literal" "--show-control-chars" - (if (zerop (length localname)) + (if (tramp-string-empty-or-nil-p localname) "" (file-name-unquote localname))) (mapcar (lambda (f) diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index b8475b7cb48..169cf1982b4 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -1630,7 +1630,7 @@ tramp-find-host This is HOST, if non-nil. Otherwise, do a lookup in `tramp-default-host-alist' and `tramp-default-host'." (let ((result - (or (and (> (length host) 0) host) + (or (and (tramp-compat-length> host 0) host) (let ((choices tramp-default-host-alist) lhost item) (while choices @@ -1642,7 +1642,7 @@ tramp-find-host lhost) tramp-default-host))) ;; We must mark, whether a default value has been used. - (if (or (> (length host) 0) (null result)) + (if (or (tramp-compat-length> host 0) (null result)) result (propertize result 'tramp-default t)))) @@ -1748,14 +1748,18 @@ tramp-dissect-hop-name (put #'tramp-dissect-hop-name 'tramp-suppress-trace t) +(defsubst tramp-string-empty-or-nil-p (string) + "Check whether STRING is empty or nil." + (or (null string) (string= string ""))) + (defun tramp-buffer-name (vec) "A name for the connection buffer VEC." (let ((method (tramp-file-name-method vec)) (user-domain (tramp-file-name-user-domain vec)) (host-port (tramp-file-name-host-port vec))) - (if (not (zerop (length user-domain))) - (format "*tramp/%s %s@%s*" method user-domain host-port) - (format "*tramp/%s %s*" method host-port)))) + (if (tramp-string-empty-or-nil-p user-domain) + (format "*tramp/%s %s*" method host-port) + (format "*tramp/%s %s@%s*" method user-domain host-port)))) (put #'tramp-buffer-name 'tramp-suppress-trace t) @@ -1800,23 +1804,23 @@ tramp-make-tramp-file-name hop (nth 6 args)))) ;; Unless `tramp-syntax' is `simplified', we need a method. - (when (and (not (zerop (length tramp-postfix-method-format))) - (zerop (length method))) + (when (and (not (string-empty-p tramp-postfix-method-format)) + (tramp-string-empty-or-nil-p method)) (signal 'wrong-type-argument (list #'stringp method))) (concat tramp-prefix-format hop - (unless (zerop (length tramp-postfix-method-format)) + (unless (string-empty-p tramp-postfix-method-format) (concat method tramp-postfix-method-format)) user - (unless (zerop (length domain)) + (unless (tramp-string-empty-or-nil-p domain) (concat tramp-prefix-domain-format domain)) - (unless (zerop (length user)) + (unless (tramp-string-empty-or-nil-p user) tramp-postfix-user-format) (when host (if (string-match-p tramp-ipv6-regexp host) (concat tramp-prefix-ipv6-format host tramp-postfix-ipv6-format) host)) - (unless (zerop (length port)) + (unless (tramp-string-empty-or-nil-p port) (concat tramp-prefix-port-format port)) tramp-postfix-host-format localname))) @@ -1840,12 +1844,12 @@ tramp-completion-make-tramp-file-name It must not be a complete Tramp file name, but as long as there are necessary only. This function will be used in file name completion." (concat tramp-prefix-format - (unless (or (zerop (length method)) - (zerop (length tramp-postfix-method-format))) + (unless (or (tramp-string-empty-or-nil-p method) + (string-empty-p tramp-postfix-method-format)) (concat method tramp-postfix-method-format)) - (unless (zerop (length user)) + (unless (tramp-string-empty-or-nil-p user) (concat user tramp-postfix-user-format)) - (unless (zerop (length host)) + (unless (tramp-string-empty-or-nil-p host) (concat (if (string-match-p tramp-ipv6-regexp host) (concat @@ -1940,9 +1944,9 @@ tramp-debug-buffer-name (let ((method (tramp-file-name-method vec)) (user-domain (tramp-file-name-user-domain vec)) (host-port (tramp-file-name-host-port vec))) - (if (not (zerop (length user-domain))) - (format "*debug tramp/%s %s@%s*" method user-domain host-port) - (format "*debug tramp/%s %s*" method host-port)))) + (if (tramp-string-empty-or-nil-p user-domain) + (format "*debug tramp/%s %s*" method host-port) + (format "*debug tramp/%s %s@%s*" method user-domain host-port)))) (put #'tramp-debug-buffer-name 'tramp-suppress-trace t) @@ -2942,10 +2946,10 @@ tramp-completion-handle-file-name-all-completions (tramp-drop-volume-letter (expand-file-name filename directory))) ;; When `tramp-syntax' is `simplified', we need a default method. (tramp-default-method - (and (zerop (length tramp-postfix-method-format)) + (and (string-empty-p tramp-postfix-method-format) tramp-default-method)) (tramp-default-method-alist - (and (zerop (length tramp-postfix-method-format)) + (and (string-empty-p tramp-postfix-method-format) tramp-default-method-alist)) tramp-default-user tramp-default-user-alist tramp-default-host tramp-default-host-alist @@ -3768,7 +3772,7 @@ tramp-handle-directory-file-name ;; Otherwise, remove any trailing slash from localname component. ;; Method, host, etc, are unchanged. (while (with-parsed-tramp-file-name directory nil - (and (not (zerop (length localname))) + (and (tramp-compat-length> localname 0) (eq (aref localname (1- (length localname))) ?/) (not (string= localname "/")))) (setq directory (substring directory 0 -1))) @@ -3799,7 +3803,8 @@ tramp-handle-expand-file-name ;; If DIR is not given, use DEFAULT-DIRECTORY or "/". (setq dir (or dir default-directory "/")) ;; Handle empty NAME. - (when (zerop (length name)) (setq name ".")) + (when (string-empty-p name) + (setq name ".")) ;; Unless NAME is absolute, concat DIR and NAME. (unless (file-name-absolute-p name) (setq name (tramp-compat-file-name-concat dir name))) @@ -3818,7 +3823,7 @@ tramp-handle-expand-file-name (let ((uname (match-string 1 localname)) (fname (match-string 2 localname)) hname) - (when (zerop (length uname)) + (when (tramp-string-empty-or-nil-p uname) (setq uname user)) (when (setq hname (tramp-get-home-directory v uname)) (setq localname (concat hname fname))))) @@ -3901,7 +3906,7 @@ tramp-handle-file-name-as-directory ;; Run the command on the localname portion only unless we are in ;; completion mode. (tramp-make-tramp-file-name - v (or (and (zerop (length (tramp-file-name-localname v))) + v (or (and (tramp-string-empty-or-nil-p (tramp-file-name-localname v)) (not (tramp-connectable-p file))) (tramp-run-real-handler #'file-name-as-directory @@ -3964,7 +3969,8 @@ tramp-handle-file-name-completion ;; "." and ".." are never interesting as completions, and are ;; actually in the way in a directory with only one file. See ;; file_name_completion() in dired.c. - (when (and (consp fnac) (= (length (delete "./" (delete "../" fnac))) 1)) + (when (and (consp fnac) + (tramp-compat-length= (delete "./" (delete "../" fnac)) 1)) (setq fnac (delete "./" (delete "../" fnac)))) (or (try-completion @@ -4725,7 +4731,7 @@ tramp-direct-async-process-p (tramp-get-connection-property v "direct-async-process") ;; There's no multi-hop. (or (not (tramp-multi-hop-p v)) - (= (length (tramp-compute-multi-hops v)) 1)) + (null (cdr (tramp-compute-multi-hops v)))) ;; There's no remote stdout or stderr file. (or (not (stringp buffer)) (not (tramp-tramp-file-p buffer))) (or (not (stringp stderr)) (not (tramp-tramp-file-p stderr)))))) @@ -6343,7 +6349,7 @@ tramp-call-process (error (setq error (error-message-string err) result 1))) - (if (zerop (length error)) + (if (tramp-string-empty-or-nil-p error) (tramp-message vec 6 "%s\n%s" result output) (tramp-message vec 6 "%s\n%s\n%s" result output error)) result)) @@ -6479,7 +6485,7 @@ tramp-read-passwd ;; Workaround. Prior Emacs 28.1, auth-source has saved empty ;; passwords. See discussion in Bug#50399. - (when (zerop (length auth-passwd)) + (when (tramp-string-empty-or-nil-p auth-passwd) (setq tramp-password-save-function nil)) (tramp-set-connection-property vec "first-password-request" nil) diff --git a/test/lisp/net/tramp-archive-tests.el b/test/lisp/net/tramp-archive-tests.el index 85766f95cda..59b7ed9cf7c 100644 --- a/test/lisp/net/tramp-archive-tests.el +++ b/test/lisp/net/tramp-archive-tests.el @@ -872,7 +872,7 @@ tramp-archive-test43-file-system-info (let ((fsi (file-system-info tramp-archive-test-archive))) (skip-unless fsi) (should (and (consp fsi) - (= (length fsi) 3) + (tramp-compat-length= fsi 3) (numberp (nth 0 fsi)) ;; FREE and AVAIL are always 0. (zerop (nth 1 fsi)) diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 918929f55e4..6172535a655 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -4516,17 +4516,17 @@ tramp-test26-file-name-completion (and (string-match-p tramp-ipv6-regexp host) tramp-postfix-ipv6-format))) ;; Complete method name. - (unless (or (zerop (length method)) - (zerop (length tramp-method-regexp))) + (unless (or (tramp-string-empty-or-nil-p method) + (string-empty-p tramp-method-regexp)) (should (member (concat prefix-format method tramp-postfix-method-format) (file-name-all-completions (concat prefix-format (substring method 0 1)) "/")))) ;; Complete host name. - (unless (or (zerop (length method)) - (zerop (length tramp-method-regexp)) - (zerop (length host)) + (unless (or (tramp-string-empty-or-nil-p method) + (string-empty-p tramp-method-regexp) + (tramp-string-empty-or-nil-p host) (tramp--test-gvfs-p method)) (should (member @@ -5370,7 +5370,7 @@ tramp-test31-memory-info (when-let ((default-directory ert-remote-temporary-file-directory) (mi (memory-info))) (should (consp mi)) - (should (= (length mi) 4)) + (should (tramp-compat-length= mi 4)) (dotimes (i (length mi)) (should (natnump (nth i mi)))))) @@ -5915,7 +5915,8 @@ tramp-test35-remote-path ;; We make a super long `tramp-remote-path'. (make-directory tmp-name) (should (file-directory-p tmp-name)) - (while (< (length (mapconcat #'identity orig-exec-path ":")) 5000) + (while (tramp-compat-length< + (mapconcat #'identity orig-exec-path ":") 5000) (let ((dir (make-temp-file (file-name-as-directory tmp-name) 'dir))) (should (file-directory-p dir)) (setq tramp-remote-path @@ -5931,9 +5932,10 @@ tramp-test35-remote-path ;; Ignore trailing newline. (setq path (substring (shell-command-to-string "echo $PATH") nil -1)) ;; The shell doesn't handle such long strings. - (when (<= (length path) - (tramp-get-connection-property - tramp-test-vec "pipe-buf" 4096)) + (unless (tramp-compat-length> + path + (tramp-get-connection-property + tramp-test-vec "pipe-buf" 4096)) ;; The last element of `exec-path' is `exec-directory'. (should (string-equal @@ -7070,7 +7072,7 @@ tramp-test43-file-system-info (when-let ((fsi (file-system-info ert-remote-temporary-file-directory))) (should (consp fsi)) - (should (= (length fsi) 3)) + (should (tramp-compat-length= fsi 3)) (dotimes (i (length fsi)) (should (natnump (or (nth i fsi) 0)))))) commit 0052aa54f6bf4f23f5f6068f593b5b0c4a72b0e6 Merge: c87217e97f7 9f5008b9b2a Author: Stefan Kangas Date: Sun Jan 15 13:08:06 2023 +0100 Merge from origin/emacs-29 9f5008b9b2a Improve error message from sqlite-mode.el 73b304bb740 ; Fix last change: remove unused @anchor. d2efee31edb ; Update htmlfontify documentation 72d2604d1fd Merge branch 'emacs-29' of git.savannah.gnu.org:/srv/git/... cf311826841 ; * lisp/files.el (insert-directory-wildcard-in-dir-p): D... 3fa10f6e54d ; Add more c-ts-mode indent and filling tests 25a5575f161 Fix c-ts-mode block comment indentation (bug#60270) 252b2c01af0 Fix c-ts-mode label indent 189d976dbae Fix statement indent for c-ts-mode (bug#59686) (bug#60280) c78e19d99c0 Allow offset in tree-sitter indent rules to be functions d13a329acff ; Minor change in c-ts-mode--indent-styles d428d510664 Support filling line comments in c-ts-mode f02998939c6 ; Fix c-ts-mode filling b365a7cc32e Fix expansion of wildcards in ls-lisp.el b5e0260f425 Fix messages displayed when diary is shown commit c87217e97f7265f22940188dacd9772003964f29 Merge: cc576cc410f 256791edd48 Author: Stefan Kangas Date: Sun Jan 15 13:08:06 2023 +0100 ; Merge from origin/emacs-29 The following commit was skipped: 256791edd48 ; Auto-commit of loaddefs files. commit cc576cc410fd7567d6b22c0e80debfd835593847 Merge: 77ca6aa56e3 920a7d38e96 Author: Stefan Kangas Date: Sun Jan 15 13:08:02 2023 +0100 Merge from origin/emacs-29 920a7d38e96 ; Fix typos 48a62c55465 Add constructor_declaration as java-ts-mode defun 72c45fa9109 Further improvement for non-string values in pcomplete 1ef359095ec ; * etc/NEWS (--with-native-compilation=aot): Tweak wording. a8eb9dd4006 Fix the case in first-completion revealed by minibuffer-t... # Conflicts: # doc/misc/modus-themes.org # etc/NEWS commit 9f5008b9b2af4f96cecff5f878657dc8cad4de80 Author: Eli Zaretskii Date: Sun Jan 15 12:06:54 2023 +0200 Improve error message from sqlite-mode.el * lisp/sqlite-mode.el (sqlite-mode-open-file): Add error checking. (Bug#60490) diff --git a/lisp/sqlite-mode.el b/lisp/sqlite-mode.el index 83762b61943..c3047c786f7 100644 --- a/lisp/sqlite-mode.el +++ b/lisp/sqlite-mode.el @@ -55,10 +55,14 @@ sqlite-mode-open-file (interactive "fSQLite file name: ") (unless (sqlite-available-p) (error "This Emacs doesn't have SQLite support, so it can't view SQLite files")) + (if (file-remote-p file) + (error "Remote SQLite files are not yet supported")) (pop-to-buffer (get-buffer-create (format "*SQLite %s*" (file-name-nondirectory file)))) (sqlite-mode) (setq-local sqlite--db (sqlite-open file)) + (unless (sqlitep sqlite--db) + (error "`sqlite-open' failed to open SQLite file")) (sqlite-mode-list-tables)) (defun sqlite-mode-list-tables () commit 73b304bb7401da99171fc55ff88352b7c0a07083 Author: Eli Zaretskii Date: Sun Jan 15 11:52:46 2023 +0200 ; Fix last change: remove unused @anchor. diff --git a/doc/misc/htmlfontify.texi b/doc/misc/htmlfontify.texi index accb631fe3a..fa45f9361ab 100644 --- a/doc/misc/htmlfontify.texi +++ b/doc/misc/htmlfontify.texi @@ -1353,7 +1353,6 @@ Customization @item hfy-exclude-file-rules @vindex hfy-exclude-file-rules -@anchor{hfy-exclude-file-rules} Regular expressions to exclude files which shouldn't be fontified. commit d2efee31edb68e8d2b8ae21e08f6c8ae3779d3c6 Author: Xi Lu Date: Sun Jan 15 11:49:45 2023 +0200 ; Update htmlfontify documentation * doc/misc/htmlfontify.texi (Customization): Remove 'hfy-find-cmd', add 'hfy-exclude-file-rules'. (Requirements): Remove text about 'find' program. diff --git a/doc/misc/htmlfontify.texi b/doc/misc/htmlfontify.texi index 2c96002fb16..accb631fe3a 100644 --- a/doc/misc/htmlfontify.texi +++ b/doc/misc/htmlfontify.texi @@ -1351,11 +1351,11 @@ Customization on the first letter of each tag. Useful when the index would otherwise be large and take a long time to render or be difficult to navigate. -@item hfy-find-cmd -@vindex hfy-find-cmd -@anchor{hfy-find-cmd} +@item hfy-exclude-file-rules +@vindex hfy-exclude-file-rules +@anchor{hfy-exclude-file-rules} -The ``find'' command used to harvest a list of files to attempt to fontify. +Regular expressions to exclude files which shouldn't be fontified. @item hfy-extn @vindex hfy-extn @@ -1545,12 +1545,6 @@ Requirements See: @ref{Customization} -@item -A copy of find (e.g., GNU find) that provides the @code{-path} predicate. - -You may be able to work around this with a suitable clever shell -command and the customization entry: @ref{hfy-find-cmd} - @item A copy of sed (e.g., GNU sed). commit 72d2604d1fd66d08f6edc3842b585e0aafaf5cc2 Merge: cf311826841 3fa10f6e54d Author: Eli Zaretskii Date: Sun Jan 15 11:19:20 2023 +0200 Merge branch 'emacs-29' of git.savannah.gnu.org:/srv/git/emacs into emacs-29 commit cf311826841748c6865c713a4b010105e199efa7 Author: Eli Zaretskii Date: Sun Jan 15 11:18:44 2023 +0200 ; * lisp/files.el (insert-directory-wildcard-in-dir-p): Doc fix. diff --git a/lisp/files.el b/lisp/files.el index 18a046e9bb4..a9a5baf1ba3 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -7674,9 +7674,12 @@ directory-listing-before-filename-regexp (defvar insert-directory-ls-version 'unknown) (defun insert-directory-wildcard-in-dir-p (dir) - "Return non-nil if DIR contents a shell wildcard in the directory part. -The return value is a cons (DIR . WILDCARDS); DIR is the -`default-directory' in the Dired buffer, and WILDCARDS are the wildcards. + "Return non-nil if DIR contains shell wildcards in its parent directory part. +The return value is a cons (DIRECTORY . WILDCARD), where DIRECTORY is the +part of DIR up to and excluding the first component that includes +wildcard characters, and WILDCARD is the rest of DIR's components. The +DIRECTORY part of the value includes the trailing slash, to indicate that +it is a directory. Valid wildcards are `*', `?', `[abc]' and `[a-z]'." (let ((wildcards "[?*")) commit 3fa10f6e54d0ba3b08c18d99b0c857f08986e37a Author: Yuan Fu Date: Fri Jan 13 23:42:44 2023 -0800 ; Add more c-ts-mode indent and filling tests * test/lisp/progmodes/c-ts-mode-resources/filling.erts: New file. * test/lisp/progmodes/c-ts-mode-resources/indent.erts: More tests. * test/lisp/progmodes/c-ts-mode-tests.el: (c-ts-mode-test-filling): new test. diff --git a/test/lisp/progmodes/c-ts-mode-resources/filling.erts b/test/lisp/progmodes/c-ts-mode-resources/filling.erts new file mode 100644 index 00000000000..e51e3658c83 --- /dev/null +++ b/test/lisp/progmodes/c-ts-mode-resources/filling.erts @@ -0,0 +1,198 @@ +Code: + (lambda () + (c-ts-mode) + (setq-local indent-tabs-mode nil) + (fill-paragraph)) + +Point-Char: | + +Name: Type 1 + +=-= +/* woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy + * woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy + * woooomy woooomy woooomy woooomy woooomy woooomy woooomy + */ +=-= +/* woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy + * woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy + * woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy + */ +=-=-= + +Name: Type 2 + +=-= +/* woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy + * woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy + woooomy woooomy woooomy woooomy woooomy woooomy woooomy + */ +=-= +/* woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy + * woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy + * woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy + */ +=-=-= + +Name: Type 3 + +=-= +/*================================================================ + woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy + woooomy woooomy woooomy woooomy woooomy woooomy woooomy + woooomy woooomy woooomy woooomy woooomy woooomy woooomy + ================================================================*/ +=-= +/*================================================================ + woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy + woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy + woooomy woooomy woooomy woooomy woooomy woooomy woooomy + ================================================================*/ +=-=-= + +Name: Type 4 + +=-= +/*================================================================ + * woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy + woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy + woooomy woooomy woooomy woooomy woooomy + * ================================================================*/ +=-= +/*================================================================ + * woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy + * woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy + * woooomy woooomy woooomy woooomy woooomy + * ================================================================*/ +=-=-= + +Name: Type 5 + +/* woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy + * woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy + * woooomy woooomy woooomy woooomy woooomy woooomy woooomy + */ +=-= +/* woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy + * woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy + * woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy + */ +=-=-= + +Name: Type 6 + +=-= +/* woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy + woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy + woooomy woooomy woooomy woooomy woooomy woooomy woooomy + */ +=-= +/* woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy + woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy + woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy + */ +=-=-= + +Name: Type 6 + +=-= +/* woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy + woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy + woooomy woooomy woooomy woooomy woooomy woooomy woooomy + */ +=-= +/* woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy + woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy + woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy + */ +=-=-= + +Name: Type 7 + +=-= +// woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy +// woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy +// woooomy woooomy woooomy woooomy woooomy woooomy woooomy +=-= +// woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy +// woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy +// woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy +=-=-= + +Name: Type 8 + +=-= +// ================================================================ +// woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy +// woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy +// woooomy woooomy woooomy woooomy woooomy woooomy woooomy +// ================================================================ +=-= +// ================================================================ +// woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy +// woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy +// woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy +// ================================================================ +=-=-= + +Name: Type 9 + +=-= +/* woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy + woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy + woooomy woooomy woooomy woooomy woooomy woooomy woooomyyy */ +=-= +/* woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy + woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy + woooomy woooomy woooomy woooomy woooomy woooomy woooomy + woooomyyy */ +=-=-= + +Name: Not Over Fill 1 + +=-= +// woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy +// woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy +// woooomy woooomy woooomy woooomy woooomy woooomy woooomy + +// |woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy +// woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy +// woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy + +// woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy +// woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy +// woooomy woooomy woooomy woooomy woooomy woooomy woooomy +=-=-= + +Name: Not Over Fill 2 + +=-= +// woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy +return; // woooomy woooomy woooomy woooomy woooomy woooomy woooomy +//| woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy +// woooomy woooomy woooomy woooomy woooomy woooomy woooomy +return; // woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy +=-= +// woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy +return; // woooomy woooomy woooomy woooomy woooomy woooomy woooomy +// woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy +// woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy +return; // woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy +=-=-= + +Name: Not Over Fill 3 + +=-= +// woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy +return; //| woooomy woooomy woooomy woooomy woooomy woooomy woooomy +// woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy +// woooomy woooomy woooomy woooomy woooomy woooomy woooomy +return; // woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy +=-= +// woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy +return; // woooomy woooomy woooomy woooomy woooomy woooomy woooomy + // woooomy woooomy woooomy woooomy woooomy woooomy woooomy + // woooomy woooomy woooomy woooomy woooomy woooomy woooomy + // woooomy woooomy +return; // woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy +=-=-= diff --git a/test/lisp/progmodes/c-ts-mode-resources/indent.erts b/test/lisp/progmodes/c-ts-mode-resources/indent.erts index 5defcbd3c83..71524e273f3 100644 --- a/test/lisp/progmodes/c-ts-mode-resources/indent.erts +++ b/test/lisp/progmodes/c-ts-mode-resources/indent.erts @@ -1,8 +1,13 @@ Code: (lambda () + (setq indent-tabs-mode nil) + (setq c-ts-mode-indent-offset 2) + (setq c-ts-mode-indent-style 'gnu) (c-ts-mode) (indent-region (point-min) (point-max))) +Point-Char: | + Name: Basic =-= @@ -25,6 +30,68 @@ main (void) } =-=-= +Name: Labels (GNU Style) + +=-= +int +main (void) +{ + label: + return 0; + if (true) + { + label: + return 0; + } + else + { + if (true) + { + label: + return 0; + } + } +} +=-=-= + +Name: For Loop with Multi-line Condition (GNU Style) + +=-= +int main() +{ + for (int i = 0; + i < b; + i++) + { + return 0; + } +} +=-=-= + +Name: If-Else (GNU Style) + +=-= +int main() +{ + if (true) + { + return 0; + } + else + { + return 1; + } +} +=-=-= + +Name: Empty Line +=-= +int main() +{ + | +} +=-=-= + Name: Multiline Parameter List (bug#60398) =-= @@ -34,7 +101,7 @@ int f2(int x, }; =-=-= -Name: Multiline Block Comments (bug#60270) +Name: Multiline Block Comments 1 (bug#60270) =-= /** @@ -42,3 +109,55 @@ Name: Multiline Block Comments (bug#60270) * @arg1: */ =-=-= + +Name: Multiline Block Comments 2 (bug#60270) + +=-= +/* + some comment + */ +=-=-= + +Name: Multiline Block Comments 3 (bug#60270) + +=-= +/* some comment + */ +=-=-= + +Name: Multiline Block Comments 4 (bug#60270) + +=-= +/* + * Some comment + */ +=-=-= + + +Code: + (lambda () + (setq indent-tabs-mode nil) + (setq c-ts-mode-indent-offset 8) + (setq c-ts-mode-indent-style 'linux) + (c-ts-mode) + (indent-region (point-min) (point-max))) + +Name: Labels (Linux Style) + +=-=-= +int main (void) +{ +label: + return 0; + if (true) { +label: + return 0; + } + else { + if (true) { +label: + return 0; + } + } +} +=-=-= diff --git a/test/lisp/progmodes/c-ts-mode-tests.el b/test/lisp/progmodes/c-ts-mode-tests.el index 8606faf9913..3d0902fe501 100644 --- a/test/lisp/progmodes/c-ts-mode-tests.el +++ b/test/lisp/progmodes/c-ts-mode-tests.el @@ -27,5 +27,9 @@ c-ts-mode-test-indentation (skip-unless (treesit-ready-p 'c)) (ert-test-erts-file (ert-resource-file "indent.erts"))) +(ert-deftest c-ts-mode-test-filling () + (skip-unless (treesit-ready-p 'c)) + (ert-test-erts-file (ert-resource-file "filling.erts"))) + (provide 'c-ts-mode-tests) ;;; c-ts-mode-tests.el ends here commit 25a5575f161c4f4f2ee42bf15cdefec0bbfc6b33 Author: Yuan Fu Date: Sun Jan 15 01:01:38 2023 -0800 Fix c-ts-mode block comment indentation (bug#60270) * lisp/progmodes/c-ts-mode.el: (c-ts-mode--comment-2nd-line-anchor): Handle another edge case. diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 4ed34af52e7..89a08a6fa9c 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -294,14 +294,15 @@ c-ts-mode--comment-2nd-line-matcher (back-to-indentation) (eq (point) (treesit-node-start parent))))) -(defun c-ts-mode--comment-2nd-line-anchor (&rest _) +(defun c-ts-mode--comment-2nd-line-anchor (_n _p bol &rest _) "Return appropriate anchor for the second line of a comment. If the first line is /* alone, return the position right after the star; if the first line is /* followed by some text, return the position right before the text minus 1. -Use an offset of 1 with this anchor." +Use an offset of 1 with this anchor. BOL is the beginning of +non-whitespace characters of the current line." (save-excursion (forward-line -1) (back-to-indentation) @@ -310,8 +311,17 @@ c-ts-mode--comment-2nd-line-anchor (if (looking-at (rx (* (or " " "\t")) eol)) ;; Only /* at the first line. (progn (skip-chars-backward " \t") - (point)) - ;; There is something after /* at the first line. + (if (save-excursion + (goto-char bol) + (looking-at (rx "*"))) + ;; The common case. Checked by "Multiline Block + ;; Comments 4". + (point) + ;; The "Multiline Block Comments 2" test in + ;; c-ts-mode-resources/indent.erts checks this. + (1- (point)))) + ;; There is something after /* at the first line. The + ;; "Multiline Block Comments 3" test checks this. (1- (point)))))) ;;; Font-lock commit 252b2c01af02d5229d9c542a43622171ecfd040d Author: Yuan Fu Date: Sun Jan 15 00:21:10 2023 -0800 Fix c-ts-mode label indent Fix indentation of the statement right under a label. * lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-styles): Fix. (c-ts-mode--top-level-label-matcher): Fix. diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index cc1f183fd73..4ed34af52e7 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -129,8 +129,12 @@ c-ts-mode--indent-styles c-ts-mode--comment-2nd-line-anchor 1) ((parent-is "comment") prev-adaptive-prefix 0) + + ;; Labels. ((node-is "labeled_statement") parent-bol 0) - ((parent-is "labeled_statement") parent-bol c-ts-mode-indent-offset) + ((parent-is "labeled_statement") + point-min c-ts-mode--statement-offset) + ((match "preproc_ifdef" "compound_statement") point-min 0) ((match "#endif" "preproc_ifdef") point-min 0) ((match "preproc_if" "compound_statement") point-min 0) @@ -216,10 +220,10 @@ c-ts-mode--top-level-label-matcher (let ((func (treesit-parent-until node (lambda (n) (equal (treesit-node-type n) - "function_definition"))))) + "compound_statement"))))) (and (equal (treesit-node-type node) "labeled_statement") - (not (treesit-node-top-level func "function_definition"))))) + (not (treesit-node-top-level func "compound_statement"))))) (defvar c-ts-mode-indent-block-type-regexp (rx (or "compound_statement" commit 189d976dbaed9067b21dbc372c52be104ef33417 Author: Yuan Fu Date: Sun Jan 15 00:16:58 2023 -0800 Fix statement indent for c-ts-mode (bug#59686) (bug#60280) Instead of trying to figure out the correct anchor, now we just count the layers of {} blocks between the node and the root node. * lisp/progmodes/c-ts-mode.el: (c-ts-mode--indent-styles): Use new offset functions c-ts-mode--close-bracket-offset and c-ts-mode--statement-offset. (c-ts-mode--bracket-children-anchor): Remove function. (c-ts-mode--top-level-label-matcher): New variable. (c-ts-mode--statement-offset) (c-ts-mode--close-bracket-offset): New offset functions. diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 2e2bd6beeb6..cc1f183fd73 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -118,7 +118,6 @@ c-ts-mode--indent-styles `(((parent-is "translation_unit") parent-bol 0) ((node-is ")") parent 1) ((node-is "]") parent-bol 0) - ((node-is "}") c-ts-mode--bracket-children-anchor 0) ((node-is "else") parent-bol 0) ((node-is "case") parent-bol 0) ((node-is "preproc_arg") no-indent) @@ -138,8 +137,16 @@ c-ts-mode--indent-styles ((match "#endif" "preproc_if") point-min 0) ((match "preproc_function_def" "compound_statement") point-min 0) ((match "preproc_call" "compound_statement") point-min 0) + + ;; {} blocks. + ((node-is "}") point-min c-ts-mode--close-bracket-offset) ((parent-is "compound_statement") - c-ts-mode--bracket-children-anchor c-ts-mode-indent-offset) + point-min c-ts-mode--statement-offset) + ((parent-is "enumerator_list") + point-min c-ts-mode--statement-offset) + ((parent-is "field_declaration_list") + point-min c-ts-mode--statement-offset) + ((parent-is "function_definition") parent-bol 0) ((parent-is "conditional_expression") first-sibling 0) ((parent-is "assignment_expression") parent-bol c-ts-mode-indent-offset) @@ -155,12 +162,11 @@ c-ts-mode--indent-styles ((query "(for_statement update: (_) @indent)") parent-bol 5) ((query "(call_expression arguments: (_) @indent)") parent c-ts-mode-indent-offset) ((parent-is "call_expression") parent 0) - ((parent-is "enumerator_list") parent-bol c-ts-mode-indent-offset) ,@(when (eq mode 'cpp) '(((node-is "access_specifier") parent-bol 0) ;; Indent the body of namespace definitions. ((parent-is "declaration_list") parent-bol c-ts-mode-indent-offset))) - ((parent-is "field_declaration_list") parent-bol c-ts-mode-indent-offset) + ((parent-is "initializer_list") parent-bol c-ts-mode-indent-offset) ((parent-is "if_statement") parent-bol c-ts-mode-indent-offset) ((parent-is "for_statement") parent-bol c-ts-mode-indent-offset) @@ -215,20 +221,50 @@ c-ts-mode--top-level-label-matcher "labeled_statement") (not (treesit-node-top-level func "function_definition"))))) -(defun c-ts-mode--bracket-children-anchor (_n parent &rest _) - "This anchor is used for children of a compound_statement. -So anything inside a {} block. PARENT should be the -compound_statement. This anchor looks at the {, if itson its own -line, anchor at it, if it has stuff before it, anchor at the -beginning of grandparent." - (save-excursion - (goto-char (treesit-node-start parent)) - (let ((bol (line-beginning-position))) - (skip-chars-backward " \t") - (treesit-node-start - (if (< bol (point)) - (treesit-node-parent parent) - parent))))) +(defvar c-ts-mode-indent-block-type-regexp + (rx (or "compound_statement" + "field_declaration_list" + "enumeratior_list")) + "Regexp matching types of block nodes (i.e., {} blocks).") + +(defun c-ts-mode--statement-offset (node parent &rest _) + "This anchor is used for children of a statement inside a block. + +This function basically counts the number of block nodes (defined +by `c-ts-mode--indent-block-type-regexp') between NODE and the +root node (not counting NODE itself), and multiply that by +`c-ts-mode-indent-offset'. + +To support GNU style, on each block level, this function also +checks whether the opening bracket { is on its own line, if so, +it adds an extra level, except for the top-level. + +PARENT is NODE's parent." + (let ((level 0)) + ;; If point is on an empty line, NODE would be nil, but we pretend + ;; there is a statement node. + (when (null node) + (setq node t)) + (while (if (eq node t) + (setq node parent) + (setq node (treesit-node-parent node))) + (when (string-match-p c-ts-mode-indent-block-type-regexp + (treesit-node-type node)) + (cl-incf level) + (save-excursion + (goto-char (treesit-node-start node)) + (cond ((bolp) nil) + ((looking-back (rx bol (* whitespace)) + (line-beginning-position)) + (cl-incf level)))))) + (* level c-ts-mode-indent-offset))) + +(defun c-ts-mode--close-bracket-offset (node parent &rest _) + "Offset for the closing bracket, NODE. +It's basically one level less that the statements in the block. +PARENT is NODE's parent." + (- (c-ts-mode--statement-offset node parent) + c-ts-mode-indent-offset)) (defun c-ts-mode--looking-at-star (_n _p bol &rest _) "A tree-sitter simple indent matcher. commit c78e19d99c01660284c6c4d58a2e98e1ba93fb6d Author: Yuan Fu Date: Sun Jan 15 00:15:25 2023 -0800 Allow offset in tree-sitter indent rules to be functions This is needed for fixing C indentation. See next comment. * doc/lispref/modes.texi (Parser-based Indentation): Update manual. * lisp/treesit.el (treesit-simple-indent): Try evaluating OFFSET as a function if it's not integer nor variable. diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi index ff372edb3ff..fe5eb8a1b8d 100644 --- a/doc/lispref/modes.texi +++ b/doc/lispref/modes.texi @@ -4926,8 +4926,7 @@ Parser-based Indentation rule is applicable. Then Emacs passes the node to @var{anchor}, which returns a buffer position. Emacs takes the column number of that position, adds @var{offset} to it, and the result is the indentation -column for the current line. @var{offset} can be an integer or a -variable whose value is an integer. +column for the current line. The @var{matcher} and @var{anchor} are functions, and Emacs provides convenient defaults for them. @@ -4943,10 +4942,13 @@ Parser-based Indentation @var{node} is @code{nil}. In that case, @var{parent} would be the smallest node that spans that position. -Emacs finds @var{bol}, @var{node} and @var{parent} and -passes them to each @var{matcher} and @var{anchor}. @var{matcher} -should return non-@code{nil} if the rule is applicable, and -@var{anchor} should return a buffer position. +@var{matcher} should return non-@code{nil} if the rule is applicable, +and @var{anchor} should return a buffer position. + +@var{offset} can be an integer, a variable whose value is an integer, +or a function that returns an integer. If it is a function, it is +passed @var{node}, @var{parent}, and @var{bol}, like matchers and +anchors. @end defvar @defvar treesit-simple-indent-presets diff --git a/lisp/treesit.el b/lisp/treesit.el index 5b306354465..ffc78b93032 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -1511,10 +1511,15 @@ treesit-simple-indent return (let ((anchor-pos (treesit--simple-indent-eval - (list anchor node parent bol)))) - (cons anchor-pos (if (symbolp offset) - (symbol-value offset) - offset))) + (list anchor node parent bol))) + (offset-val + (cond ((numberp offset) offset) + ((and (symbolp offset) + (boundp offset)) + (symbol-value offset)) + (t (treesit--simple-indent-eval + (list offset node parent bol)))))) + (cons anchor-pos offset-val)) finally return (progn (when treesit--indent-verbose (message "No matched rule")) commit d13a329acff37b37091e137e3b04669ab7aab9ae Author: Yuan Fu Date: Sat Jan 14 20:53:10 2023 -0800 ; Minor change in c-ts-mode--indent-styles ; * lisp/progmodes/c-ts-mode.el: (c-ts-mode--indent-styles): Move top-level label rule to GNU style. diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 5f8d7426cce..2e2bd6beeb6 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -130,7 +130,6 @@ c-ts-mode--indent-styles c-ts-mode--comment-2nd-line-anchor 1) ((parent-is "comment") prev-adaptive-prefix 0) - (c-ts-mode--top-level-label-matcher point-min 1) ((node-is "labeled_statement") parent-bol 0) ((parent-is "labeled_statement") parent-bol c-ts-mode-indent-offset) ((match "preproc_ifdef" "compound_statement") point-min 0) @@ -174,6 +173,7 @@ c-ts-mode--indent-styles `((gnu ;; Prepend rules to set highest priority ((match "while" "do_statement") parent 0) + (c-ts-mode--top-level-label-matcher point-min 1) ,@common) (k&r ,@common) (linux commit d428d5106642ad0a76d4abfb39d59c5bd80edddb Author: Yuan Fu Date: Fri Jan 13 23:31:18 2023 -0800 Support filling line comments in c-ts-mode Now we handle line comments separately because for line comments, each line is an individual node, unlike block comments, where the whole block comment is a single node. fill-comment-paragraph turns out to do the job perfectly fine. * lisp/progmodes/c-ts-mode.el: (c-ts-mode--fill-paragraph): Extract out most parts into c-ts-mode--fill-block-comment. (c-ts-mode--fill-block-comment): New extracted function. diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index c1f354c7bad..5f8d7426cce 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -682,73 +682,83 @@ c-ts-mode--fill-paragraph (interactive "*P") (save-restriction (widen) - (let* ((node (treesit-node-at (point))) - (start (treesit-node-start node)) - (end (treesit-node-end node)) - ;; Bind to nil to avoid infinite recursion. - (fill-paragraph-function nil) - (orig-point (point-marker)) - (start-marker (point-marker)) - (end-marker nil) - (end-len 0)) - (move-marker start-marker start) + (let ((node (treesit-node-at (point)))) (when (string-match-p c-ts-mode--comment-regexp (treesit-node-type node)) - ;; We mask "/*" and the space before "*/" like - ;; `c-fill-paragraph' does. - (atomic-change-group - ;; Mask "/*". - (goto-char start) - (when (looking-at (rx (* (syntax whitespace)) - (group "/") "*")) - (goto-char (match-beginning 1)) - (move-marker start-marker (point)) - (replace-match " " nil nil nil 1)) - ;; Include whitespaces before /*. - (goto-char start) - (beginning-of-line) - (setq start (point)) - ;; Mask spaces before "*/" if it is attached at the end - ;; of a sentence rather than on its own line. - (goto-char end) - (when (looking-back (rx (not (syntax whitespace)) - (group (+ (syntax whitespace))) - "*/") - (line-beginning-position)) - (goto-char (match-beginning 1)) - (setq end-marker (point-marker)) - (setq end-len (- (match-end 1) (match-beginning 1))) - (replace-match (make-string end-len ?x) - nil nil nil 1)) - ;; If "*/" is on its own line, don't included it in the - ;; filling region. - (when (not end-marker) - (goto-char end) - (when (looking-back (rx "*/") 2) - (backward-char 2) - (skip-syntax-backward "-") - (setq end (point)))) - ;; Let `fill-paragraph' do its thing. - (goto-char orig-point) - (narrow-to-region start end) - ;; We don't want to fill the region between START and - ;; START-MARKER, otherwise the filling function might delete - ;; some spaces there. - (fill-region start-marker end arg) - ;; Unmask. - (when start-marker - (goto-char start-marker) - (delete-char 1) - (insert "/")) - (when end-marker - (goto-char end-marker) - (delete-region (point) (+ end-len (point))) - (insert (make-string end-len ?\s)))) - (goto-char orig-point)) + (if (save-excursion + (goto-char (treesit-node-start node)) + (looking-at "//")) + (fill-comment-paragraph arg) + (c-ts-mode--fill-block-comment arg))) ;; Return t so `fill-paragraph' doesn't attempt to fill by ;; itself. t))) +(defun c-ts-mode--fill-block-comment (&optional arg) + "Fillling function for block comments. +ARG is passed to `fill-paragraph'. Assume point is in a block +comment." + (let* ((node (treesit-node-at (point))) + (start (treesit-node-start node)) + (end (treesit-node-end node)) + ;; Bind to nil to avoid infinite recursion. + (fill-paragraph-function nil) + (orig-point (point-marker)) + (start-marker (point-marker)) + (end-marker nil) + (end-len 0)) + (move-marker start-marker start) + ;; We mask "/*" and the space before "*/" like + ;; `c-fill-paragraph' does. + (atomic-change-group + ;; Mask "/*". + (goto-char start) + (when (looking-at (rx (* (syntax whitespace)) + (group "/") "*")) + (goto-char (match-beginning 1)) + (move-marker start-marker (point)) + (replace-match " " nil nil nil 1)) + ;; Include whitespaces before /*. + (goto-char start) + (beginning-of-line) + (setq start (point)) + ;; Mask spaces before "*/" if it is attached at the end + ;; of a sentence rather than on its own line. + (goto-char end) + (when (looking-back (rx (not (syntax whitespace)) + (group (+ (syntax whitespace))) + "*/") + (line-beginning-position)) + (goto-char (match-beginning 1)) + (setq end-marker (point-marker)) + (setq end-len (- (match-end 1) (match-beginning 1))) + (replace-match (make-string end-len ?x) + nil nil nil 1)) + ;; If "*/" is on its own line, don't included it in the + ;; filling region. + (when (not end-marker) + (goto-char end) + (when (looking-back (rx "*/") 2) + (backward-char 2) + (skip-syntax-backward "-") + (setq end (point)))) + ;; Let `fill-paragraph' do its thing. + (goto-char orig-point) + (narrow-to-region start end) + ;; We don't want to fill the region between START and + ;; START-MARKER, otherwise the filling function might delete + ;; some spaces there. + (fill-region start-marker end arg) + ;; Unmask. + (when start-marker + (goto-char start-marker) + (delete-char 1) + (insert "/")) + (when end-marker + (goto-char end-marker) + (delete-region (point) (+ end-len (point))) + (insert (make-string end-len ?\s)))))) + (defun c-ts-mode-comment-setup () "Set up local variables for C-like comment. commit f02998939c6b7eaa5a63137573abe6fd85fc3de1 Author: Yuan Fu Date: Fri Jan 13 23:05:45 2023 -0800 ; Fix c-ts-mode filling * lisp/progmodes/c-ts-mode.el: (c-ts-mode--comment-regexp): New variable. (c-ts-mode--fill-paragraph): Use the new variable, and make sure start-marker is always initialized. diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index ef5a9c2195a..c1f354c7bad 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -671,6 +671,11 @@ c-ts-mode-indent-defun ;;; Filling +(defvar c-ts-mode--comment-regexp + ;; These covers C/C++, Java, JavaScript, TypeScript, Rust, C#. + (rx (or "comment" "line_comment" "block_comment")) + "Regexp pattern that matches a comment in C-like languages.") + (defun c-ts-mode--fill-paragraph (&optional arg) "Fillling function for `c-ts-mode'. ARG is passed to `fill-paragraph'." @@ -683,12 +688,12 @@ c-ts-mode--fill-paragraph ;; Bind to nil to avoid infinite recursion. (fill-paragraph-function nil) (orig-point (point-marker)) - (start-marker nil) + (start-marker (point-marker)) (end-marker nil) (end-len 0)) - ;; These covers C/C++, Java, JavaScript, TypeScript, Rust, C#. - (when (member (treesit-node-type node) - '("comment" "line_comment" "block_comment")) + (move-marker start-marker start) + (when (string-match-p c-ts-mode--comment-regexp + (treesit-node-type node)) ;; We mask "/*" and the space before "*/" like ;; `c-fill-paragraph' does. (atomic-change-group @@ -697,7 +702,7 @@ c-ts-mode--fill-paragraph (when (looking-at (rx (* (syntax whitespace)) (group "/") "*")) (goto-char (match-beginning 1)) - (setq start-marker (point-marker)) + (move-marker start-marker (point)) (replace-match " " nil nil nil 1)) ;; Include whitespaces before /*. (goto-char start) commit b365a7cc32e223e428d082a74d0780df223ad193 Author: Eli Zaretskii Date: Sun Jan 15 10:47:24 2023 +0200 Fix expansion of wildcards in ls-lisp.el * lisp/ls-lisp.el (ls-lisp--dired): Fix error message text. Handle the case of a wildcard specifying directories. (Bug#60819) diff --git a/lisp/ls-lisp.el b/lisp/ls-lisp.el index 217bebcfcb2..81ff14932c6 100644 --- a/lisp/ls-lisp.el +++ b/lisp/ls-lisp.el @@ -482,8 +482,22 @@ ls-lisp--dired (if (not dir-wildcard) (funcall orig-fun dir-or-list switches) (let* ((default-directory (car dir-wildcard)) - (files (file-expand-wildcards (cdr dir-wildcard))) + (wildcard (cdr dir-wildcard)) + (files (file-expand-wildcards wildcard)) (dir (car dir-wildcard))) + ;; When the wildcard ends in a slash, file-expand-wildcards + ;; returns nil; fix that by treating the wildcards as + ;; specifying only directories whose names match the + ;; widlcard. + (if (and (null files) + (directory-name-p wildcard)) + (setq files + (delq nil + (mapcar (lambda (fname) + (if (file-accessible-directory-p fname) + fname)) + (file-expand-wildcards + (directory-file-name wildcard)))))) (if files (let ((inhibit-read-only t) (buf @@ -494,7 +508,7 @@ ls-lisp--dired (dired-goto-next-file) (forward-line 0) (insert " wildcard " (cdr dir-wildcard) "\n")))) - (user-error "No files matching regexp"))))))) + (user-error "No files matching wildcard"))))))) (advice-add 'dired :around #'ls-lisp--dired) commit b5e0260f4258b7d29c208c5cec271ea6c4ef9f69 Author: Eli Zaretskii Date: Sun Jan 15 08:10:33 2023 +0200 Fix messages displayed when diary is shown * lisp/calendar/diary-lib.el (diary-list-entries): Display the "...done" message only if there's no important message in the echo-area. (Bug#60795) diff --git a/lisp/calendar/diary-lib.el b/lisp/calendar/diary-lib.el index b90ed715fae..44fb5eb5a86 100644 --- a/lisp/calendar/diary-lib.el +++ b/lisp/calendar/diary-lib.el @@ -880,7 +880,10 @@ diary-list-entries (original-date original-date)) (run-hooks 'diary-hook)))))) (and temp-buff (buffer-name temp-buff) (kill-buffer temp-buff))) - (or d-incp (message "Preparing diary...done")) + (or d-incp + ;; Don't clobber messages displayed while preparing the diary. + (not (equal (current-message) "Preparing diary...")) + (message "Preparing diary...done")) diary-entries-list))) (defun diary-unhide-everything () commit 256791edd484e07cfa963cc9c7cb0b8a66d448bb Author: Stefan Kangas Date: Sun Jan 15 05:08:49 2023 +0100 ; Auto-commit of loaddefs files. diff --git a/lisp/ldefs-boot.el b/lisp/ldefs-boot.el index bad13e9bb9f..a463a7da67e 100644 --- a/lisp/ldefs-boot.el +++ b/lisp/ldefs-boot.el @@ -1079,10 +1079,11 @@ 'command-apropos search for matches for that word as a substring. If it is a list of words, search for matches for any two (or more) of those words. -Note that by default this command only searches in the file specified by -`internal-doc-file-name'; i.e., the etc/DOC file. With \\[universal-argument] prefix, -or if `apropos-do-all' is non-nil, it searches all currently defined -documentation strings. +Note that by default this command only searches in the functions predefined +at Emacs startup, i.e., the primitives implemented in C or preloaded in the +Emacs dump image. +With \\[universal-argument] prefix, or if `apropos-do-all' is non-nil, it searches +all currently defined documentation strings. Returns list of symbols and documentation found. @@ -2929,10 +2930,18 @@ "semantic/bovine/c" (autoload 'c-ts-mode "c-ts-mode" "\ Major mode for editing C, powered by tree-sitter. +This mode is independent from the classic cc-mode.el based +`c-mode', so configuration variables of that mode, like +`c-basic-offset', don't affect this mode. + (fn)" t) (autoload 'c++-ts-mode "c-ts-mode" "\ Major mode for editing C++, powered by tree-sitter. +This mode is independent from the classic cc-mode.el based +`c++-mode', so configuration variables of that mode, like +`c-basic-offset', don't affect this mode. + (fn)" t) (register-definition-prefixes "c-ts-mode" '("c-ts-mode-")) @@ -4114,6 +4123,22 @@ "cfengine" non-nil, means also include partially matching ligatures and non-canonical equivalences. +Each line of the display shows the equivalences in two different +ways separated by a colon: + + - as the literal character or sequence + - using an ASCII-only escape syntax + +For example, for the letter \\='r\\=', the first line is + + r: ?\\N{LATIN SMALL LETTER R} + +which is for the requested character itself, and a later line has + + ṟ: ?\\N{LATIN SMALL LETTER R}?\\N{COMBINING MACRON BELOW} + +which clearly shows what the constituent characters are. + (fn CHAR &optional LAX)" t) (register-definition-prefixes "char-fold" '("char-fold-")) @@ -22325,7 +22350,7 @@ "opascal" ;;; Generated autoloads from org/org.el -(push (purecopy '(org 9 6)) package--builtin-versions) +(push (purecopy '(org 9 6 1)) package--builtin-versions) (autoload 'org-babel-do-load-languages "org" "\ Load the languages defined in `org-babel-load-languages'. @@ -24504,6 +24529,7 @@ "pop3" (autoload 'pp-emacs-lisp-code "pp" "\ Insert SEXP into the current buffer, formatted as Emacs Lisp code. Use the `pp-max-width' variable to control the desired line length. +Note that this could be slow for large SEXPs. (fn SEXP)") (register-definition-prefixes "pp" '("pp-")) @@ -25090,7 +25116,7 @@ "ede/proj-shared" ;;; Generated autoloads from progmodes/project.el -(push (purecopy '(project 0 9 3)) package--builtin-versions) +(push (purecopy '(project 0 9 4)) package--builtin-versions) (autoload 'project-current "project" "\ Return the project instance in DIRECTORY, defaulting to `default-directory'. @@ -27313,6 +27339,13 @@ "rtree" ;;; Generated autoloads from progmodes/ruby-mode.el (push (purecopy '(ruby-mode 1 2)) package--builtin-versions) +(autoload 'ruby-base-mode "ruby-mode" "\ +Generic major mode for editing Ruby. + +This mode is intended to be inherited by concrete major modes. +Currently there are `ruby-mode' and `ruby-ts-mode'. + +(fn)" t) (autoload 'ruby-mode "ruby-mode" "\ Major mode for editing Ruby code. @@ -27321,6 +27354,15 @@ "rtree" (dolist (name (list "ruby" "rbx" "jruby" "ruby1.9" "ruby1.8")) (add-to-list 'interpreter-mode-alist (cons (purecopy name) 'ruby-mode))) (register-definition-prefixes "ruby-mode" '("ruby-")) + +;;; Generated autoloads from progmodes/ruby-ts-mode.el + +(autoload 'ruby-ts-mode "ruby-ts-mode" "\ +Major mode for editing Ruby, powered by tree-sitter. + +(fn)" t) +(register-definition-prefixes "ruby-ts-mode" '("ruby-ts-")) + ;;; Generated autoloads from ruler-mode.el @@ -32414,7 +32456,6 @@ "todo-mode" ;;; Generated autoloads from textmodes/toml-ts-mode.el -(add-to-list 'auto-mode-alist '("\\.toml\\'" . toml-ts-mode)) (autoload 'toml-ts-mode "toml-ts-mode" "\ Major mode for editing TOML, powered by tree-sitter. @@ -32802,6 +32843,21 @@ "tree-widget" ;;; Generated autoloads from treesit.el +(autoload 'treesit-install-language-grammar "treesit" "\ +Build and install the tree-sitter language grammar library for LANG. + +Interactively, if `treesit-language-source-alist' doesn't already +have data for building the grammar for LANG, prompt for its +repository URL and the C/C++ compiler to use. + +This command requires Git, a C compiler and (sometimes) a C++ compiler, +and the linker to be installed and on PATH. It also requires that the +recipe for LANG exists in `treesit-language-source-alist'. + +See `exec-path' for the current path where Emacs looks for +executable programs, such as the C/C++ compiler and linker. + +(fn LANG)" t) (register-definition-prefixes "treesit" '("treesit-")) @@ -36777,7 +36833,7 @@ "xmltok" ;;; Generated autoloads from progmodes/xref.el -(push (purecopy '(xref 1 6 0)) package--builtin-versions) +(push (purecopy '(xref 1 6 1)) package--builtin-versions) (autoload 'xref-find-backend "xref") (define-obsolete-function-alias 'xref-pop-marker-stack #'xref-go-back "29.1") (autoload 'xref-go-back "xref" "\ commit 920a7d38e96134289393b7bfcc3a7b88be73925b Author: Stefan Kangas Date: Sun Jan 15 02:10:32 2023 +0100 ; Fix typos diff --git a/doc/misc/modus-themes.org b/doc/misc/modus-themes.org index 0dbe7a6c5b6..4bf78379c10 100644 --- a/doc/misc/modus-themes.org +++ b/doc/misc/modus-themes.org @@ -2811,7 +2811,7 @@ that can be overridden): As one can tell, we bind a key to a hexadecimal RGB color value. Now say we wish to override those specific values and have our changes propagate to all faces that use those keys. We could write something -like this, which adds a subtle ochre tint: +like this, which adds a subtle ocher tint: #+begin_src emacs-lisp (setq modus-themes-operandi-color-overrides @@ -2886,7 +2886,7 @@ look like this: With those in place, one can use {{{kbd(M-x my-modus-themes-tinted)}}} and then load the Modus theme of their choice. The new palette subset -will come into effect: subtle ochre tints (or shades of gray) for Modus +will come into effect: subtle ocher tints (or shades of gray) for Modus Operandi and night sky blue shades for Modus Vivendi. Switching between the two themes, such as with {{{kbd(M-x modus-themes-toggle)}}} will also use the overrides. diff --git a/lisp/icomplete.el b/lisp/icomplete.el index 9fa622017f7..014f38b2024 100644 --- a/lisp/icomplete.el +++ b/lisp/icomplete.el @@ -252,7 +252,7 @@ icomplete-forward-completions "Step forward completions by one entry. Second entry becomes the first and can be selected with `icomplete-force-complete-and-exit'. -Return non-nil iff something was stepped." +Return non-nil if something was stepped." (interactive) (let* ((beg (icomplete--field-beg)) (end (icomplete--field-end)) @@ -270,7 +270,7 @@ icomplete-backward-completions "Step backward completions by one entry. Last entry becomes the first and can be selected with `icomplete-force-complete-and-exit'. -Return non-nil iff something was stepped." +Return non-nil if something was stepped." (interactive) (let* ((beg (icomplete--field-beg)) (end (icomplete--field-end)) diff --git a/lisp/org/org-mouse.el b/lisp/org/org-mouse.el index 6a733f09db7..3b2c4cba624 100644 --- a/lisp/org/org-mouse.el +++ b/lisp/org/org-mouse.el @@ -241,7 +241,7 @@ org-mouse-line-position (t :middle))) (defun org-mouse-empty-line () - "Return non-nil iff the line contains only white space." + "Return non-nil if the line contains only white space." (save-excursion (beginning-of-line) (looking-at "[ \t]*$"))) (defun org-mouse-next-heading () @@ -283,7 +283,7 @@ org-mouse-keyword-menu If SELECTED is nil, then all items are normal menu items. If SELECTED is a function, then each item is a checkbox, which is -enabled for a given keyword iff (funcall SELECTED keyword) return +enabled for a given keyword if (funcall SELECTED keyword) return non-nil. If SELECTED is neither nil nor a function, then the items are radio buttons. A radio button is enabled for the keyword `equal' to SELECTED. diff --git a/lisp/simple.el b/lisp/simple.el index bb0ed092b70..3f3dbe78c39 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -2228,8 +2228,8 @@ read-extended-command-predicate This includes commands marked as specific to the current buffer's modes and commands that have keybindings in the current buffer's active local keymaps. It also includes - several commands, like Cuztomize commands, which should - always be avaliable." + several commands, like Customize commands, which should + always be available." :version "28.1" :group 'completion :type '(choice (const :tag "Don't exclude any commands" nil) diff --git a/lisp/woman.el b/lisp/woman.el index dfb5e69778f..92cd425d32f 100644 --- a/lisp/woman.el +++ b/lisp/woman.el @@ -2355,7 +2355,7 @@ woman-decode-region (point-max))) (defun woman-horizontal-escapes (to) - "Process \\h'+/-N' local horizontal motion escapes upto TO. + "Process \\h'+/-N' local horizontal motion escapes up to TO. Implements arbitrary forward and non-overlapping backward motion. Preserves location of `point'." ;; Moved from `woman-decode-region' for version 0.50. @@ -3346,7 +3346,7 @@ woman-get-next-char (defun woman2-tr (to) ".tr abcde -- Translate a -> b, c -> d, ..., e -> space. -Format paragraphs upto TO. Supports special chars. +Format paragraphs up to TO. Supports special chars. \(Breaks, but should not.)" ;; This should be an update, but consing onto the front of the alist ;; has the same effect and match duplicates should not matter. @@ -3402,7 +3402,7 @@ woman-translate (defvar woman-registers ; these are all read-only '((".H" 24) (".V" 48) ; resolution in basic units (".g" 0) ; not groff - ;; (Iff emulating groff need to implement groff italic correction + ;; (If emulating groff need to implement groff italic correction ;; \/, e.g. for pic.1) (".i" left-margin) ; current indent (".j" woman-adjust) ; current adjustment @@ -3432,7 +3432,7 @@ woman2-process-escapes-to-eol (defun woman2-nr (to) ".nr R +/-N M -- Assign +/-N (wrt to previous value, if any) to register R. The increment for auto-incrementing is set to M. -Format paragraphs upto TO. (Breaks, but should not!)" +Format paragraphs up to TO. (Breaks, but should not!)" (let* ((name (buffer-substring (point) (progn (skip-syntax-forward "^ ") (point)))) @@ -3699,7 +3699,7 @@ woman-find-next-control-line (defun woman2-PD (to) ".PD d -- Set the interparagraph distance to d. -Round to whole lines, default 1 line. Format paragraphs upto TO. +Round to whole lines, default 1 line. Format paragraphs up to TO. \(Breaks, but should not.)" ;; .ie \\n[.$] .nr PD (v;\\$1) ;; .el .nr PD .4v>?\n[.V] @@ -3718,7 +3718,7 @@ woman-interparagraph-space (setq woman-leave-blank-lines woman-interparagraph-distance)) (defun woman2-TH (to) - ".TH n c x v m -- Begin a man page. Format paragraphs upto TO. + ".TH n c x v m -- Begin a man page. Format paragraphs up to TO. n is the name of the page in chapter c; x is extra commentary; v alters page foot left; m alters page head center. \(Should set prevailing indent and tabs to 5.)" @@ -3748,7 +3748,7 @@ woman2-TH (defun woman2-SH (to) ".SH -- Sub-head. Leave blank line and subhead. -Format paragraphs upto TO. Set prevailing indent to 5." +Format paragraphs up to TO. Set prevailing indent to 5." (if (eolp) ; If no args then (delete-char 1) ; apply to next line (woman-unquote-args) ; else unquote to end of heading @@ -3767,7 +3767,7 @@ woman2-SH (defun woman2-SS (to) ".SS -- Sub-sub-head. Like .SH but indent heading 3 spaces. -Format paragraphs upto TO." +Format paragraphs up to TO." (if (eolp) ; If no args then (delete-char 1)) ; apply to next line. (insert " ") @@ -3776,7 +3776,7 @@ woman2-SS (defun woman2-LP (to) ".LP,.PP -- Begin paragraph. Set prevailing indent to 5. -Leave 1 blank line. Format paragraphs upto TO." +Leave 1 blank line. Format paragraphs up to TO." (woman-delete-line 1) ; ignore any arguments (woman-interparagraph-space) (setq woman-prevailing-indent woman-default-indent) @@ -3786,21 +3786,21 @@ 'woman2-PP (defalias 'woman2-P #'woman2-LP) (defun woman2-ns (to) - ".ns -- Turn on no-space mode. Format paragraphs upto TO." + ".ns -- Turn on no-space mode. Format paragraphs up to TO." ;; Should not cause a break! (woman-delete-line 1) ; ignore argument(s) (setq woman-nospace t) (woman2-format-paragraphs to)) (defun woman2-rs (to) - ".rs -- Turn off no-space mode. Format paragraphs upto TO." + ".rs -- Turn off no-space mode. Format paragraphs up to TO." ;; Should not cause a break! (woman-delete-line 1) ; ignore argument(s) (setq woman-nospace nil) (woman2-format-paragraphs to)) (defun woman2-sp (to) - ".sp N -- If N > 0 then leave 1 blank line. Format paragraphs upto TO." + ".sp N -- If N > 0 then leave 1 blank line. Format paragraphs up to TO." (let ((N (if (eolp) 1 (woman-get-numeric-arg)))) (if (>= N 0) (woman-delete-line 1) ; ignore argument(s) @@ -3955,13 +3955,13 @@ woman-horizontal-line ;;; 4. Text Filling, Adjusting, and Centering (defun woman2-br (to) - ".br -- Break. Leave no blank line. Format paragraphs upto TO." + ".br -- Break. Leave no blank line. Format paragraphs up to TO." (woman-delete-line 1) ; ignore any arguments (woman2-format-paragraphs to)) (defun woman2-fi (to) ".fi -- Fill subsequent output lines. Leave no blank line. -Format paragraphs upto TO." +Format paragraphs up to TO." (setq woman-nofill nil) (woman-delete-line 1) ; ignore any arguments ;; Preserve any final blank line in the nofill region: @@ -3981,7 +3981,7 @@ woman2-nf (defun woman2-ad (to) ".ad c -- Line adjustment is begun (once fill mode is on). Set justification mode to c if specified. -Format paragraphs upto TO. (Breaks, but should not.)" +Format paragraphs up to TO. (Breaks, but should not.)" ;; c = l -- left, r -- right, c -- center, b or n -- both, ;; absent -- unchanged. Initial mode adj,both. (setq woman-adjust @@ -3997,7 +3997,7 @@ woman2-ad (woman2-format-paragraphs to)) (defun woman2-na (to) - ".na -- No adjusting. Format paragraphs upto TO. + ".na -- No adjusting. Format paragraphs up to TO. \(Breaks, but should not.)" (setq woman-adjust-previous woman-adjust woman-justify-previous woman-justify @@ -4037,7 +4037,7 @@ woman-leave-blank-lines (defvar woman-temp-indent nil) (defun woman2-format-paragraphs (to &optional new-left) - "Indent, fill and adjust paragraphs upto TO to current left margin. + "Indent, fill and adjust paragraphs up to TO to current left margin. If optional arg NEW-LEFT is non-nil then reset current left margin. If `woman-nofill' is non-nil then indent without filling or adjusting." ;; Blank space should only ever be output before text. @@ -4103,7 +4103,7 @@ woman2-format-paragraphs ;;; Tagged, indented and hanging paragraphs: (defun woman2-TP (to) - ".TP i -- Set prevailing indent to i. Format paragraphs upto TO. + ".TP i -- Set prevailing indent to i. Format paragraphs up to TO. Begin indented paragraph with hanging tag given by next text line. If tag doesn't fit, place it on a separate line." (let ((i (woman2-get-prevailing-indent))) @@ -4111,7 +4111,7 @@ woman2-TP (woman2-tagged-paragraph to i))) (defun woman2-IP (to) - ".IP x i -- Same as .TP with tag x. Format paragraphs upto TO." + ".IP x i -- Same as .TP with tag x. Format paragraphs up to TO." (woman-interparagraph-space) (if (eolp) ; no args ;; Like LP without resetting prevailing indent @@ -4152,7 +4152,7 @@ woman-find-next-control-line-carefully (defun woman2-tagged-paragraph (to i) "Begin indented paragraph with hanging tag given by current text line. If tag doesn't fit, leave it on separate line. -Format paragraphs upto TO. Set prevailing indent to I." +Format paragraphs up to TO. Set prevailing indent to I." (if (not (looking-at "\\s *$")) ; non-empty tag (setq woman-leave-blank-lines nil)) @@ -4206,7 +4206,7 @@ woman2-tagged-paragraph (goto-char to))))) (defun woman2-HP (to) - ".HP i -- Set prevailing indent to i. Format paragraphs upto TO. + ".HP i -- Set prevailing indent to i. Format paragraphs up to TO. Begin paragraph with hanging indent." (let ((i (woman2-get-prevailing-indent))) (woman-interparagraph-space) @@ -4228,7 +4228,7 @@ woman2-get-prevailing-indent (defun woman2-RS (to) ".RS i -- Start relative indent, move left margin in distance i. -Set prevailing indent to 5 for nested indents. Format paragraphs upto TO." +Set prevailing indent to 5 for nested indents. Format paragraphs up to TO." (push woman-left-margin woman-RS-left-margin) (push woman-prevailing-indent woman-RS-prevailing-indent) (setq woman-left-margin (+ woman-left-margin @@ -4237,7 +4237,7 @@ woman2-RS (woman2-format-paragraphs to woman-left-margin)) (defun woman2-RE (to) - ".RE -- End of relative indent. Format paragraphs upto TO. + ".RE -- End of relative indent. Format paragraphs up to TO. Set prevailing indent to amount of starting .RS." (when woman-RS-left-margin (setq woman-left-margin (pop woman-RS-left-margin))) @@ -4274,18 +4274,18 @@ woman-in-left-margin (defun woman2-ll (to) ".ll +/-N -- Set, increment or decrement line length. -Format paragraphs upto TO. (Breaks, but should not.)" +Format paragraphs up to TO. (Breaks, but should not.)" (woman-set-arg 'fill-column 'woman-ll-fill-column) (woman2-format-paragraphs to)) (defun woman2-in (to) ".in +/-N -- Set, increment or decrement the indent. -Format paragraphs upto TO." +Format paragraphs up to TO." (woman-set-arg 'left-margin 'woman-in-left-margin) (woman2-format-paragraphs to)) (defun woman2-ti (to) - ".ti +/-N -- Temporary indent. Format paragraphs upto TO." + ".ti +/-N -- Temporary indent. Format paragraphs up to TO." ;; Ignore if no argument. ;; Indent next output line only wrt current indent. ;; Current indent is not changed. @@ -4300,7 +4300,7 @@ woman2-ta ".ta Nt ... -- Set tabs, left type, unless t=R(right), C(centered). \(Breaks, but should not.) The tab stops are separated by spaces; a value preceded by + represents an increment to the previous stop value. -Format paragraphs upto TO." +Format paragraphs up to TO." (setq tab-stop-list nil) (woman2-process-escapes-to-eol 'numeric) (save-excursion @@ -4350,7 +4350,7 @@ woman-tab-to-tab-stop (insert ?\s)))) (defun woman2-DT (to) - ".DT -- Restore default tabs. Format paragraphs upto TO. + ".DT -- Restore default tabs. Format paragraphs up to TO. \(Breaks, but should not.)" ;; Currently just terminates special tab processing. (setq tab-stop-list nil) @@ -4359,7 +4359,7 @@ woman2-DT (defun woman2-fc (to) ".fc a b -- Set field delimiter a and pad character b. -Format paragraphs upto TO. +Format paragraphs up to TO. A VERY FIRST ATTEMPT to make fields at least readable! Needs doing properly!" (if (eolp) @@ -4395,7 +4395,7 @@ woman2-fc (defun woman2-TS (to) ".TS -- Start of table code for the tbl processor. -Format paragraphs upto TO." +Format paragraphs up to TO." (when woman-emulate-tbl ;; Assumes column separator is \t and intercolumn spacing is 3. ;; The first line may optionally be a list of options terminated by diff --git a/src/ccl.c b/src/ccl.c index c92684f4bc7..6e780ef9f0c 100644 --- a/src/ccl.c +++ b/src/ccl.c @@ -1987,7 +1987,7 @@ ccl_get_compiled_code (Lisp_Object ccl_prog, ptrdiff_t *idx) /* Setup fields of the structure pointed by CCL appropriately for the execution of CCL program CCL_PROG. CCL_PROG is the name (symbol) of the CCL program or the already compiled code (vector). - Return true iff successful. + Return true if successful. If CCL_PROG is nil, just reset the structure pointed by CCL. */ bool diff --git a/src/keyboard.c b/src/keyboard.c index 0ed28070335..6f0f075e54e 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -10010,7 +10010,7 @@ read_key_sequence (Lisp_Object *keybuf, Lisp_Object prompt, if (/* first_unbound < indec.start && first_unbound < fkey.start && */ first_unbound < keytran.start) - { /* The prefix upto first_unbound has no binding and has + { /* The prefix up to first_unbound has no binding and has no translation left to do either, so we know it's unbound. If we don't stop now, we risk staying here indefinitely (if the user keeps entering fkey or keytran prefixes diff --git a/src/regex-emacs.c b/src/regex-emacs.c index 6b2fa5df037..2dca0d16ad9 100644 --- a/src/regex-emacs.c +++ b/src/regex-emacs.c @@ -223,7 +223,7 @@ #define BYTEWIDTH 8 /* In bits. */ is followed by a range table: 2 bytes of flags for character sets (low 8 bits, high 8 bits) See RANGE_TABLE_WORK_BITS below. - 2 bytes, the number of pairs that follow (upto 32767) + 2 bytes, the number of pairs that follow (up to 32767) pairs, each 2 multibyte characters, each multibyte character represented as 3 bytes. */ charset, diff --git a/test/lisp/erc/resources/networks/merge-server/track.eld b/test/lisp/erc/resources/networks/merge-server/track.eld index 4a97f92f722..19c37aaf40b 100644 --- a/test/lisp/erc/resources/networks/merge-server/track.eld +++ b/test/lisp/erc/resources/networks/merge-server/track.eld @@ -21,7 +21,7 @@ (0.00 ":irc.example.net 376 tester :End of message of the day.")) ((mode 10 "MODE tester +i") - (0.00 ":irc.example.net 501 tester x :is not a recognised user mode.") + (0.00 ":irc.example.net 501 tester x :is not a recognized user mode.") (0.00 ":NickServ!NickServ@services.int NOTICE tester :Welcome to FooNet, tester! Here on FooNet, we provide services to enable the registration of nicknames and channels! For details, type \2/msg NickServ help\2 and \2/msg ChanServ help\2.") (0.02 ":tester!user@10.0.2.100 MODE tester :+i")) diff --git a/test/manual/indent/octave.m b/test/manual/indent/octave.m index 76cad09ad1e..08b7fa58d59 100644 --- a/test/manual/indent/octave.m +++ b/test/manual/indent/octave.m @@ -1517,7 +1517,7 @@ function copy_files (desc, packdir, global_install) if (exist (fullfile (desc.dir, getarch ()), "dir") && ! strcmp (fullfile (desc.dir, getarch ()), octfiledir)) if (! exist (octfiledir, "dir")) - ## Can be required to create upto three levels of dirs. + ## Can be required to create up to three levels of dirs. octm1 = fileparts (octfiledir); if (! exist (octm1, "dir")) octm2 = fileparts (octm1); commit 48a62c55465f22d8b647f3627dcb1d827130e05e Author: Theodor Thornhill Date: Sat Jan 14 22:39:08 2023 +0100 Add constructor_declaration as java-ts-mode defun * lisp/progmodes/java-ts-mode.el (java-ts-mode): Extend treesit-defun-type-regexp. diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index 03342ab52bb..d29fcd80861 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -311,7 +311,8 @@ java-ts-mode "enum_declaration" "import_declaration" "package_declaration" - "module_declaration"))) + "module_declaration" + "constructor_declaration"))) (setq-local treesit-defun-name-function #'java-ts-mode--defun-name) ;; Font-lock. commit 72c45fa9109a53cb55d13697d69e9a32a7e289b5 Author: Gregory Heytings Date: Wed Jan 4 16:48:03 2023 +0000 Further improvement for non-string values in pcomplete * lisp/pcomplete.el (pcomplete-arg): Use the string representation of the argument value instead of the text representation of the argument. Return the value, even when it is not a string, when index is 'last'. Fixes bug#60464. diff --git a/lisp/pcomplete.el b/lisp/pcomplete.el index 5bee5152463..1ca7a213361 100644 --- a/lisp/pcomplete.el +++ b/lisp/pcomplete.el @@ -632,6 +632,13 @@ pcomplete-list ;;; Internal Functions: ;; argument handling +(defsubst pcomplete-actual-arg (&optional index offset) + "Return the actual text representation of the last argument. +This is different from `pcomplete-arg', which returns the textual value +that the last argument evaluated to. This function returns what the +user actually typed in." + (buffer-substring (pcomplete-begin index offset) (point))) + (defun pcomplete-arg (&optional index offset) "Return the textual content of the INDEXth argument. INDEX is based from the current processing position. If INDEX is @@ -659,11 +666,20 @@ pcomplete-arg (_ (- pcomplete-index (or index 0)))) (or offset 0)) pcomplete-args))) - (if (stringp arg) + (if (or (stringp arg) + ;; FIXME: 'last' is handled specially in Emacs 29, because + ;; 'pcomplete-parse-arguments' accepts a list of strings + ;; (which are completion candidates) as return value for + ;; (pcomplete-arg 'last). See below: "it means it's a + ;; list of completions computed during parsing, + ;; e.g. Eshell uses that to turn globs into lists of + ;; completions". This special case will be dealt with + ;; differently in Emacs 30: the pcomplete-arg-value + ;; property will be used by 'pcomplete-parse-arguments'. + (eq index 'last)) arg (propertize - (buffer-substring (pcomplete-begin index offset) - (pcomplete-begin (1- (or index 0)) offset)) + (car (split-string (pcomplete-actual-arg index offset))) 'pcomplete-arg-value arg)))) (defun pcomplete-begin (&optional index offset) @@ -679,13 +695,6 @@ pcomplete-begin (setq index (+ index offset))) (nth index pcomplete-begins)) -(defsubst pcomplete-actual-arg (&optional index offset) - "Return the actual text representation of the last argument. -This is different from `pcomplete-arg', which returns the textual value -that the last argument evaluated to. This function returns what the -user actually typed in." - (buffer-substring (pcomplete-begin index offset) (point))) - (defsubst pcomplete-next-arg () "Move the various pointers to the next argument." (setq pcomplete-index (1+ pcomplete-index) commit 1ef359095ec610a92c1f485b3f301782336dfc4e Author: Sean Whitton Date: Sat Jan 14 12:50:54 2023 -0700 ; * etc/NEWS (--with-native-compilation=aot): Tweak wording. I've observed people thinking that this is a completely new feature. diff --git a/etc/NEWS b/etc/NEWS index ac338da71e8..d1ddd0194c1 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -25,11 +25,13 @@ applies, and please also update docstrings as needed. * Installation Changes in Emacs 29.1 --- -** Ahead-of-time native compilation can now be specified via configure. -Use '--with-native-compilation=aot' to specify that all the Lisp files +** Ahead-of-time native compilation can now be requested via configure. +Use '--with-native-compilation=aot' to request that all the Lisp files in the Emacs tree should be natively compiled ahead of time. (This is slow on most machines.) +This feature existed in Emacs 28.1, but was less easy to request. + +++ ** Emacs can be built with the tree-sitter parsing library. This library, together with grammar libraries, provides incremental commit a8eb9dd40069d3555a59ec2f692f64f9b8679ae7 Author: Juri Linkov Date: Sat Jan 14 20:56:33 2023 +0200 Fix the case in first-completion revealed by minibuffer-tests * lisp/simple.el (first-completion): Add the text-property 'first-completion' when the first completion is at the beginning of the buffer. * test/lisp/minibuffer-tests.el (completions-header-format-test): Revert the recent change. diff --git a/lisp/simple.el b/lisp/simple.el index e23ee961879..bb0ed092b70 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -9722,7 +9722,11 @@ first-completion "Move to the first item in the completion list." (interactive) (goto-char (point-min)) - (unless (get-text-property (point) 'mouse-face) + (if (get-text-property (point) 'mouse-face) + (unless (get-text-property (point) 'first-completion) + (let ((inhibit-read-only t)) + (add-text-properties (point) (min (1+ (point)) (point-max)) + '(first-completion t)))) (when-let ((pos (next-single-property-change (point) 'mouse-face))) (goto-char pos)))) diff --git a/test/lisp/minibuffer-tests.el b/test/lisp/minibuffer-tests.el index 2ac5e0f29d6..1de8e56cbd4 100644 --- a/test/lisp/minibuffer-tests.el +++ b/test/lisp/minibuffer-tests.el @@ -421,7 +421,7 @@ completions-header-format-test (switch-to-completions) ;; Fixed in bug#55430 (should (equal "aa" (get-text-property (point) 'completion--string))) - (next-completion 3) + (next-completion 2) (should (equal "ac" (get-text-property (point) 'completion--string))) (previous-completion 2) (should (equal "aa" (get-text-property (point) 'completion--string)))