diff options
| author | Sean Whitton <spwhitton@spwhitton.name> | 2026-05-23 17:30:21 +0100 |
|---|---|---|
| committer | Sean Whitton <spwhitton@spwhitton.name> | 2026-05-23 17:30:21 +0100 |
| commit | a96fc7d5465f97908a9a6d5d2cf3be8cbf6b0ebe (patch) | |
| tree | 05658dde8cf89101ced5862b74e454dac7d99a9a | |
| parent | 7fe595465bcca3a7ef59feadfd29b38a75315c65 (diff) | |
| parent | 4f13f52a3aade6e43e42f14f9f94b0c43d6b4b12 (diff) | |
Merge from origin/emacs-31
4f13f52a3aa * build-aux/git-hooks/commit-msg: Replace Markdown-style ...
dd42133315b vc-test--rename-file: Disable part of test for SCCS
eb653865c3a markdown-ts-mode: Don't enable unconditionally by default
# Conflicts:
# etc/NEWS
| -rwxr-xr-x | build-aux/git-hooks/commit-msg | 16 | ||||
| -rw-r--r-- | etc/NEWS.31 | 17 | ||||
| -rw-r--r-- | lisp/textmodes/markdown-ts-mode.el | 24 | ||||
| -rw-r--r-- | test/lisp/vc/vc-tests/vc-tests.el | 4 |
4 files changed, 35 insertions, 26 deletions
diff --git a/build-aux/git-hooks/commit-msg b/build-aux/git-hooks/commit-msg index 159990b1406..ddde1b4e586 100755 --- a/build-aux/git-hooks/commit-msg +++ b/build-aux/git-hooks/commit-msg @@ -75,6 +75,7 @@ exec $awk \ } c_lower = "abcdefghijklmnopqrstuvwxyz" unsafe_gnu_url = "(http|ftp)://([" c_lower ".]*\\.)?(gnu|fsf)\\.org" + markdown_quotation = "(^|[^\\\\])`[^'\''`]+`" } { input[NR] = $0 } @@ -92,11 +93,6 @@ exec $awk \ status = 1 } - /(^|[^\\])`[^'\''`]+`/ { - print "Markdown-style quotes in commit message" - status = 1 - } - nlines == 0 && $0 !~ non_space { next } { nlines++ } @@ -141,7 +137,7 @@ exec $awk \ status = 1 } - $0 ~ unsafe_gnu_url { + $0 ~ unsafe_gnu_url || $0 ~ markdown_quotation { needs_rewriting = 1 } @@ -167,7 +163,13 @@ exec $awk \ suffix = substr(line, RSTART) line = prefix "https:" substr(suffix, 5 + (suffix ~ /^http:/)) } - print line >file + while (match(line, markdown_quotation)) { + prefix = substr(line, 1, RSTART) + within = substr(line, RSTART + 2, RLENGTH - 3) + suffix = substr(line, RSTART + RLENGTH) + line = prefix "'\''" within "'\''" suffix + } + print line >file } if (close(file) != 0) { print "Cannot rewrite: " file diff --git a/etc/NEWS.31 b/etc/NEWS.31 index 083e6b50ea4..7fc998ff547 100644 --- a/etc/NEWS.31 +++ b/etc/NEWS.31 @@ -3938,19 +3938,12 @@ A major mode based on 'conf-mode' for editing ".npmrc" files. *** New major mode 'markdown-ts-mode'. A major mode based on the tree-sitter library for editing Markdown -files. This is now the default major mode for Markdown files. If you -don't have the necessary tree-sitter grammar libraries installed, or if -your Emacs was built without tree-sitter support, Emacs will now show a -warning to that effect when you visit a Markdown file. If you don't -want to use this mode and want to avoid these warnings, add the -following to your init file: +files. Markdown files are visited using this mode when the required +tree-sitter grammars ('markdown' and 'markdown-inline') are available, +or when the user has opted in via 'treesit-enabled-modes'. Otherwise, +Markdown files fall back to 'text-mode'. - (add-to-list 'auto-mode-alist '("\\.md\\'" . fundamental-mode)) - (add-to-list 'auto-mode-alist '("\\.markdown\\'" . fundamental-mode)) - (add-to-list 'auto-mode-alist '("\\.mdx\\'" . fundamental-mode)) - -This will cause Emacs to visit Markdown files in Fundamental mode, which -was the default before this mode was added to Emacs. +To install the grammars, use 'M-x markdown-ts-mode-install-parsers'. *** New major mode 'mhtml-ts-mode'. An optional major mode based on the tree-sitter library for editing HTML diff --git a/lisp/textmodes/markdown-ts-mode.el b/lisp/textmodes/markdown-ts-mode.el index be2247b870e..fed6ded192c 100644 --- a/lisp/textmodes/markdown-ts-mode.el +++ b/lisp/textmodes/markdown-ts-mode.el @@ -5401,14 +5401,14 @@ With a prefix argument, ARG, if needed, install parsers for `html', (cond ((treesit-ready-p '(markdown markdown-inline) t) (markdown-ts--set-up)) (t - (warn "markdown-ts-mode cannot be set up; using fundamental-mode. + (warn "markdown-ts-mode cannot be set up; using text-mode. %s." (if (treesit-available-p) "The tree-sitter parsers `markdown' and `markdown-inline' were not found. Use the command `markdown-ts-mode-install-parsers' to install them. With a prefix argument, it can also install optional parsers" "Emacs was built without Tree-sitter support, or could not load Tree-sitter")) - (fundamental-mode))))) + (text-mode))))) ;;;###autoload (define-derived-mode markdown-ts-mode text-mode "Markdown" @@ -5620,10 +5620,24 @@ If non-nil and `point' is in a table, enable #'markdown-ts--enable-in-table-mode 'local)))) ;;;###autoload +(defun markdown-ts-mode-maybe () + "Enable `markdown-ts-mode' when its grammars are available. +Also propose to install the grammars when `treesit-enabled-modes' +is t or contains the mode name." + (declare-function treesit-language-available-p "treesit.c") + (if (or (and (treesit-language-available-p 'markdown) + (treesit-language-available-p 'markdown-inline)) + (eq treesit-enabled-modes t) + (memq 'markdown-ts-mode treesit-enabled-modes)) + (markdown-ts-mode) + (text-mode))) + +;;;###autoload (when (boundp 'treesit-major-mode-remap-alist) - (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-ts-mode)) - (add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-ts-mode)) - (add-to-list 'auto-mode-alist '("\\.mdx\\'" . markdown-ts-mode)) + (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-ts-mode-maybe)) + (add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-ts-mode-maybe)) + (add-to-list 'auto-mode-alist '("\\.mdx\\'" . markdown-ts-mode-maybe)) + ;; To be able to toggle between an external package and core ts-mode: (add-to-list 'treesit-major-mode-remap-alist '(markdown-mode . markdown-ts-mode))) diff --git a/test/lisp/vc/vc-tests/vc-tests.el b/test/lisp/vc/vc-tests/vc-tests.el index 1fb17842478..8e2ae2c4454 100644 --- a/test/lisp/vc/vc-tests/vc-tests.el +++ b/test/lisp/vc/vc-tests/vc-tests.el @@ -592,8 +592,8 @@ This checks also `vc-backend' and `vc-responsible-backend'." 'added)))) ;; Test OK-IF-ALREADY-EXISTS. - ;; RCS and SRC don't support `vc-delete-file'. - (unless (memq backend '(RCS SRC)) + ;; RCS, SRC and SCCS don't support `vc-delete-file'. + (unless (memq backend '(RCS SRC SCCS)) (let ((tmp-name (expand-file-name "qux" default-directory)) (new-name (expand-file-name "quuux" default-directory))) (write-region "qux" nil tmp-name nil 'nomessage) |
