mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 06:20:55 -08:00
Merge from origin/emacs-29
53481cc954Fix description of when "\xNNN" is considered a unibyte c...1ef8b90ae0Simplify imenu setup for {cmake,dockerfile}-ts-modes7338af9c98; * etc/PROBLEMS: Document that GnuPG 2.4.4 solves the Ea...5483a1df99Improve documentation of profiler commandsfb4cf0ab46; Fix xref under Output Overrides in Elisp manual.aa6c24da61Fix broken links to Freedesktop notifications spec14d68221d2Fix nasty cut'n'waste error in Tramp51ca049608Fix image-dired-tags-db-file void variable errorc450eec07ftypescript-ts-mode: Skip test if tsx grammar missing9841ced147; Fix typos557ed9c046* admin/README: Document the run-codespell script.5701f96335* admin/README: Fix entry on coccinelle subdirectory.1805f4bfd6Add script admin/run-codespell and supporting files
This commit is contained in:
commit
6176924238
18 changed files with 1774 additions and 98 deletions
18
admin/README
18
admin/README
|
|
@ -39,6 +39,11 @@ Build Emacs in various ways.
|
||||||
|
|
||||||
Install emacs quickly ("incrementally").
|
Install emacs quickly ("incrementally").
|
||||||
|
|
||||||
|
** run-codespell
|
||||||
|
|
||||||
|
Run the codespell tool on the Emacs sources. Requires codespell to be
|
||||||
|
installed first.
|
||||||
|
|
||||||
** alloc-colors.c
|
** alloc-colors.c
|
||||||
|
|
||||||
A utility program that allocates a given number of colors on X. Can
|
A utility program that allocates a given number of colors on X. Can
|
||||||
|
|
@ -57,15 +62,16 @@ Tests for custom types and load problems.
|
||||||
Show files added/removed between two tar files.
|
Show files added/removed between two tar files.
|
||||||
|
|
||||||
|
|
||||||
Brief description of sub-directories:
|
* Brief description of sub-directories.
|
||||||
|
|
||||||
charsets scripts for generating charset map files
|
charsets scripts for generating charset map files
|
||||||
in ../etc/charsets
|
in ../etc/charsets
|
||||||
coccinelle patches to make coccinelle work with
|
coccinelle semantic patches for use with the static code
|
||||||
the latest Emacs version. Since they
|
analyzer coccinelle. Since they apply a few
|
||||||
apply a few minor changes in Emacs internals
|
minor changes in Emacs internals in multiple
|
||||||
in multiple places, they are trivial for
|
places, they are trivial for copyright
|
||||||
copyright purposes.
|
purposes.
|
||||||
|
codespell supporting files for the run-codespell script.
|
||||||
grammars wisent and bovine grammars, used to produce
|
grammars wisent and bovine grammars, used to produce
|
||||||
files in lisp/cedet/.
|
files in lisp/cedet/.
|
||||||
notes miscellaneous notes related to administrative
|
notes miscellaneous notes related to administrative
|
||||||
|
|
|
||||||
27
admin/codespell/README
Normal file
27
admin/codespell/README
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
This directory contains supporting files for running codespell.
|
||||||
|
See the ./admin/run-codespell script.
|
||||||
|
|
||||||
|
codespell.dictionary
|
||||||
|
|
||||||
|
This file contains additional, Emacs-specific corrections. When
|
||||||
|
fixing typos in Emacs, consider adding them to this file.
|
||||||
|
|
||||||
|
codespell.exclude
|
||||||
|
|
||||||
|
This file contains lines that are correct and should be ignored by
|
||||||
|
codespell. Add any false positives to this file.
|
||||||
|
|
||||||
|
The lines must match lines in the Emacs source tree exactly,
|
||||||
|
including any whitespace.
|
||||||
|
|
||||||
|
codespell.ignore
|
||||||
|
|
||||||
|
This file contains any words that are correct in the context of
|
||||||
|
Emacs, or that we otherwise choose to ignore. Use your best
|
||||||
|
judgment when adding words to this file. Common typos that are
|
||||||
|
only correct in highly specific contexts should probably be in
|
||||||
|
codespell.exclude instead.
|
||||||
|
|
||||||
|
codespell.rc
|
||||||
|
|
||||||
|
This file contains the Emacs specific codespell configuration.
|
||||||
17
admin/codespell/codespell.dictionary
Normal file
17
admin/codespell/codespell.dictionary
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
alis->alist, alias, alas, axis, alms,
|
||||||
|
boostrap-clean->bootstrap-clean
|
||||||
|
brunches->branches
|
||||||
|
defalis->defalias
|
||||||
|
defalises->defaliases
|
||||||
|
ecmacs->emacs
|
||||||
|
ehsell->eshell
|
||||||
|
emcs->emacs
|
||||||
|
finis->finish
|
||||||
|
firs->first
|
||||||
|
file-writeable-p->file-writable-p
|
||||||
|
hep->help
|
||||||
|
least-favourite->least-favorite
|
||||||
|
lien->line
|
||||||
|
liens->lines
|
||||||
|
mecas->emacs
|
||||||
|
sehell->eshell, shell,
|
||||||
1551
admin/codespell/codespell.exclude
Normal file
1551
admin/codespell/codespell.exclude
Normal file
File diff suppressed because it is too large
Load diff
41
admin/codespell/codespell.ignore
Normal file
41
admin/codespell/codespell.ignore
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
acknowledgements
|
||||||
|
afile
|
||||||
|
ake
|
||||||
|
analogue
|
||||||
|
ans
|
||||||
|
bloc
|
||||||
|
blocs
|
||||||
|
callint
|
||||||
|
clen
|
||||||
|
crossreference
|
||||||
|
crossreferences
|
||||||
|
debbugs
|
||||||
|
dedented
|
||||||
|
dependant
|
||||||
|
doas
|
||||||
|
ede
|
||||||
|
grey
|
||||||
|
gud
|
||||||
|
ifset
|
||||||
|
inout
|
||||||
|
keypair
|
||||||
|
keyserver
|
||||||
|
keyservers
|
||||||
|
lightening
|
||||||
|
mapp
|
||||||
|
master
|
||||||
|
mimicks
|
||||||
|
mitre
|
||||||
|
msdos
|
||||||
|
ot
|
||||||
|
parm
|
||||||
|
parms
|
||||||
|
reenable
|
||||||
|
reenabled
|
||||||
|
requestor
|
||||||
|
sie
|
||||||
|
spawnve
|
||||||
|
statics
|
||||||
|
stdio
|
||||||
|
texline
|
||||||
|
typdef
|
||||||
4
admin/codespell/codespell.rc
Normal file
4
admin/codespell/codespell.rc
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
[codespell]
|
||||||
|
skip=.git/*,*.elc,*.eln,*.gpg,*.gz,*.icns,*.jpg,*.kbx,*.key,*.pbm,*.png,*.rnc,*.so,*.tiff,*.tit,*.xml,*.xpm,*.zip,*random_seed
|
||||||
|
builtin=clear,rare,en-GB_to_en-US
|
||||||
|
quiet-level=35
|
||||||
68
admin/run-codespell
Executable file
68
admin/run-codespell
Executable file
|
|
@ -0,0 +1,68 @@
|
||||||
|
#!/bin/bash
|
||||||
|
### run-codespell - run codespell on Emacs
|
||||||
|
|
||||||
|
## Copyright (C) 2023-2024 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
## Author: Stefan Kangas <stefankangas@gmail.com>
|
||||||
|
|
||||||
|
## This file is part of GNU Emacs.
|
||||||
|
|
||||||
|
## GNU Emacs is free software: you can redistribute it and/or modify
|
||||||
|
## it under the terms of the GNU General Public License as published by
|
||||||
|
## the Free Software Foundation, either version 3 of the License, or
|
||||||
|
## (at your option) any later version.
|
||||||
|
|
||||||
|
## GNU Emacs is distributed in the hope that it will be useful,
|
||||||
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
## GNU General Public License for more details.
|
||||||
|
|
||||||
|
## You should have received a copy of the GNU General Public License
|
||||||
|
## along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
### Commentary:
|
||||||
|
|
||||||
|
## Run codespell on the Emacs source tree.
|
||||||
|
##
|
||||||
|
## codespell 2.2.2 or later is recommended. Earlier versions had a
|
||||||
|
## bug where the line count was incorrect for files containing "^L"
|
||||||
|
## characters.
|
||||||
|
|
||||||
|
source "${0%/*}/emacs-shell-lib"
|
||||||
|
|
||||||
|
CODESPELL_DIR="${PD}/codespell"
|
||||||
|
|
||||||
|
CODESPELL_RC="${CODESPELL_DIR}/codespell.rc"
|
||||||
|
CODESPELL_EXCLUDE="${CODESPELL_DIR}/codespell.exclude"
|
||||||
|
CODESPELL_IGNORE="${CODESPELL_DIR}/codespell.ignore"
|
||||||
|
CODESPELL_DICTIONARY="${CODESPELL_DIR}/codespell.dictionary"
|
||||||
|
|
||||||
|
emacs_run_codespell ()
|
||||||
|
{
|
||||||
|
git ls-files |\
|
||||||
|
grep -v -E -e '^(lib|m4)/.*' |\
|
||||||
|
grep -v -E -e '^admin/(charsets|codespell|unidata)/.*' |\
|
||||||
|
grep -v -E -e '^doc/misc/texinfo.tex$' |\
|
||||||
|
grep -v -E -e '^etc/(AUTHORS|HELLO|publicsuffix.txt)$' |\
|
||||||
|
grep -v -E -e '^etc/refcards/(cs|de|fr|pl|pt|sk)-.+.tex$' |\
|
||||||
|
grep -v -E -e '^etc/tutorials/TUTORIAL\..+' |\
|
||||||
|
grep -v -E -e '^leim/(MISC|SKK)-DIC/.*' |\
|
||||||
|
grep -v -E -e '^lisp/language/ethio-util.el' |\
|
||||||
|
grep -v -E -e '^lisp/ldefs-boot.el' |\
|
||||||
|
grep -v -E -e '^lisp/leim/.*' |\
|
||||||
|
grep -v -E -e '^test/lisp/net/puny-resources/IdnaTestV2.txt' |\
|
||||||
|
grep -v -E -e '^test/manual/(etags|indent)/.*' |\
|
||||||
|
grep -v -E -e '^test/src/regex-resources/.*' |\
|
||||||
|
xargs codespell \
|
||||||
|
--config "$CODESPELL_RC" \
|
||||||
|
--exclude-file "$CODESPELL_EXCLUDE" \
|
||||||
|
--ignore-words "$CODESPELL_IGNORE" \
|
||||||
|
--disable-colors \
|
||||||
|
--write-changes \
|
||||||
|
$@
|
||||||
|
}
|
||||||
|
|
||||||
|
emacs_run_codespell
|
||||||
|
emacs_run_codespell --dictionary "$CODESPELL_DICTIONARY"
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
@ -1093,10 +1093,19 @@ argument (@kbd{C-u @key{RET}}) to see the whole call tree below a
|
||||||
function. Pressing @kbd{@key{RET}} again will collapse back to the
|
function. Pressing @kbd{@key{RET}} again will collapse back to the
|
||||||
original state.
|
original state.
|
||||||
|
|
||||||
Press @kbd{j} or @kbd{mouse-2} to jump to the definition of a function
|
@findex profiler-report-find-entry
|
||||||
at point. Press @kbd{d} to view a function's documentation. You can
|
@findex profiler-report-describe-entry
|
||||||
save a profile to a file using @kbd{C-x C-w}. You can compare two
|
@findex profiler-find-profile
|
||||||
profiles using @kbd{=}.
|
@findex profiler-find-profile-other-window
|
||||||
|
@findex profiler-report-compare-profile
|
||||||
|
Press @kbd{j} (@code{profiler-report-find-entry}) or @kbd{mouse-2} to
|
||||||
|
jump to the definition of a function at point. Press @kbd{d}
|
||||||
|
(@code{profiler-report-describe-entry}) to view a function's
|
||||||
|
documentation. You can save a profile to a file using @kbd{C-x C-w}
|
||||||
|
(@code{profiler-report-write-profile}) and read a saved profile with
|
||||||
|
@w{@kbd{M-x profiler-find-profile}} or @w{@kbd{M-x
|
||||||
|
profiler-find-profile-other-window}}. You can compare two profiles
|
||||||
|
using @kbd{=} (@code{profiler-report-compare-profile}).
|
||||||
|
|
||||||
@c FIXME reversed calltree?
|
@c FIXME reversed calltree?
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1180,13 +1180,14 @@ character), Emacs automatically assumes that it is multibyte.
|
||||||
|
|
||||||
You can also use hexadecimal escape sequences (@samp{\x@var{n}}) and
|
You can also use hexadecimal escape sequences (@samp{\x@var{n}}) and
|
||||||
octal escape sequences (@samp{\@var{n}}) in string constants.
|
octal escape sequences (@samp{\@var{n}}) in string constants.
|
||||||
@strong{But beware:} If a string constant contains hexadecimal or
|
@strong{But beware:} If a string constant contains octal escape
|
||||||
octal escape sequences, and these escape sequences all specify unibyte
|
sequences or one- or two-digit hexadecimal escape sequences, and these
|
||||||
characters (i.e., less than 256), and there are no other literal
|
escape sequences all specify unibyte characters (i.e., codepoints less
|
||||||
non-@acronym{ASCII} characters or Unicode-style escape sequences in
|
than 256), and there are no other literal non-@acronym{ASCII}
|
||||||
the string, then Emacs automatically assumes that it is a unibyte
|
characters or Unicode-style escape sequences in the string, then Emacs
|
||||||
string. That is to say, it assumes that all non-@acronym{ASCII}
|
automatically assumes that it is a unibyte string. That is to say, it
|
||||||
characters occurring in the string are 8-bit raw bytes.
|
assumes that all non-@acronym{ASCII} characters occurring in the
|
||||||
|
string are 8-bit raw bytes.
|
||||||
|
|
||||||
In hexadecimal and octal escape sequences, the escaped character
|
In hexadecimal and octal escape sequences, the escaped character
|
||||||
code may contain a variable number of digits, so the first subsequent
|
code may contain a variable number of digits, so the first subsequent
|
||||||
|
|
|
||||||
|
|
@ -2945,7 +2945,7 @@ interpreted as icon name.
|
||||||
|
|
||||||
@item :category @var{category}
|
@item :category @var{category}
|
||||||
The type of notification this is, a string. See the
|
The type of notification this is, a string. See the
|
||||||
@uref{https://developer.gnome.org/notification-spec/#categories,
|
@url{https://specifications.freedesktop.org/notification-spec/notification-spec-latest.html#categories,
|
||||||
Desktop Notifications Specification} for a list of standard
|
Desktop Notifications Specification} for a list of standard
|
||||||
categories.
|
categories.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -995,7 +995,7 @@ less natural and is less compact.
|
||||||
@cindex overrides, in output functions
|
@cindex overrides, in output functions
|
||||||
@cindex output variables, overriding
|
@cindex output variables, overriding
|
||||||
|
|
||||||
The previous section (@pxref{Output Functions}) lists the numerous
|
The previous section (@pxref{Output Variables}) lists the numerous
|
||||||
variables that control how the Emacs Lisp printer formats data for
|
variables that control how the Emacs Lisp printer formats data for
|
||||||
outputs. These are generally available for users to change, but
|
outputs. These are generally available for users to change, but
|
||||||
sometimes you want to output data in the default format, or override
|
sometimes you want to output data in the default format, or override
|
||||||
|
|
|
||||||
|
|
@ -530,11 +530,10 @@ The solution is to use gawk (GNU awk).
|
||||||
*** Saving a file encrypted with GnuPG via EasyPG hangs.
|
*** Saving a file encrypted with GnuPG via EasyPG hangs.
|
||||||
|
|
||||||
This is known to happen with GnuPG v2.4.1. The only known workaround
|
This is known to happen with GnuPG v2.4.1. The only known workaround
|
||||||
is to downgrade to a version of GnuPG older than 2.4.1 (or, in the
|
is to downgrade to a version of GnuPG older than 2.4.1, or upgrade to
|
||||||
future, upgrade to a newer version which solves the problem, when such
|
version 2.4.4 and newer, which reportedly solves the problem. Note
|
||||||
a fixed version becomes available). Note that GnuPG v2.2.42 and later
|
that GnuPG v2.2.42 and later also has this problem, so you should also
|
||||||
also has this problem, so you should also avoid those later 2.2.4x
|
avoid those later 2.2.4x versions; v2.2.41 is reported to work fine.
|
||||||
versions; v2.2.41 is reported to work fine.
|
|
||||||
|
|
||||||
*** EasyPG loopback pinentry does not work with gpgsm.
|
*** EasyPG loopback pinentry does not work with gpgsm.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ Return the value of last form in BODY."
|
||||||
"Check if `image-dired-tags-db-file' exists.
|
"Check if `image-dired-tags-db-file' exists.
|
||||||
If not, try to create it (including any parent directories).
|
If not, try to create it (including any parent directories).
|
||||||
Signal error if there are problems creating it."
|
Signal error if there are problems creating it."
|
||||||
|
(require 'image-dired) ; for `image-dired-dir'
|
||||||
(or (file-exists-p image-dired-tags-db-file)
|
(or (file-exists-p image-dired-tags-db-file)
|
||||||
(let (dir buf)
|
(let (dir buf)
|
||||||
(unless (file-directory-p (setq dir (file-name-directory
|
(unless (file-directory-p (setq dir (file-name-directory
|
||||||
|
|
|
||||||
|
|
@ -3191,7 +3191,7 @@ Host is always \"localhost\"."
|
||||||
(when (zerop (tramp-call-process nil "getent" nil t nil "passwd"))
|
(when (zerop (tramp-call-process nil "getent" nil t nil "passwd"))
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(cl-loop while (not (eobp)) collect
|
(cl-loop while (not (eobp)) collect
|
||||||
(tramp-parse-etc-group-group))))
|
(tramp-parse-passwd-group))))
|
||||||
(tramp-parse-file filename #'tramp-parse-passwd-group))))
|
(tramp-parse-file filename #'tramp-parse-passwd-group))))
|
||||||
|
|
||||||
(defun tramp-parse-passwd-group ()
|
(defun tramp-parse-passwd-group ()
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
;;; Commentary:
|
;;; Commentary:
|
||||||
|
|
||||||
;; This package provides an implementation of the Desktop Notifications
|
;; This package provides an implementation of the Desktop Notifications
|
||||||
;; <https://developer.gnome.org/notification-spec/>.
|
;; <https://specifications.freedesktop.org/notification-spec/latest/>.
|
||||||
|
|
||||||
;; In order to activate this package, you must add the following code
|
;; In order to activate this package, you must add the following code
|
||||||
;; into your .emacs:
|
;; into your .emacs:
|
||||||
|
|
|
||||||
|
|
@ -32,10 +32,8 @@
|
||||||
|
|
||||||
(declare-function treesit-parser-create "treesit.c")
|
(declare-function treesit-parser-create "treesit.c")
|
||||||
(declare-function treesit-query-capture "treesit.c")
|
(declare-function treesit-query-capture "treesit.c")
|
||||||
(declare-function treesit-induce-sparse-tree "treesit.c")
|
|
||||||
(declare-function treesit-node-child "treesit.c")
|
|
||||||
(declare-function treesit-node-start "treesit.c")
|
|
||||||
(declare-function treesit-node-type "treesit.c")
|
(declare-function treesit-node-type "treesit.c")
|
||||||
|
(declare-function treesit-search-subtree "treesit.c")
|
||||||
|
|
||||||
(defcustom cmake-ts-mode-indent-offset 2
|
(defcustom cmake-ts-mode-indent-offset 2
|
||||||
"Number of spaces for each indentation step in `cmake-ts-mode'."
|
"Number of spaces for each indentation step in `cmake-ts-mode'."
|
||||||
|
|
@ -195,37 +193,14 @@ Check if a node type is available, then return the right font lock rules."
|
||||||
'((ERROR) @font-lock-warning-face))
|
'((ERROR) @font-lock-warning-face))
|
||||||
"Tree-sitter font-lock settings for `cmake-ts-mode'.")
|
"Tree-sitter font-lock settings for `cmake-ts-mode'.")
|
||||||
|
|
||||||
(defun cmake-ts-mode--imenu ()
|
(defun cmake-ts-mode--function-name (node)
|
||||||
"Return Imenu alist for the current buffer."
|
"Return the function name of NODE.
|
||||||
(let* ((node (treesit-buffer-root-node))
|
Return nil if there is no name or if NODE is not a function node."
|
||||||
(func-tree (treesit-induce-sparse-tree
|
(pcase (treesit-node-type node)
|
||||||
node "function_def" nil 1000))
|
("function_command"
|
||||||
(func-index (cmake-ts-mode--imenu-1 func-tree)))
|
|
||||||
(append
|
|
||||||
(when func-index `(("Function" . ,func-index))))))
|
|
||||||
|
|
||||||
(defun cmake-ts-mode--imenu-1 (node)
|
|
||||||
"Helper for `cmake-ts-mode--imenu'.
|
|
||||||
Find string representation for NODE and set marker, then recurse
|
|
||||||
the subtrees."
|
|
||||||
(let* ((ts-node (car node))
|
|
||||||
(children (cdr node))
|
|
||||||
(subtrees (mapcan #'cmake-ts-mode--imenu-1
|
|
||||||
children))
|
|
||||||
(name (when ts-node
|
|
||||||
(pcase (treesit-node-type ts-node)
|
|
||||||
("function_def"
|
|
||||||
(treesit-node-text
|
(treesit-node-text
|
||||||
(treesit-node-child (treesit-node-child ts-node 0) 2) t)))))
|
(treesit-search-subtree node "^argument$" nil nil 2)
|
||||||
(marker (when ts-node
|
t))))
|
||||||
(set-marker (make-marker)
|
|
||||||
(treesit-node-start ts-node)))))
|
|
||||||
(cond
|
|
||||||
((or (null ts-node) (null name)) subtrees)
|
|
||||||
(subtrees
|
|
||||||
`((,name ,(cons name marker) ,@subtrees)))
|
|
||||||
(t
|
|
||||||
`((,name . ,marker))))))
|
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(define-derived-mode cmake-ts-mode prog-mode "CMake"
|
(define-derived-mode cmake-ts-mode prog-mode "CMake"
|
||||||
|
|
@ -242,7 +217,8 @@ the subtrees."
|
||||||
(setq-local comment-start-skip (rx "#" (* (syntax whitespace))))
|
(setq-local comment-start-skip (rx "#" (* (syntax whitespace))))
|
||||||
|
|
||||||
;; Imenu.
|
;; Imenu.
|
||||||
(setq-local imenu-create-index-function #'cmake-ts-mode--imenu)
|
(setq-local treesit-simple-imenu-settings
|
||||||
|
`(("Function" "\\`function_command\\'" nil cmake-ts-mode--function-name)))
|
||||||
(setq-local which-func-functions nil)
|
(setq-local which-func-functions nil)
|
||||||
|
|
||||||
;; Indent.
|
;; Indent.
|
||||||
|
|
|
||||||
|
|
@ -31,10 +31,8 @@
|
||||||
(eval-when-compile (require 'rx))
|
(eval-when-compile (require 'rx))
|
||||||
|
|
||||||
(declare-function treesit-parser-create "treesit.c")
|
(declare-function treesit-parser-create "treesit.c")
|
||||||
(declare-function treesit-induce-sparse-tree "treesit.c")
|
|
||||||
(declare-function treesit-node-child "treesit.c")
|
(declare-function treesit-node-child "treesit.c")
|
||||||
(declare-function treesit-node-child-by-field-name "treesit.c")
|
(declare-function treesit-node-child-by-field-name "treesit.c")
|
||||||
(declare-function treesit-node-start "treesit.c")
|
|
||||||
(declare-function treesit-node-type "treesit.c")
|
(declare-function treesit-node-type "treesit.c")
|
||||||
|
|
||||||
(defvar dockerfile-ts-mode--syntax-table
|
(defvar dockerfile-ts-mode--syntax-table
|
||||||
|
|
@ -118,38 +116,15 @@ continuation to the previous entry."
|
||||||
'((ERROR) @font-lock-warning-face))
|
'((ERROR) @font-lock-warning-face))
|
||||||
"Tree-sitter font-lock settings.")
|
"Tree-sitter font-lock settings.")
|
||||||
|
|
||||||
(defun dockerfile-ts-mode--imenu ()
|
(defun dockerfile-ts-mode--stage-name (node)
|
||||||
"Return Imenu alist for the current buffer."
|
"Return the stage name of NODE.
|
||||||
(let* ((node (treesit-buffer-root-node))
|
Return nil if there is no name or if NODE is not a stage node."
|
||||||
(stage-tree (treesit-induce-sparse-tree
|
(pcase (treesit-node-type node)
|
||||||
node "from_instruction"
|
|
||||||
nil 1000))
|
|
||||||
(stage-index (dockerfile-ts-mode--imenu-1 stage-tree)))
|
|
||||||
(when stage-index `(("Stage" . ,stage-index)))))
|
|
||||||
|
|
||||||
(defun dockerfile-ts-mode--imenu-1 (node)
|
|
||||||
"Helper for `dockerfile-ts-mode--imenu'.
|
|
||||||
Find string representation for NODE and set marker, then recurse
|
|
||||||
the subtrees."
|
|
||||||
(let* ((ts-node (car node))
|
|
||||||
(children (cdr node))
|
|
||||||
(subtrees (mapcan #'dockerfile-ts-mode--imenu-1
|
|
||||||
children))
|
|
||||||
(name (when ts-node
|
|
||||||
(pcase (treesit-node-type ts-node)
|
|
||||||
("from_instruction"
|
("from_instruction"
|
||||||
(treesit-node-text
|
(treesit-node-text
|
||||||
(or (treesit-node-child-by-field-name ts-node "as")
|
(or (treesit-node-child-by-field-name node "as")
|
||||||
(treesit-node-child ts-node 1)) t)))))
|
(treesit-node-child node 1))
|
||||||
(marker (when ts-node
|
t))))
|
||||||
(set-marker (make-marker)
|
|
||||||
(treesit-node-start ts-node)))))
|
|
||||||
(cond
|
|
||||||
((or (null ts-node) (null name)) subtrees)
|
|
||||||
(subtrees
|
|
||||||
`((,name ,(cons name marker) ,@subtrees)))
|
|
||||||
(t
|
|
||||||
`((,name . ,marker))))))
|
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(define-derived-mode dockerfile-ts-mode prog-mode "Dockerfile"
|
(define-derived-mode dockerfile-ts-mode prog-mode "Dockerfile"
|
||||||
|
|
@ -166,8 +141,8 @@ the subtrees."
|
||||||
(setq-local comment-start-skip (rx "#" (* (syntax whitespace))))
|
(setq-local comment-start-skip (rx "#" (* (syntax whitespace))))
|
||||||
|
|
||||||
;; Imenu.
|
;; Imenu.
|
||||||
(setq-local imenu-create-index-function
|
(setq-local treesit-simple-imenu-settings
|
||||||
#'dockerfile-ts-mode--imenu)
|
`(("Stage" "\\`from_instruction\\'" nil dockerfile-ts-mode--stage-name)))
|
||||||
(setq-local which-func-functions nil)
|
(setq-local which-func-functions nil)
|
||||||
|
|
||||||
;; Indent.
|
;; Indent.
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,8 @@
|
||||||
(require 'treesit)
|
(require 'treesit)
|
||||||
|
|
||||||
(ert-deftest typescript-ts-mode-test-indentation ()
|
(ert-deftest typescript-ts-mode-test-indentation ()
|
||||||
(skip-unless (treesit-ready-p 'typescript))
|
(skip-unless (and (treesit-ready-p 'typescript)
|
||||||
|
(treesit-ready-p 'tsx)))
|
||||||
(ert-test-erts-file (ert-resource-file "indent.erts")))
|
(ert-test-erts-file (ert-resource-file "indent.erts")))
|
||||||
|
|
||||||
(provide 'typescript-ts-mode-tests)
|
(provide 'typescript-ts-mode-tests)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue