pkg update and first config fix

org-brain not working, add org-roam
This commit is contained in:
2022-12-19 23:02:34 +01:00
parent 02b3e07185
commit 82f05baffe
885 changed files with 356098 additions and 36993 deletions

View File

@@ -1,24 +1,20 @@
;;; with-editor.el --- Use the Emacsclient as $EDITOR -*- lexical-binding: t -*-
;;; with-editor.el --- Use the Emacsclient as $EDITOR -*- lexical-binding:t -*-
;; Copyright (C) 2014-2022 The Magit Project Contributors
;;
;; You should have received a copy of the AUTHORS.md file. If not,
;; see https://github.com/magit/with-editor/blob/master/AUTHORS.md.
;; Copyright (C) 2014-2022 The Magit Project Contributors
;; Author: Jonas Bernoulli <jonas@bernoul.li>
;; Maintainer: Jonas Bernoulli <jonas@bernoul.li>
;; Keywords: tools
;; Homepage: https://github.com/magit/with-editor
;; Keywords: processes terminals
;; Package-Requires: ((emacs "24.4"))
;; Package-Version: 3.0.5
;; Package-Version: 3.2.0.50-git
;; Package-Requires: ((emacs "25.1") (compat "28.1.1.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 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.
;;
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -26,9 +22,7 @@
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with Magit. If not, see http://www.gnu.org/licenses.
;; This file is not part of GNU Emacs.
;; along with this file. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
@@ -48,9 +42,9 @@
;; file:
;;
;; (define-key (current-global-map)
;; [remap async-shell-command] 'with-editor-async-shell-command)
;; [remap async-shell-command] #'with-editor-async-shell-command)
;; (define-key (current-global-map)
;; [remap shell-command] 'with-editor-shell-command)
;; [remap shell-command] #'with-editor-shell-command)
;; Alternatively use the global `shell-command-with-editor-mode',
;; which always sets `$EDITOR' for all Emacs commands which ultimately
@@ -63,17 +57,17 @@
;; always arrange for the current Emacs instance to be used as editor
;; by adding it to the appropriate mode hooks:
;;
;; (add-hook 'shell-mode-hook 'with-editor-export-editor)
;; (add-hook 'eshell-mode-hook 'with-editor-export-editor)
;; (add-hook 'term-exec-hook 'with-editor-export-editor)
;; (add-hook 'vterm-mode-hook 'with-editor-export-editor)
;; (add-hook 'shell-mode-hook #'with-editor-export-editor)
;; (add-hook 'eshell-mode-hook #'with-editor-export-editor)
;; (add-hook 'term-exec-hook #'with-editor-export-editor)
;; (add-hook 'vterm-mode-hook #'with-editor-export-editor)
;; Some variants of this function exist, these two forms are
;; equivalent:
;;
;; (add-hook 'shell-mode-hook
;; (apply-partially 'with-editor-export-editor "GIT_EDITOR"))
;; (add-hook 'shell-mode-hook 'with-editor-export-git-editor)
;; (apply-partially #'with-editor-export-editor "GIT_EDITOR"))
;; (add-hook 'shell-mode-hook #'with-editor-export-git-editor)
;; This library can also be used by other packages which need to use
;; the current Emacs instance as editor. In fact this library was
@@ -84,27 +78,21 @@
;;; Code:
(require 'cl-lib)
(eval-when-compile
(require 'pcase) ; `pcase-dolist' is not autoloaded on Emacs 24.
(require 'subr-x))
(require 'compat)
(require 'server)
(require 'shell)
(eval-when-compile (require 'subr-x))
(eval-when-compile
(progn (require 'dired nil t)
(require 'eshell nil t)
(require 'term nil t)
(condition-case err
(require 'vterm nil t)
(error (message "Error(vterm): %S" err)))
(require 'warnings nil t)))
(declare-function dired-get-filename 'dired)
(declare-function term-emulate-terminal 'term)
(declare-function vterm-send-return 'vterm)
(declare-function vterm-send-string 'vterm)
(declare-function dired-get-filename "dired"
(&optional localp no-error-if-not-filep))
(declare-function term-emulate-terminal "term" (proc str))
(declare-function vterm-send-return "vterm" ())
(declare-function vterm-send-string "vterm" (string &optional paste-p))
(defvar eshell-preoutput-filter-functions)
(defvar git-commit-post-finish-hook)
(defvar vterm--process)
(defvar warning-minimum-level)
(defvar warning-minimum-log-level)
;;; Options
@@ -128,7 +116,7 @@ please see https://github.com/magit/magit/wiki/Emacsclient."))))
(defun with-editor-locate-emacsclient-1 (path depth)
(let* ((version-lst (cl-subseq (split-string emacs-version "\\.") 0 depth))
(version-reg (concat "^" (mapconcat #'identity version-lst "\\."))))
(or (locate-file-internal
(or (locate-file
(if (equal (downcase invocation-name) "remacs")
"remacsclient"
"emacsclient")
@@ -166,11 +154,11 @@ please see https://github.com/magit/magit/wiki/Emacsclient."))))
(let ((dir (expand-file-name "bin" invocation-directory)))
(when (file-directory-p dir)
(push dir path)))
(when (string-match-p "Cellar" invocation-directory)
(when (string-search "Cellar" invocation-directory)
(let ((dir (expand-file-name "../../../bin" invocation-directory)))
(when (file-directory-p dir)
(push dir path))))))
(cl-remove-duplicates path :test 'equal)))
(cl-remove-duplicates path :test #'equal)))
(defcustom with-editor-emacsclient-executable (with-editor-locate-emacsclient)
"The Emacsclient executable used by the `with-editor' macro."
@@ -180,7 +168,7 @@ please see https://github.com/magit/magit/wiki/Emacsclient."))))
(defcustom with-editor-sleeping-editor "\
sh -c '\
printf \"WITH-EDITOR: $$ OPEN $0\\037 IN $(pwd)\\n\"; \
printf \"\\nWITH-EDITOR: $$ OPEN $0\\037 IN $(pwd)\\n\"; \
sleep 604800 & sleep=$!; \
trap \"kill $sleep; exit 0\" USR1; \
trap \"kill $sleep; exit 1\" USR2; \
@@ -209,7 +197,7 @@ with \"bash\" (and install that), or you can use the older, less
performant implementation:
\"sh -c '\\
echo \\\"WITH-EDITOR: $$ OPEN $0 IN $(pwd)\\\"; \\
echo -e \\\"\\nWITH-EDITOR: $$ OPEN $0 IN $(pwd)\\n\\\"; \\
trap \\\"exit 0\\\" USR1; \\
trap \\\"exit 1\" USR2; \\
while true; do sleep 1; done'\"
@@ -292,7 +280,7 @@ When t, then use the emacsclient. This has the disadvantage that
`with-editor-mode' won't be enabled because we don't know whether
this package was involved at all in the call to the emacsclient,
and when it is not, then we really should. The problem is that
the emacsclient doesn't pass a long any environment variables to
the emacsclient doesn't pass along any environment variables to
the server. This will hopefully be fixed in Emacs eventually.
When nil, then use the sleeping editor. Because in this case we
@@ -374,14 +362,18 @@ And some tools that do not handle $EDITOR properly also break."
(dir default-directory)
(pid with-editor--pid))
(remove-hook 'kill-buffer-query-functions
'with-editor-kill-buffer-noop t)
#'with-editor-kill-buffer-noop t)
(cond (cancel
(save-buffer)
(if clients
(dolist (client clients)
(ignore-errors
(server-send-string client "-error Canceled by user"))
(delete-process client))
(let ((buf (current-buffer)))
(dolist (client clients)
(message "client %S" client)
(ignore-errors
(server-send-string client "-error Canceled by user"))
(delete-process client))
(when (buffer-live-p buf)
(kill-buffer buf)))
;; Fallback for when emacs was used as $EDITOR
;; instead of emacsclient or the sleeping editor.
;; See https://github.com/magit/magit/issues/2258.
@@ -407,15 +399,15 @@ And some tools that do not handle $EDITOR properly also break."
(defvar with-editor-mode-map
(let ((map (make-sparse-keymap)))
(define-key map "\C-c\C-c" 'with-editor-finish)
(define-key map [remap server-edit] 'with-editor-finish)
(define-key map [remap evil-save-and-close] 'with-editor-finish)
(define-key map [remap evil-save-modified-and-close] 'with-editor-finish)
(define-key map "\C-c\C-k" 'with-editor-cancel)
(define-key map [remap kill-buffer] 'with-editor-cancel)
(define-key map [remap ido-kill-buffer] 'with-editor-cancel)
(define-key map [remap iswitchb-kill-buffer] 'with-editor-cancel)
(define-key map [remap evil-quit] 'with-editor-cancel)
(define-key map "\C-c\C-c" #'with-editor-finish)
(define-key map [remap server-edit] #'with-editor-finish)
(define-key map [remap evil-save-and-close] #'with-editor-finish)
(define-key map [remap evil-save-modified-and-close] #'with-editor-finish)
(define-key map "\C-c\C-k" #'with-editor-cancel)
(define-key map [remap kill-buffer] #'with-editor-cancel)
(define-key map [remap ido-kill-buffer] #'with-editor-cancel)
(define-key map [remap iswitchb-kill-buffer] #'with-editor-cancel)
(define-key map [remap evil-quit] #'with-editor-cancel)
map))
(define-minor-mode with-editor-mode
@@ -427,7 +419,7 @@ And some tools that do not handle $EDITOR properly also break."
(unless with-editor-mode
(user-error "With-Editor mode cannot be turned off"))
(add-hook 'kill-buffer-query-functions
'with-editor-kill-buffer-noop nil t)
#'with-editor-kill-buffer-noop nil t)
;; `server-execute' displays a message which is not
;; correct when using this mode.
(when with-editor-show-usage
@@ -551,7 +543,7 @@ at run-time.
(apply fn next-buffer args)))
(advice-add 'server-switch-buffer :around
'server-switch-buffer--with-editor-server-window-alist)
#'server-switch-buffer--with-editor-server-window-alist)
(defun start-file-process--with-editor-process-filter
(fn name buffer program &rest program-args)
@@ -573,12 +565,12 @@ the appropriate editor environment variable."
(push (concat with-editor--envvar "=" with-editor-sleeping-editor)
program-args))
(let ((process (apply fn name buffer program program-args)))
(set-process-filter process 'with-editor-process-filter)
(set-process-filter process #'with-editor-process-filter)
(process-put process 'default-dir default-directory)
process)))
(advice-add 'start-file-process :around
'start-file-process--with-editor-process-filter)
#'start-file-process--with-editor-process-filter)
(cl-defun make-process--with-editor-process-filter
(fn &rest keys &key name buffer command coding noquery stop
@@ -651,7 +643,7 @@ may not insert the text into the PROCESS's buffer. Then it calls
(setq string (concat incomplete string)))
(save-match-data
(cond
((and process (not (string-match-p "\n\\'" string)))
((and process (not (string-suffix-p "\n" string)))
(let ((length (length string)))
(when (> length with-editor--max-incomplete-length)
(setq string
@@ -672,8 +664,10 @@ may not insert the text into the PROCESS's buffer. Then it calls
(with-current-buffer (find-file-noselect file)
(with-editor-mode 1)
(setq with-editor--pid pid)
(setq with-editor-previous-winconf
(current-window-configuration))
(run-hooks 'with-editor-filter-visit-hook)
(funcall (or (with-editor-server-window) 'switch-to-buffer)
(funcall (or (with-editor-server-window) #'switch-to-buffer)
(current-buffer))
(kill-local-variable 'server-window)))
nil)
@@ -688,7 +682,7 @@ may not insert the text into the PROCESS's buffer. Then it calls
(internal-default-process-filter process string)))
(advice-add 'server-visit-files :after
'server-visit-files--with-editor-file-name-history-exclude)
#'server-visit-files--with-editor-file-name-history-exclude)
(defun server-visit-files--with-editor-file-name-history-exclude
(files _proc &optional _nowait)
@@ -720,12 +714,12 @@ This works in `shell-mode', `term-mode', `eshell-mode' and
(shell-quote-argument with-editor-sleeping-editor)))
(while (accept-process-output process 0.1))
(if (derived-mode-p 'term-mode)
(with-editor-set-process-filter process 'with-editor-emulate-terminal)
(add-hook 'comint-output-filter-functions 'with-editor-output-filter
(with-editor-set-process-filter process #'with-editor-emulate-terminal)
(add-hook 'comint-output-filter-functions #'with-editor-output-filter
nil t))))
((derived-mode-p 'eshell-mode)
(add-to-list 'eshell-preoutput-filter-functions
'with-editor-output-filter)
#'with-editor-output-filter)
(setenv envvar with-editor-sleeping-editor))
((derived-mode-p 'vterm-mode)
(if with-editor-emacsclient-executable
@@ -734,10 +728,10 @@ This works in `shell-mode', `term-mode', `eshell-mode' and
(with-editor--setup)
(while (accept-process-output vterm--process 0.1))
(when-let ((v (getenv envvar)))
(vterm-send-string (format "export %s=%S" envvar v))
(vterm-send-string (format " export %s=%S" envvar v))
(vterm-send-return))
(when-let ((v (getenv "EMACS_SERVER_FILE")))
(vterm-send-string (format "export EMACS_SERVER_FILE=%S" v))
(vterm-send-string (format " export EMACS_SERVER_FILE=%S" v))
(vterm-send-return))
(vterm-send-string "clear")
(vterm-send-return))
@@ -855,21 +849,21 @@ else like the former."
;; that mode, even though it only runs the shell to run a single
;; command. The `with-editor-export-editor' hook function is only
;; intended to be used in buffers in which an interactive shell is
;; running, so it has to be remove here.
;; running, so it has to be removed here.
(let ((shell-mode-hook (remove 'with-editor-export-editor shell-mode-hook)))
(cond ((or (not (or with-editor--envvar shell-command-with-editor-mode))
(not (string-match-p "&\\'" command)))
(not (string-suffix-p "&" command)))
(funcall fn command output-buffer error-buffer))
((and with-editor-shell-command-use-emacsclient
with-editor-emacsclient-executable
(not (file-remote-p default-directory)))
(with-editor (funcall fn command output-buffer error-buffer)))
(t
(apply fn (format "%s=%s %s"
(or with-editor--envvar "EDITOR")
(shell-quote-argument with-editor-sleeping-editor)
command)
output-buffer error-buffer)
(funcall fn (format "%s=%s %s"
(or with-editor--envvar "EDITOR")
(shell-quote-argument with-editor-sleeping-editor)
command)
output-buffer error-buffer)
(ignore-errors
(let ((process (get-buffer-process
(or output-buffer
@@ -881,7 +875,7 @@ else like the former."
process))))))
(advice-add 'shell-command :around
'shell-command--shell-command-with-editor-mode)
#'shell-command--shell-command-with-editor-mode)
;;; _
@@ -889,6 +883,7 @@ else like the former."
"Debug configuration issues.
See info node `(with-editor)Debugging' for instructions."
(interactive)
(require 'warnings)
(with-current-buffer (get-buffer-create "*with-editor-debug*")
(pop-to-buffer (current-buffer))
(erase-buffer)