Merge from origin/emacs-29

f1f571e72a Add electric indent for preproc directives
83af806ab7 Rename 'emacs-news-toggle-tag' to 'emacs-news-cycle-tag'
5bc88b3b17 Add menu to news-mode
40f4bc4e0a ; Avoid installing VC package dependencies multiple times
1c9d81a2b4 Attempt to recognise if a VC package has no Elisp files
This commit is contained in:
Stefan Kangas 2023-02-17 06:30:17 +01:00
commit 23089f1cf2
5 changed files with 41 additions and 10 deletions

View file

@ -440,7 +440,7 @@ version of that package."
(package-desc-version a)))
(duplicate-p (a b)
"Are A and B the same package?"
(equal a (car b)))
(eq (package-desc-name a) (package-desc-name b)))
(depends-on-p (target package)
"Does PACKAGE depend on TARGET?"
(or (eq target package)
@ -457,7 +457,7 @@ version of that package."
(depends-on-p desc-a desc-b)))))
(mapc #'search requirements)
(cl-callf sort to-install #'version-order)
(cl-callf seq-uniq to-install)
(cl-callf seq-uniq to-install #'duplicate-p)
(cl-callf sort to-install #'dependent-order))
(mapc #'package-install-from-archive to-install)
missing))
@ -602,6 +602,13 @@ attribute in PKG-SPEC."
(vc-retrieve-tag dir release-rev)
(message "No release revision was found, continuing...")))))
(defvar package-vc-non-code-file-names
'(".dir-locals.el" ".dir-locals-2.el")
"List of file names that do not contain Emacs Lisp code.
This list is used by `package-vc--unpack' to better check if the
user is fetching code from a repository that does not contain any
Emacs Lisp files.")
(defun package-vc--unpack (pkg-desc pkg-spec &optional rev)
"Install the package described by PKG-DESC.
PKG-SPEC is a package specification, a property list describing
@ -623,6 +630,14 @@ checkout. This overrides the `:branch' attribute in PKG-SPEC."
(when (directory-empty-p pkg-dir)
(delete-directory pkg-dir)
(error "Empty checkout for %s" name))
(unless (seq-remove
(lambda (file)
(member (file-name-nondirectory file) package-vc-non-code-file-names))
(directory-files-recursively pkg-dir "\\.el\\'" nil))
(when (yes-or-no-p (format "No Emacs Lisp files found when fetching \"%s\", \
abort installation?" name))
(delete-directory pkg-dir t)
(user-error "Installation aborted")))
;; When nothing is specified about a `lisp-dir', then should
;; heuristically check if there is a sub-directory with lisp

View file

@ -219,6 +219,7 @@ delimiters < and >'s."
MODE is either `c' or `cpp'."
(let ((common
`(((parent-is "translation_unit") point-min 0)
((query "(ERROR (ERROR)) @indent") point-min 0)
((node-is ")") parent 1)
((node-is "]") parent-bol 0)
((node-is "else") parent-bol 0)
@ -816,7 +817,7 @@ the semicolon. This function skips the semicolon."
;; Electric
(setq-local electric-indent-chars
(append "{}():;," electric-indent-chars))
(append "{}():;,#" electric-indent-chars))
;; Imenu.
(setq-local treesit-simple-imenu-settings

View file

@ -53,13 +53,28 @@
:parent emacs-news-common-map
"C-c C-s" #'emacs-news-next-untagged-entry
"C-c C-r" #'emacs-news-previous-untagged-entry
"C-c C-t" #'emacs-news-toggle-tag
"C-c C-t" #'emacs-news-cycle-tag
"C-c C-d" #'emacs-news-delete-temporary-markers
"C-c C-g" #'emacs-news-goto-section
"C-c C-j" #'emacs-news-find-heading
"C-c C-e" #'emacs-news-count-untagged-entries
"C-x C-q" #'emacs-news-view-mode
"<remap> <open-line>" #'emacs-news-open-line)
(easy-menu-define emacs-news-mode-menu emacs-news-mode-map
"Menu for `emacs-news-mode'."
'("News"
["Next Untagged" emacs-news-next-untagged-entry :help "Go to next untagged entry"]
["Previous Untagged" emacs-news-previous-untagged-entry :help "Go to previous untagged entry"]
["Count Untagged" emacs-news-count-untagged-entries :help "Count the number of untagged entries"]
["Cycle Tag" emacs-news-cycle-tag :help "Cycle documentation tag of current entry"]
["Delete Tags" emacs-news-delete-temporary-markers :help "Delete all documentation tags in buffer"]
"--"
["Goto Section" emacs-news-goto-section :help "Prompt for section and go to it"]
["Goto Heading" emacs-news-find-heading :help "Prompt for heading and go to it"]
"--"
["Enter View Mode" emacs-news-view-mode :help "Enter view-only mode"]))
(defvar emacs-news-view-mode-map
;; This is defined this way instead of inheriting because we're
;; deriving the mode from `special-mode' and want the keys from there.
@ -173,8 +188,8 @@ untagged NEWS entry."
(interactive nil emacs-news-mode)
(emacs-news-next-untagged-entry t))
(defun emacs-news-toggle-tag ()
"Toggle documentation tag of current headline in the Emacs NEWS file."
(defun emacs-news-cycle-tag ()
"Cycle documentation tag of current headline in the Emacs NEWS file."
(interactive nil emacs-news-mode)
(save-excursion
(goto-char (line-beginning-position))
@ -191,7 +206,7 @@ untagged NEWS entry."
(insert "+++"))
((looking-at (rx bol "+++" eol))
(delete-char 4))
(t (user-error "Invalid headline tag; can't toggle")))))
(t (user-error "Invalid headline tag; can't cycle")))))
(defun emacs-news-count-untagged-entries ()
"Say how many untagged entries there are in the current NEWS buffer."

View file

@ -23,10 +23,10 @@
(require 'ert-x)
(require 'emacs-news-mode)
(ert-deftest emacs-news-toggle-tag ()
(ert-test-erts-file (ert-resource-file "toggle-tag.erts")
(ert-deftest emacs-news-cycle-tag ()
(ert-test-erts-file (ert-resource-file "cycle-tag.erts")
(lambda ()
(emacs-news-mode)
(emacs-news-toggle-tag))))
(emacs-news-cycle-tag))))
;;; emacs-news-mode-tests.el ends here