diff --git a/lisp/f.el b/lisp/f.el index 012727c3..6f9b83f1 100644 --- a/lisp/f.el +++ b/lisp/f.el @@ -5,7 +5,8 @@ ;; Author: Johan Andersson ;; Maintainer: Johan Andersson ;; Version: 0.20.0 -;; Package-Version: 20191110.1357 +;; Package-Version: 20210624.1103 +;; Package-Commit: 50af874cd19042f17c8686813d52569b1025c76a ;; Keywords: files, directories ;; URL: http://github.com/rejeep/f.el ;; Package-Requires: ((s "1.7.0") (dash "2.2.0")) @@ -181,7 +182,13 @@ ending slash." (--mapcat (let ((conf-files (cdr it))) (if (> (length conf-files) 1) - (--map (cons (car it) (concat (f-filename (s-chop-suffix (cdr it) (car it))) (f-path-separator) (cdr it))) conf-files) + (--map (cons + (car it) + (concat + (f-filename (s-chop-suffix (cdr it) + (car it))) + (f-path-separator) (cdr it))) + conf-files) conf-files)) uniq-filenames-next)))) uniq-filenames-next)) @@ -201,14 +208,16 @@ This function expects no duplicate paths." ;;;; I/O -(defun f-read-bytes (path) +(defun f-read-bytes (path &optional beg end) "Read binary data from PATH. -Return the binary data as unibyte string." +Return the binary data as unibyte string. The optional second and +third arguments BEG and END specify what portion of the file to +read." (with-temp-buffer (set-buffer-multibyte nil) (setq buffer-file-coding-system 'binary) - (insert-file-contents-literally path) + (insert-file-contents-literally path nil beg end) (buffer-substring-no-properties (point-min) (point-max)))) (defalias 'f-read 'f-read-text) diff --git a/lisp/flycheck/flycheck-pkg.el b/lisp/flycheck/flycheck-pkg.el index 08f646e2..5e34dc8d 100644 --- a/lisp/flycheck/flycheck-pkg.el +++ b/lisp/flycheck/flycheck-pkg.el @@ -1,10 +1,10 @@ -(define-package "flycheck" "20201228.2104" "On-the-fly syntax checking" +(define-package "flycheck" "20210825.1804" "On-the-fly syntax checking" '((dash "2.12.1") (pkg-info "0.4") (let-alist "1.0.4") (seq "1.11") (emacs "24.3")) - :commit "01396a5eff9fa494285e0d3139838231c05e3948" :authors + :commit "784f184cdd9f9cb4e3dbb997c09d93e954142842" :authors '(("Sebastian Wiesner" . "swiesner@lunaryorn.com")) :maintainer '("Clément Pit-Claudel" . "clement.pitclaudel@live.com") diff --git a/lisp/flycheck/flycheck.el b/lisp/flycheck/flycheck.el index 30a4a384..b88335b5 100644 --- a/lisp/flycheck/flycheck.el +++ b/lisp/flycheck/flycheck.el @@ -360,7 +360,7 @@ A syntax checker assigned to this variable must be defined with Use the command `flycheck-select-checker' to select a syntax checker for the current buffer, or set this variable as file local variable to always use a specific syntax checker for a -file. See Info Node `(emacs)Specifying File Variables' for more +file. See Info Node `(Emacs)Specifying File Variables' for more information about file variables.") (put 'flycheck-checker 'safe-local-variable 'flycheck-registered-checker-p) @@ -2052,6 +2052,17 @@ are mandatory. be found online at URL. - nil if there is no explanation for this error. + If URL is provided by the checker, and cannot be composed + from other elements in the `flycheck-error' object, consider + passing the URL via text properties: + + ;; During the error object creation + (put-text-property 0 1 'explainer-url .url .check_id) + + ;; In the error-explainer FUNCTION + (let ((id (flycheck-error-id err))) + (and id `(url . ,(get-text-property 0 'explainer-url id)))) + This property is optional. `:next-checkers NEXT-CHECKERS' @@ -3806,7 +3817,7 @@ the THING at the column, and END the end of the THING." (`symbols ;; Ensure that we're on a word or symbol. See ;; https://github.com/flycheck/flycheck/issues/1519 - (and (< beg (point-max)) + (and (<= (point-min) beg) (< beg (point-max)) (memq (char-syntax (char-after beg)) '(?w ?_)) (flycheck-bounds-of-thing-at-point 'symbol beg))) (`sexps @@ -8391,15 +8402,21 @@ Requires DMD 2.066 or newer. See URL `https://dlang.org/'." "A Dockerfile syntax checker using the hadolint. See URL `http://github.com/hadolint/hadolint/'." - :command ("hadolint" "-") + :command ("hadolint" "--no-color" "-") :standard-input t :error-patterns ((error line-start - (file-name) ":" line ":" column " " (message) + (file-name) ":" line " " (id (one-or-more alnum)) " error: " (message) line-end) (warning line-start - (file-name) ":" line " " (id (one-or-more alnum)) " " (message) - line-end)) + (file-name) ":" line " " (id (one-or-more alnum)) + " warning: " (message) line-end) + (info line-start + (file-name) ":" line " " (id (one-or-more alnum)) " info: " (message) + line-end) + (error line-start + (file-name) ":" line ":" column " " (message) + line-end)) :error-filter (lambda (errors) (flycheck-sanitize-errors @@ -8595,7 +8612,7 @@ This variable has no effect, if (setq flycheck-emacs-lisp-check-declare ,value))))) (defun flycheck--emacs-lisp-enabled-p () - "Check whether to enable Emacs Lisp checkers in the current buffer." + "Check whether to enable Emacs Lisp checker in the current buffer." (not (or ;; Do not check buffers used for autoloads generation during package @@ -8612,6 +8629,12 @@ This variable has no effect, if (member (file-name-nondirectory (buffer-file-name)) '("Cask" "Carton" ".dir-locals.el" ".dir-locals-2.el")))))) +(defun flycheck--emacs-lisp-checkdoc-enabled-p () + "Check whether to enable Emacs Lisp Checkdoc in the current buffer." + (and (flycheck--emacs-lisp-enabled-p) + ;; These files are valid Lisp, but don't contain "standard" comments. + (not (member (buffer-file-name) '("Eldev" "Eldev-local"))))) + (flycheck-define-checker emacs-lisp "An Emacs Lisp syntax checker using the Emacs Lisp Byte compiler. @@ -8731,7 +8754,7 @@ The checker runs `checkdoc-current-buffer'." :error-patterns ((info line-start (file-name) ":" line ": " (message) line-end)) :modes (emacs-lisp-mode) - :enabled flycheck--emacs-lisp-enabled-p) + :enabled flycheck--emacs-lisp-checkdoc-enabled-p) (dolist (checker '(emacs-lisp emacs-lisp-checkdoc)) (setf (car (flycheck-checker-get checker 'command)) @@ -10428,6 +10451,35 @@ because it adds the current directory to Python's path)." `("-c" ,(concat "import sys;sys.path.pop(0);import runpy;" (format "runpy.run_module(%S)" module-name))))) +(defcustom flycheck-python-project-files + '("pyproject.toml" "setup.cfg" "mypy.ini" "pyrightconfig.json") + "Files used to find where to run Python checkers from. +Currently used for pylint, flake8, and pyright. + +The presence of one in these files indicates the root of the +current project; `.pylintrc' is not part of the list because it +is commonly found in ~/." + :group 'flycheck + :type '(repeat (string :tag "File name")) + :package-version '(flycheck . "0.33") + :safe #'flycheck-string-list-p) + +(defun flycheck-python-find-project-root (_checker) + "Find the root directory of a Python project. + +The root directory is assumed to be the nearest parent directory +that contains one of `flycheck-python-project-files'. If no such +file is found, we use the same heuristic as epylint: the nearest +parent directory that doesn't have a __init__.py file." + (let ((start (if buffer-file-name + (file-name-directory buffer-file-name) + default-directory))) + (or (flycheck--locate-dominating-file-matching + start (regexp-opt flycheck-python-project-files)) + (locate-dominating-file + start (lambda (dir) + (not (file-exists-p (expand-file-name "__init__.py" dir)))))))) + (flycheck-def-config-file-var flycheck-flake8rc python-flake8 ".flake8rc") (flycheck-def-option-var flycheck-flake8-error-level-alist @@ -10524,7 +10576,7 @@ Requires Flake8 3.0 or newer. See URL (concat "--stdin-display-name=" buffer-file-name))) "-") :standard-input t - :working-directory flycheck-flake8--find-project-root + :working-directory flycheck-python-find-project-root :error-filter (lambda (errors) (let ((errors (flycheck-sanitize-errors errors))) (seq-map #'flycheck-flake8-fix-error-level errors))) @@ -10542,7 +10594,9 @@ Requires Flake8 3.0 or newer. See URL :next-checkers ((warning . python-pylint) (warning . python-mypy))) -(flycheck-def-config-file-var flycheck-pylintrc python-pylint ".pylintrc") +(flycheck-def-config-file-var + flycheck-pylintrc python-pylint + '("pylintrc" ".pylintrc" "pyproject.toml" "setup.cfg")) (flycheck-def-option-var flycheck-pylint-use-symbolic-id t python-pylint "Whether to use pylint message symbols or message codes. @@ -10595,6 +10649,7 @@ See URL `https://www.pylint.org/'." ;; import bar'), see https://github.com/flycheck/flycheck/issues/280 source-inplace) :error-parser flycheck-parse-pylint + :working-directory flycheck-python-find-project-root :enabled (lambda () (or (not (flycheck-python-needs-module-p 'python-pylint)) (flycheck-python-find-module 'python-pylint "pylint"))) @@ -10627,6 +10682,7 @@ See URL `https://docs.python.org/3.4/library/py_compile.html'." (error line-start "SyntaxError: ('" (message (one-or-more (not (any "'")))) "', ('" (file-name (one-or-more (not (any "'")))) "', " line ", " column ", " (one-or-more not-newline) line-end)) + :working-directory flycheck-python-find-project-root :modes python-mode :next-checkers ((warning . python-mypy))) @@ -10652,11 +10708,6 @@ the BUFFER that was checked respectively." :filename (buffer-file-name buffer)))) (cdr (nth 2 (car (flycheck-parse-json output)))))) -(defun flycheck-pyright--find-project-root (_checker) - "Find project root by searching for pyright config file." - (locate-dominating-file - (or buffer-file-name default-directory) "pyrightconfig.json")) - (flycheck-define-checker python-pyright "Static type checker for Python @@ -10664,7 +10715,7 @@ See URL https://github.com/microsoft/pyright." :command ("pyright" "--outputjson" source-inplace) - :working-directory flycheck-pyright--find-project-root + :working-directory flycheck-python-find-project-root :error-parser flycheck-pyright--parse-error :modes python-mode) @@ -10672,7 +10723,7 @@ See URL https://github.com/microsoft/pyright." 'flycheck-python-mypy-config "32") (flycheck-def-config-file-var flycheck-python-mypy-config python-mypy - '("mypy.ini" "setup.cfg")) + '("mypy.ini" "pyproject.toml" "setup.cfg")) (flycheck-def-option-var flycheck-python-mypy-cache-dir nil python-mypy "Directory used to write .mypy_cache directories." @@ -10699,6 +10750,7 @@ See URL `http://mypy-lang.org/'." ": warning:" (message) line-end) (info line-start (file-name) ":" line (optional ":" column) ": note:" (message) line-end)) + :working-directory flycheck-python-find-project-root :modes python-mode ;; Ensure the file is saved, to work around ;; https://github.com/python/mypy/issues/4746. @@ -10914,7 +10966,7 @@ See URL `https://git.io/vhi2t'." See URL `https://github.com/markdownlint/markdownlint'." :command ("mdl" (config-file "--style" flycheck-markdown-mdl-style) - (option "--tags=" flycheck-markdown-mdl-rules concat + (option "--tags=" flycheck-markdown-mdl-tags concat flycheck-option-comma-separated-list) (option "--rules=" flycheck-markdown-mdl-rules concat flycheck-option-comma-separated-list)) @@ -10937,6 +10989,10 @@ See URL `https://nixos.org/nix/manual/#sec-nix-instantiate'." :standard-input t :error-patterns ((error line-start + "error: " (message) + (one-or-more "\n") + (zero-or-more space) "at «stdin»:" line ":" column ":" line-end) + (error line-start "at: (" line ":" column ") from stdin" (one-or-more "\n" (zero-or-more space (one-or-more not-newline))) (message) line-end) @@ -12354,9 +12410,14 @@ See URL `https://github.com/nodeca/js-yaml'." ((error line-start (or "JS-YAML" "YAMLException") ": " (message) " at line " line ", column " column ":" + line-end) + (error line-start + (or "JS-YAML" "YAMLException") ": " + (message) " (" line ":" column ")" line-end)) :modes yaml-mode - :next-checkers ((warning . cwl))) + :next-checkers ((warning . yaml-yamllint) + (warning . cwl))) (flycheck-define-checker yaml-ruby "A YAML syntax checker using Ruby's YAML parser. @@ -12375,7 +12436,8 @@ See URL `http://www.ruby-doc.org/stdlib-2.0.0/libdoc/yaml/rdoc/YAML.html'." ((error line-start "stdin:" (zero-or-more not-newline) ":" (message) "at line " line " column " column line-end)) :modes yaml-mode - :next-checkers ((warning . cwl))) + :next-checkers ((warning . yaml-yamllint) + (warning . cwl))) (flycheck-def-config-file-var flycheck-yamllintrc yaml-yamllint ".yamllint") @@ -12390,7 +12452,8 @@ See URL `https://github.com/adrienverge/yamllint'." "stdin:" line ":" column ": [error] " (message) line-end) (warning line-start "stdin:" line ":" column ": [warning] " (message) line-end)) - :modes yaml-mode) + :modes yaml-mode + :next-checkers ((warning . cwl))) (provide 'flycheck) diff --git a/lisp/git-commit/git-commit-pkg.el b/lisp/git-commit/git-commit-pkg.el new file mode 100644 index 00000000..d880e45d --- /dev/null +++ b/lisp/git-commit/git-commit-pkg.el @@ -0,0 +1,18 @@ +(define-package "git-commit" "20220101.841" "Edit Git commit messages." + '((emacs "25.1") + (dash "20210826") + (transient "20210920") + (with-editor "20211001")) + :commit "2e73b66c2980abb9211d9881a8710c8ac5a33184" :authors + '(("Jonas Bernoulli" . "jonas@bernoul.li") + ("Sebastian Wiesner" . "lunaryorn@gmail.com") + ("Florian Ragwitz" . "rafl@debian.org") + ("Marius Vollmer" . "marius.vollmer@gmail.com")) + :maintainer + '("Jonas Bernoulli" . "jonas@bernoul.li") + :keywords + '("git" "tools" "vc") + :url "https://github.com/magit/magit") +;; Local Variables: +;; no-byte-compile: t +;; End: diff --git a/lisp/git-commit.el b/lisp/git-commit/git-commit.el similarity index 82% rename from lisp/git-commit.el rename to lisp/git-commit/git-commit.el index fc147885..d637b2a4 100644 --- a/lisp/git-commit.el +++ b/lisp/git-commit/git-commit.el @@ -1,34 +1,32 @@ ;;; git-commit.el --- Edit Git commit messages -*- lexical-binding: t; -*- -;; Copyright (C) 2010-2020 The Magit Project Contributors +;; Copyright (C) 2010-2022 The Magit Project Contributors ;; ;; You should have received a copy of the AUTHORS.md file which ;; lists all contributors. If not, see http://magit.vc/authors. -;; Authors: Jonas Bernoulli -;; Sebastian Wiesner -;; Florian Ragwitz -;; Marius Vollmer +;; Author: Jonas Bernoulli +;; Sebastian Wiesner +;; Florian Ragwitz +;; Marius Vollmer ;; Maintainer: Jonas Bernoulli -;; Package-Requires: ((emacs "25.1") (dash "20200524") (transient "20200601") (with-editor "20200522")) -;; Package-Version: 20201222.1527 -;; Package-Commit: c5e11811197ef8c667a605e5d9dd8ec77247bd13 ;; Keywords: git tools vc ;; Homepage: https://github.com/magit/magit - -;; This file is not part of GNU Emacs. +;; Package-Requires: ((emacs "25.1") (transient "0.3.6") (with-editor "3.0.5")) +;; Package-Version: 3.3.0 +;; SPDX-License-Identifier: GPL-3.0-or-later ;; This file 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, or (at your option) ;; any later version. - +;; ;; This file 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 this file. If not, see . @@ -114,18 +112,21 @@ ;;; Code: ;;;; Dependencies -(require 'dash) -(require 'log-edit) +(require 'seq) +(require 'subr-x) + (require 'magit-git nil t) +(require 'magit-mode nil t) (require 'magit-utils nil t) + +(require 'log-edit) (require 'ring) +(require 'rx) (require 'server) (require 'transient) (require 'with-editor) -(eval-when-compile - (require 'recentf) - (require 'subr-x)) +(defvar recentf-exclude) ;;;; Declarations @@ -152,13 +153,21 @@ :link '(info-link "(magit)Editing Commit Messages") :group 'tools) -;;;###autoload (define-minor-mode global-git-commit-mode "Edit Git commit messages. + This global mode arranges for `git-commit-setup' to be called when a Git commit message file is opened. That usually happens when Git uses the Emacsclient as $GIT_EDITOR to have the user -provide such a commit message." +provide such a commit message. + +Loading the library `git-commit' by default enables this mode, +but the library is not automatically loaded because doing that +would pull in many dependencies and increase startup time too +much. You can either rely on `magit' loading this library or +you can load it explicitly. Autoloading is not an alternative +because in this case autoloading would immediately trigger +full loading." :group 'git-commit :type 'boolean :global t @@ -179,8 +188,17 @@ The major mode configured here is turned on by the minor mode :type '(choice (function-item text-mode) (function-item markdown-mode) (function-item org-mode) + (function-item fundamental-mode) + (function-item git-commit-elisp-text-mode) (function :tag "Another mode") (const :tag "No major mode"))) +;;;###autoload(put 'git-commit-major-mode 'safe-local-variable +;;;###autoload (lambda (val) +;;;###autoload (memq val '(text-mode +;;;###autoload markdown-mode +;;;###autoload org-mode +;;;###autoload fundamental-mode +;;;###autoload git-commit-elisp-text-mode)))) (defcustom git-commit-setup-hook '(git-commit-save-message @@ -197,6 +215,7 @@ The major mode configured here is turned on by the minor mode git-commit-setup-changelog-support magit-generate-changelog git-commit-turn-on-auto-fill + git-commit-turn-on-orglink git-commit-turn-on-flyspell git-commit-propertize-diff bug-reference-mode @@ -286,9 +305,19 @@ already using it, then you probably shouldn't start doing so." "Co-authored-by") "A list of Git pseudo headers to be highlighted." :group 'git-commit - :safe (lambda (val) (and (listp val) (-all-p 'stringp val))) + :safe (lambda (val) (and (listp val) (seq-every-p #'stringp val))) :type '(repeat string)) +(defcustom git-commit-use-local-message-ring nil + "Whether to use a local message ring instead of the global one. +This can be set globally, in which case every repository gets its +own commit message ring, or locally for a single repository. If +Magit isn't available, then setting this to a non-nil value has +no effect." + :group 'git-commit + :safe 'booleanp + :type 'boolean) + ;;;; Faces (defgroup git-commit-faces nil @@ -375,6 +404,8 @@ This is only used if Magit is available." (let ((map (make-sparse-keymap))) (define-key map (kbd "M-p") 'git-commit-prev-message) (define-key map (kbd "M-n") 'git-commit-next-message) + (define-key map (kbd "C-c M-p") 'git-commit-search-message-backward) + (define-key map (kbd "C-c M-n") 'git-commit-search-message-forward) (define-key map (kbd "C-c C-i") 'git-commit-insert-pseudo-header) (define-key map (kbd "C-c C-a") 'git-commit-ack) (define-key map (kbd "C-c M-i") 'git-commit-suggested) @@ -422,13 +453,12 @@ This is only used if Magit is available." ;;; Hooks -;;;###autoload (defconst git-commit-filename-regexp "/\\(\ \\(\\(COMMIT\\|NOTES\\|PULLREQ\\|MERGEREQ\\|TAG\\)_EDIT\\|MERGE_\\|\\)MSG\ \\|\\(BRANCH\\|EDIT\\)_DESCRIPTION\\)\\'") -(eval-after-load 'recentf - '(add-to-list 'recentf-exclude git-commit-filename-regexp)) +(with-eval-after-load 'recentf + (add-to-list 'recentf-exclude git-commit-filename-regexp)) (add-to-list 'with-editor-file-name-history-exclude git-commit-filename-regexp) @@ -439,7 +469,6 @@ This is only used if Magit is available." (add-hook 'after-change-major-mode-hook 'git-commit-setup-font-lock-in-buffer) -;;;###autoload (defun git-commit-setup-check-buffer () (and buffer-file-name (string-match-p git-commit-filename-regexp buffer-file-name) @@ -450,24 +479,27 @@ This is only used if Magit is available." (defun git-commit-file-not-found () ;; cygwin git will pass a cygwin path (/cygdrive/c/foo/.git/...), ;; try to handle this in window-nt Emacs. - (--when-let - (and (or (string-match-p git-commit-filename-regexp buffer-file-name) - (and (boundp 'git-rebase-filename-regexp) - (string-match-p git-rebase-filename-regexp - buffer-file-name))) - (not (file-accessible-directory-p - (file-name-directory buffer-file-name))) - (if (require 'magit-git nil t) - ;; Emacs prepends a "c:". - (magit-expand-git-file-name (substring buffer-file-name 2)) - ;; Fallback if we can't load `magit-git'. - (and (string-match "\\`[a-z]:/\\(cygdrive/\\)?\\([a-z]\\)/\\(.*\\)" - buffer-file-name) - (concat (match-string 2 buffer-file-name) ":/" - (match-string 3 buffer-file-name))))) - (when (file-accessible-directory-p (file-name-directory it)) + (when-let + ((file (and (or (string-match-p git-commit-filename-regexp + buffer-file-name) + (and (boundp 'git-rebase-filename-regexp) + (string-match-p git-rebase-filename-regexp + buffer-file-name))) + (not (file-accessible-directory-p + (file-name-directory buffer-file-name))) + (if (require 'magit-git nil t) + ;; Emacs prepends a "c:". + (magit-expand-git-file-name + (substring buffer-file-name 2)) + ;; Fallback if we can't load `magit-git'. + (and (string-match + "\\`[a-z]:/\\(cygdrive/\\)?\\([a-z]\\)/\\(.*\\)" + buffer-file-name) + (concat (match-string 2 buffer-file-name) ":/" + (match-string 3 buffer-file-name))))))) + (when (file-accessible-directory-p (file-name-directory file)) (let ((inhibit-read-only t)) - (insert-file-contents it t) + (insert-file-contents file t) t)))) (when (eq system-type 'windows-nt) @@ -479,13 +511,23 @@ Type \\[with-editor-finish] to finish, \ \\[git-commit-prev-message] and \\[git-commit-next-message] \ to recover older messages") -;;;###autoload (defun git-commit-setup () (when (fboundp 'magit-toplevel) ;; `magit-toplevel' is autoloaded and defined in magit-git.el, ;; That library declares this functions without loading ;; magit-process.el, which defines it. (require 'magit-process nil t)) + (when git-commit-major-mode + (let ((auto-mode-alist (list (cons (concat "\\`" + (regexp-quote buffer-file-name) + "\\'") + git-commit-major-mode))) + ;; The major-mode hook might want to consult these minor + ;; modes, while the minor-mode hooks might want to consider + ;; the major mode. + (git-commit-mode t) + (with-editor-mode t)) + (normal-mode t))) ;; Pretend that git-commit-mode is a major-mode, ;; so that directory-local settings can be used. (let ((default-directory @@ -502,17 +544,6 @@ to recover older messages") (major-mode 'git-commit-mode)) ; trick dir-locals-collect-variables (hack-dir-local-variables) (hack-local-variables-apply))) - (when git-commit-major-mode - (let ((auto-mode-alist (list (cons (concat "\\`" - (regexp-quote buffer-file-name) - "\\'") - git-commit-major-mode))) - ;; The major-mode hook might want to consult these minor - ;; modes, while the minor-mode hooks might want to consider - ;; the major mode. - (git-commit-mode t) - (with-editor-mode t)) - (normal-mode t))) ;; Show our own message using our hook. (setq with-editor-show-usage nil) (setq with-editor-usage-message git-commit-usage-message) @@ -541,9 +572,9 @@ to recover older messages") (magit-wip-maybe-add-commit-hook))) (setq with-editor-cancel-message 'git-commit-cancel-message) - (make-local-variable 'log-edit-comment-ring-index) (git-commit-mode 1) (git-commit-setup-font-lock) + (git-commit-prepare-message-ring) (when (boundp 'save-place) (setq save-place nil)) (save-excursion @@ -595,6 +626,16 @@ to `git-commit-fill-column'." (setq-local comment-auto-fill-only-comments nil) (turn-on-auto-fill)) +(defun git-commit-turn-on-orglink () + "Turn on Orglink mode if it is available. +If `git-commit-major-mode' is `org-mode', then silently forgo +turning on `orglink-mode'." + (when (and (not (derived-mode-p 'org-mode)) + (boundp 'orglink-match-anywhere) + (fboundp 'orglink-mode)) + (setq-local orglink-match-anywhere t) + (orglink-mode 1))) + (defun git-commit-turn-on-flyspell () "Unconditionally turn on Flyspell mode. Also prevent comments from being checked and @@ -626,7 +667,7 @@ finally check current non-comment text." "Check for violations of certain basic style conventions. For each violation ask the user if she wants to proceed anyway. -Option `git-commit-check-style-conventions' controls which +Option `git-commit-style-convention-checks' controls which conventions are checked." (or force (save-excursion @@ -655,17 +696,29 @@ conventions are checked." "Cycle backward through message history, after saving current message. With a numeric prefix ARG, go back ARG comments." (interactive "*p") - (when (and (git-commit-save-message) (> arg 0)) - (setq log-edit-comment-ring-index - (log-edit-new-comment-index - arg (ring-length log-edit-comment-ring)))) - (save-restriction - (goto-char (point-min)) - (narrow-to-region (point) - (if (re-search-forward (concat "^" comment-start) nil t) - (max 1 (- (point) 2)) - (point-max))) - (log-edit-previous-comment arg))) + (let ((len (ring-length log-edit-comment-ring))) + (if (<= len 0) + (progn (message "Empty comment ring") (ding)) + ;; Unlike `log-edit-previous-comment' we save the current + ;; non-empty and newly written comment, because otherwise + ;; it would be irreversibly lost. + (when-let ((message (git-commit-buffer-message))) + (unless (ring-member log-edit-comment-ring message) + (ring-insert log-edit-comment-ring message) + (cl-incf arg) + (setq len (ring-length log-edit-comment-ring)))) + ;; Delete the message but not the instructions at the end. + (save-restriction + (goto-char (point-min)) + (narrow-to-region + (point) + (if (re-search-forward (concat "^" comment-start) nil t) + (max 1 (- (point) 2)) + (point-max))) + (delete-region (point-min) (point))) + (setq log-edit-comment-ring-index (log-edit-new-comment-index arg len)) + (message "Comment %d" (1+ log-edit-comment-ring-index)) + (insert (ring-ref log-edit-comment-ring log-edit-comment-ring-index))))) (defun git-commit-next-message (arg) "Cycle forward through message history, after saving current message. @@ -673,13 +726,53 @@ With a numeric prefix ARG, go forward ARG comments." (interactive "*p") (git-commit-prev-message (- arg))) +(defun git-commit-search-message-backward (string) + "Search backward through message history for a match for STRING. +Save current message first." + (interactive + ;; Avoid `format-prompt' because it isn't available until Emacs 28. + (list (read-string (format "Comment substring (default %s): " + log-edit-last-comment-match) + nil nil log-edit-last-comment-match))) + (cl-letf (((symbol-function #'log-edit-previous-comment) + (symbol-function #'git-commit-prev-message))) + (log-edit-comment-search-backward string))) + +(defun git-commit-search-message-forward (string) + "Search forward through message history for a match for STRING. +Save current message first." + (interactive + ;; Avoid `format-prompt' because it isn't available until Emacs 28. + (list (read-string (format "Comment substring (default %s): " + log-edit-last-comment-match) + nil nil log-edit-last-comment-match))) + (cl-letf (((symbol-function #'log-edit-previous-comment) + (symbol-function #'git-commit-prev-message))) + (log-edit-comment-search-forward string))) + (defun git-commit-save-message () "Save current message to `log-edit-comment-ring'." (interactive) - (when-let ((message (git-commit-buffer-message))) - (when-let ((index (ring-member log-edit-comment-ring message))) - (ring-remove log-edit-comment-ring index)) - (ring-insert log-edit-comment-ring message))) + (if-let ((message (git-commit-buffer-message))) + (progn + (when-let ((index (ring-member log-edit-comment-ring message))) + (ring-remove log-edit-comment-ring index)) + (ring-insert log-edit-comment-ring message) + (when (and git-commit-use-local-message-ring + (fboundp 'magit-repository-local-set)) + (magit-repository-local-set 'log-edit-comment-ring + log-edit-comment-ring)) + (message "Message saved")) + (message "Only whitespace and/or comments; message not saved"))) + +(defun git-commit-prepare-message-ring () + (make-local-variable 'log-edit-comment-ring-index) + (when (and git-commit-use-local-message-ring + (fboundp 'magit-repository-local-get)) + (setq-local log-edit-comment-ring + (magit-repository-local-get + 'log-edit-comment-ring + (make-ring log-edit-maximum-comment-ring-size))))) (defun git-commit-buffer-message () (let ((flush (concat "^" comment-start)) @@ -860,7 +953,8 @@ Added to `font-lock-extend-region-functions'." "Changes not staged for commit:" "Unmerged paths:" "Author:" - "Date:")) + "Date:") + "Also fontified outside of comments in `git-commit-font-lock-keywords-2'.") (defconst git-commit-font-lock-keywords-1 '(;; Pseudo headers @@ -868,8 +962,6 @@ Added to `font-lock-extend-region-functions'." (regexp-opt git-commit-known-pseudo-headers)) (1 'git-commit-known-pseudo-header) (2 'git-commit-pseudo-header))) - ("^[-a-zA-Z]+: [^<]+? <[^>]+>" - (0 'git-commit-pseudo-header)) ;; Summary (eval . `(,(git-commit-summary-regexp) (1 'git-commit-summary))) @@ -895,7 +987,13 @@ Added to `font-lock-extend-region-functions'." (1 'git-commit-comment-heading t))) (eval . `(,(format "^%s\t\\(?:\\([^:\n]+\\):\\s-+\\)?\\(.*\\)" comment-start) (1 'git-commit-comment-action t t) - (2 'git-commit-comment-file t))))) + (2 'git-commit-comment-file t))) + ;; "commit HASH" + (eval . `(,(rx bol "commit " (1+ alnum) eol) + (0 'git-commit-pseudo-header))) + ;; `git-commit-comment-headings' (but not in commented lines) + (eval . `(,(rx-to-string `(seq bol (or ,@git-commit-comment-headings) (1+ blank) (1+ nonl) eol)) + (0 'git-commit-pseudo-header))))) (defconst git-commit-font-lock-keywords-3 `(,@git-commit-font-lock-keywords-2 @@ -913,7 +1011,7 @@ Added to `font-lock-extend-region-functions'." ;; Your branch is up to date with 'master'. ;; Your branch and 'master' have diverged, . `(,(format - "^%s Your branch \\(?:is up-to-date with\\|and\\) '%s'" + "^%s Your branch \\(?:is up[- ]to[- ]date with\\|and\\) '%s'" comment-start git-commit--branch-name-regexp) (1 'git-commit-comment-branch-local t) (2 'git-commit-comment-branch-remote t))) @@ -925,7 +1023,7 @@ Added to `font-lock-extend-region-functions'." (1 'bold t) (2 'bold t))))) -(defvar git-commit-font-lock-keywords git-commit-font-lock-keywords-2 +(defvar git-commit-font-lock-keywords git-commit-font-lock-keywords-3 "Font-Lock keywords for Git-Commit mode.") (defun git-commit-setup-font-lock () @@ -957,17 +1055,14 @@ Added to `font-lock-extend-region-functions'." (progn ;; Make sure the below functions are available. (require 'magit) - ;; Font-Lock wants every submatch to succeed, - ;; so also match the empty string. Do not use - ;; `regexp-quote' because that is slow if there - ;; are thousands of branches outweighing the - ;; benefit of an efficient regep. - (format "\\(\\(?:%s\\)\\|\\)\\(\\(?:%s\\)\\|\\)" + ;; Font-Lock wants every submatch to succeed, so + ;; also match the empty string. Avoid listing + ;; remote branches and using `regexp-quote', + ;; because in repositories have thousands of + ;; branches that would be very slow. See #4353. + (format "\\(\\(?:%s\\)\\|\\)\\([^']+\\)" (mapconcat #'identity (magit-list-local-branch-names) - "\\|") - (mapconcat #'identity - (magit-list-remote-branch-names) "\\|"))) "\\([^']*\\)")) (setq-local font-lock-multiline t) diff --git a/lisp/versions b/lisp/versions index 3b9d7a65..0e85dcd7 100644 --- a/lisp/versions +++ b/lisp/versions @@ -33,12 +33,12 @@ | emojify | [[https://melpa.org/#/emojify][melpa]] | 1.2.1 | 20210108.1111 | 1.2.1 | 20201130.1116 | | | ess | [[https://melpa.org/#/ess][melpa]] | 18.10.3snapshot | 20211231.1746 | 18.10.3snapshot | 20210106.1141 | | | ess-R-data-view.el | [[https://melpa.org/#/ess-R-data-view][melpa]] | 0.1 | 20130509.1158 | | | | -| f.el | melpa | 0.20.0 | 20191110.1357 | | | | -| flycheck | melpa | 32-cvs | 20201228.2104 | 32-cvs | 20200610.1809 | | -| flycheck-ledger.el | melpa | DEV | 20200304.2204 | DEV | 20180819.321 | | -| flycheck-pos-tip.el | melpa | 0.4-cvs | 20200516.1600 | 0.4-cvs | 20180610.1615 | | -| focus | melpa | 1.0.0 | 20191209.2210 | | | | -| git-commit.el | melpa | - | 20201222.1527 | - | 20200608.928 | | +| f.el | [[https://melpa.org/#/f][melpa]] | 0.20.0 | 20210624.1103 | 0.20.0 | 20191110.1357 | | +| flycheck | [[https://melpa.org/#/flycheck][melpa]] | 32-cvs | 20210825.1804 | 32-cvs | 20201228.2104 | | +| flycheck-ledger.el | [[https://melpa.org/#/flycheck-ledger][melpa]] | DEV | 20200304.2204 | DEV | 20180819.321 | | +| flycheck-pos-tip.el | [[https://melpa.org/#/flycheck-pos-tip][melpa]] | 0.4-cvs | 20200516.1600 | 0.4-cvs | 20180610.1615 | | +| focus | [[https://melpa.org/#/focus][melpa]] | 1.0.0 | 20191209.2210 | | | | +| git-commit | [[https://melpa.org/#/git-commit][melpa]] | - | 20201222.1527 | - | 20200608.928 | required by magit | | git-messenger.el | melpa | 0.18 | 20201202.1637 | 0.18 | 20200321.2337 | | | gnuplot | melpa | 0.8.0 | 20210104.1052 | 0.7.0 | 20200322.53 | | | gnuplot-mode.el | melpa | 1.2.0 | 20171013.1616 | | | | diff --git a/settings/eaf-settings.el b/settings/eaf-settings.el index bd51d1ec..c6bc9511 100644 --- a/settings/eaf-settings.el +++ b/settings/eaf-settings.el @@ -9,19 +9,8 @@ :load-path (lambda() (concat config-dir "lisp/emacs-application-framework")) ;;:after (org) ;; eaf requires eaf-interleave requires org ;;:defer 2 - :commands (eaf-open - eaf-open-browser - eaf-open-browser-with-history - eaf-open-mail-as-html - eaf-open-camera - eaf-open-terminal - eaf-file-sender-qrcode eaf-file-sender-qrcode-in-dired - eaf-file-browser-qrcode - eaf-open-airshare - eaf-open-rss-reader - eaf-open-mindmap eaf-create-minmap - eaf-open-office - eaf-open-demo) + ;;;eaf-open-demo + :commands (eaf-open) ;; :unless (string= (system-name) "hasp138dw") ;;:when (if (require 'dbus) (dbus-ping :session "org.freedesktop.Notifications")) :if my-dbusp ;; EAF use DBus' session bus, it must run by a general user (DO NOT USE as root). @@ -30,5 +19,91 @@ (setq eaf-find-alternate-file-in-dired t) (setq eaf-config-location (concat user-cache-directory "eaf/"))) +;; core extensions +(use-package eaf-mail + :after (eaf) + :commands (eaf-open-mail-as-html)) + +;; core extensions +(use-package eaf-org + :after (eaf) + :commands (eaf-org-open)) + +(use-package eaf-airshare + :after (eaf) + :commands (eaf-open-airshare)) + +(use-package eaf-browser + :after (eaf) + :commands (eaf-open-browser + eaf-open-browser-with-history)) + +(use-package eaf-camera + :after (eaf) + :commands (eaf-open-camera)) + +(use-package eaf-file-browser + :after (eaf) + :commands (eaf-file-browser-qrcode)) + +(use-package eaf-file-manager + :after (eaf) + :commands (eaf-open-in-file-manager)) + +(use-package eaf-file-sender + :after (eaf) + :commands (eaf-file-sender-qrcode + eaf-file-sender-qrcode-in-dired)) + +;; required for eaf-open with image files +(use-package eaf-image-viewer + :after (eaf)) + +(use-package eaf-jupyter + :after (eaf) + :commands (eaf-open-jupyter)) + +;; required for eaf-open with markdown files +(use-package eaf-markdown-previewer + :after (eaf)) + +(use-package eaf-mindmap + :after (eaf) + :commands (eaf-open-mindmap + eaf-create-minmap)) + +(use-package eaf-music-player + :after (eaf) + :commands (eaf-open-music-player)) + +(use-package eaf-netease-cloud-music + :after (eaf) + :commands (eaf-open-netease-cloud-music)) + +;; required for eaf-open with org files +(use-package eaf-org-previewer + :after (eaf)) + +;; required for eaf-open with pdf files +(use-package eaf-pdf-viewer + :after (eaf) + :commands (eaf-open-office)) + +(use-package eaf-rss-reader + :after (eaf) + :commands (eaf-open-rss-reader)) + +(use-package eaf-system-monitor + :after (eaf) + :commands (eaf-open-system-monitor)) + +(use-package eaf-terminal + :after (eaf) + :commands (eaf-open-terminal)) + +;; required for eaf-open with video files +(use-package eaf-video-player + :after (eaf)) + (provide 'eaf-settings) ;;; eaf-settings.el ends here diff --git a/settings/version-control-settings.el b/settings/version-control-settings.el index 55a137a9..7a10e4d7 100644 --- a/settings/version-control-settings.el +++ b/settings/version-control-settings.el @@ -20,6 +20,12 @@ ;;; Code: ;; see also Diff-Hl (diff-hl-mode) to see VC diff highlighting in fringes. + +;; required by magit +(use-package git-commit + :load-path (lambda() (concat config-dir "lisp/git-commit")) + :defer t) + (use-package magit :load-path (lambda() (concat config-dir "lisp/magit")) :bind (("C-c M-g" . magit-file-dispatch))