Update elpa packages
This commit is contained in:
parent
d915e27d60
commit
4d1b0b5b61
129 changed files with 3688 additions and 10 deletions
174
elpa/async-20191030.2138/async-autoloads.el
Normal file
174
elpa/async-20191030.2138/async-autoloads.el
Normal file
|
@ -0,0 +1,174 @@
|
|||
;;; async-autoloads.el --- automatically extracted autoloads
|
||||
;;
|
||||
;;; Code:
|
||||
|
||||
(add-to-list 'load-path (directory-file-name
|
||||
(or (file-name-directory #$) (car load-path))))
|
||||
|
||||
|
||||
;;;### (autoloads nil "async" "async.el" (0 0 0 0))
|
||||
;;; Generated autoloads from async.el
|
||||
|
||||
(autoload 'async-start-process "async" "\
|
||||
Start the executable PROGRAM asynchronously. See `async-start'.
|
||||
PROGRAM is passed PROGRAM-ARGS, calling FINISH-FUNC with the
|
||||
process object when done. If FINISH-FUNC is nil, the future
|
||||
object will return the process object when the program is
|
||||
finished. Set DEFAULT-DIRECTORY to change PROGRAM's current
|
||||
working directory.
|
||||
|
||||
\(fn NAME PROGRAM FINISH-FUNC &rest PROGRAM-ARGS)" nil nil)
|
||||
|
||||
(autoload 'async-start "async" "\
|
||||
Execute START-FUNC (often a lambda) in a subordinate Emacs process.
|
||||
When done, the return value is passed to FINISH-FUNC. Example:
|
||||
|
||||
(async-start
|
||||
;; What to do in the child process
|
||||
(lambda ()
|
||||
(message \"This is a test\")
|
||||
(sleep-for 3)
|
||||
222)
|
||||
|
||||
;; What to do when it finishes
|
||||
(lambda (result)
|
||||
(message \"Async process done, result should be 222: %s\"
|
||||
result)))
|
||||
|
||||
If FINISH-FUNC is nil or missing, a future is returned that can
|
||||
be inspected using `async-get', blocking until the value is
|
||||
ready. Example:
|
||||
|
||||
(let ((proc (async-start
|
||||
;; What to do in the child process
|
||||
(lambda ()
|
||||
(message \"This is a test\")
|
||||
(sleep-for 3)
|
||||
222))))
|
||||
|
||||
(message \"I'm going to do some work here\") ;; ....
|
||||
|
||||
(message \"Waiting on async process, result should be 222: %s\"
|
||||
(async-get proc)))
|
||||
|
||||
If you don't want to use a callback, and you don't care about any
|
||||
return value from the child process, pass the `ignore' symbol as
|
||||
the second argument (if you don't, and never call `async-get', it
|
||||
will leave *emacs* process buffers hanging around):
|
||||
|
||||
(async-start
|
||||
(lambda ()
|
||||
(delete-file \"a remote file on a slow link\" nil))
|
||||
'ignore)
|
||||
|
||||
Note: Even when FINISH-FUNC is present, a future is still
|
||||
returned except that it yields no value (since the value is
|
||||
passed to FINISH-FUNC). Call `async-get' on such a future always
|
||||
returns nil. It can still be useful, however, as an argument to
|
||||
`async-ready' or `async-wait'.
|
||||
|
||||
\(fn START-FUNC &optional FINISH-FUNC)" nil nil)
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "async" '("async-")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "async-bytecomp" "async-bytecomp.el" (0 0 0
|
||||
;;;;;; 0))
|
||||
;;; Generated autoloads from async-bytecomp.el
|
||||
|
||||
(autoload 'async-byte-recompile-directory "async-bytecomp" "\
|
||||
Compile all *.el files in DIRECTORY asynchronously.
|
||||
All *.elc files are systematically deleted before proceeding.
|
||||
|
||||
\(fn DIRECTORY &optional QUIET)" nil nil)
|
||||
|
||||
(defvar async-bytecomp-package-mode nil "\
|
||||
Non-nil if Async-Bytecomp-Package mode is enabled.
|
||||
See the `async-bytecomp-package-mode' command
|
||||
for a description of this minor mode.
|
||||
Setting this variable directly does not take effect;
|
||||
either customize it (see the info node `Easy Customization')
|
||||
or call the function `async-bytecomp-package-mode'.")
|
||||
|
||||
(custom-autoload 'async-bytecomp-package-mode "async-bytecomp" nil)
|
||||
|
||||
(autoload 'async-bytecomp-package-mode "async-bytecomp" "\
|
||||
Byte compile asynchronously packages installed with package.el.
|
||||
Async compilation of packages can be controlled by
|
||||
`async-bytecomp-allowed-packages'.
|
||||
|
||||
\(fn &optional ARG)" t nil)
|
||||
|
||||
(autoload 'async-byte-compile-file "async-bytecomp" "\
|
||||
Byte compile Lisp code FILE asynchronously.
|
||||
|
||||
Same as `byte-compile-file' but asynchronous.
|
||||
|
||||
\(fn FILE)" t nil)
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "async-bytecomp" '("async-byte")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "dired-async" "dired-async.el" (0 0 0 0))
|
||||
;;; Generated autoloads from dired-async.el
|
||||
|
||||
(defvar dired-async-mode nil "\
|
||||
Non-nil if Dired-Async mode is enabled.
|
||||
See the `dired-async-mode' command
|
||||
for a description of this minor mode.
|
||||
Setting this variable directly does not take effect;
|
||||
either customize it (see the info node `Easy Customization')
|
||||
or call the function `dired-async-mode'.")
|
||||
|
||||
(custom-autoload 'dired-async-mode "dired-async" nil)
|
||||
|
||||
(autoload 'dired-async-mode "dired-async" "\
|
||||
Do dired actions asynchronously.
|
||||
|
||||
\(fn &optional ARG)" t nil)
|
||||
|
||||
(autoload 'dired-async-do-copy "dired-async" "\
|
||||
Run ‘dired-do-copy’ asynchronously.
|
||||
|
||||
\(fn &optional ARG)" t nil)
|
||||
|
||||
(autoload 'dired-async-do-symlink "dired-async" "\
|
||||
Run ‘dired-do-symlink’ asynchronously.
|
||||
|
||||
\(fn &optional ARG)" t nil)
|
||||
|
||||
(autoload 'dired-async-do-hardlink "dired-async" "\
|
||||
Run ‘dired-do-hardlink’ asynchronously.
|
||||
|
||||
\(fn &optional ARG)" t nil)
|
||||
|
||||
(autoload 'dired-async-do-rename "dired-async" "\
|
||||
Run ‘dired-do-rename’ asynchronously.
|
||||
|
||||
\(fn &optional ARG)" t nil)
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "dired-async" '("dired-async-")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "smtpmail-async" "smtpmail-async.el" (0 0 0
|
||||
;;;;;; 0))
|
||||
;;; Generated autoloads from smtpmail-async.el
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "smtpmail-async" '("async-smtpmail-")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil nil ("async-pkg.el") (0 0 0 0))
|
||||
|
||||
;;;***
|
||||
|
||||
;; Local Variables:
|
||||
;; version-control: never
|
||||
;; no-byte-compile: t
|
||||
;; no-update-autoloads: t
|
||||
;; coding: utf-8
|
||||
;; End:
|
||||
;;; async-autoloads.el ends here
|
210
elpa/async-20191030.2138/async-bytecomp.el
Normal file
210
elpa/async-20191030.2138/async-bytecomp.el
Normal file
|
@ -0,0 +1,210 @@
|
|||
;;; async-bytecomp.el --- Compile elisp files asynchronously -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2014-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Authors: John Wiegley <jwiegley@gmail.com>
|
||||
;; Thierry Volpiatto <thierry.volpiatto@gmail.com>
|
||||
|
||||
;; Keywords: dired async byte-compile
|
||||
;; X-URL: https://github.com/jwiegley/dired-async
|
||||
|
||||
;; This program 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 2, or (at
|
||||
;; your option) any later version.
|
||||
|
||||
;; This program 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; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
;; Boston, MA 02111-1307, USA.
|
||||
|
||||
;;; Commentary:
|
||||
;;
|
||||
;; This package provide the `async-byte-recompile-directory' function
|
||||
;; which allows, as the name says to recompile a directory outside of
|
||||
;; your running emacs.
|
||||
;; The benefit is your files will be compiled in a clean environment without
|
||||
;; the old *.el files loaded.
|
||||
;; Among other things, this fix a bug in package.el which recompile
|
||||
;; the new files in the current environment with the old files loaded, creating
|
||||
;; errors in most packages after upgrades.
|
||||
;;
|
||||
;; NB: This package is advicing the function `package--compile'.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'cl-lib)
|
||||
(require 'async)
|
||||
|
||||
(defcustom async-bytecomp-allowed-packages
|
||||
;; FIXME: Arguably the default should be `all', but currently
|
||||
;; this minor mode is silently/forcefully enabled by Helm and Magit to ensure
|
||||
;; they get compiled asynchronously, so this conservative default value is
|
||||
;; here to make sure that the mode can be enabled without the user's
|
||||
;; explicit consent.
|
||||
'(async forge helm helm-core helm-ls-git helm-ls-hg magit)
|
||||
"Packages in this list will be compiled asynchronously by `package--compile'.
|
||||
All the dependencies of these packages will be compiled async too,
|
||||
so no need to add dependencies to this list.
|
||||
The value of this variable can also be the symbol `all', in this case
|
||||
all packages are always compiled asynchronously."
|
||||
:group 'async
|
||||
:type '(choice
|
||||
(const :tag "All packages" all)
|
||||
(repeat symbol)))
|
||||
|
||||
(defvar async-byte-compile-log-file
|
||||
(concat user-emacs-directory "async-bytecomp.log"))
|
||||
|
||||
;;;###autoload
|
||||
(defun async-byte-recompile-directory (directory &optional quiet)
|
||||
"Compile all *.el files in DIRECTORY asynchronously.
|
||||
All *.elc files are systematically deleted before proceeding."
|
||||
(cl-loop with dir = (directory-files directory t "\\.elc\\'")
|
||||
unless dir return nil
|
||||
for f in dir
|
||||
when (file-exists-p f) do (delete-file f))
|
||||
;; Ensure async is reloaded when async.elc is deleted.
|
||||
;; This happen when recompiling its own directory.
|
||||
(load "async")
|
||||
(let ((call-back
|
||||
(lambda (&optional _ignore)
|
||||
(if (file-exists-p async-byte-compile-log-file)
|
||||
(let ((buf (get-buffer-create byte-compile-log-buffer))
|
||||
(n 0))
|
||||
(with-current-buffer buf
|
||||
(goto-char (point-max))
|
||||
(let ((inhibit-read-only t))
|
||||
(insert-file-contents async-byte-compile-log-file)
|
||||
(compilation-mode))
|
||||
(display-buffer buf)
|
||||
(delete-file async-byte-compile-log-file)
|
||||
(unless quiet
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "^.*:Error:" nil t)
|
||||
(cl-incf n)))
|
||||
(if (> n 0)
|
||||
(message "Failed to compile %d files in directory `%s'" n directory)
|
||||
(message "Directory `%s' compiled asynchronously with warnings" directory)))))
|
||||
(unless quiet
|
||||
(message "Directory `%s' compiled asynchronously with success" directory))))))
|
||||
(async-start
|
||||
`(lambda ()
|
||||
(require 'bytecomp)
|
||||
,(async-inject-variables "\\`\\(load-path\\)\\|byte\\'")
|
||||
(let ((default-directory (file-name-as-directory ,directory))
|
||||
error-data)
|
||||
(add-to-list 'load-path default-directory)
|
||||
(byte-recompile-directory ,directory 0 t)
|
||||
(when (get-buffer byte-compile-log-buffer)
|
||||
(setq error-data (with-current-buffer byte-compile-log-buffer
|
||||
(buffer-substring-no-properties (point-min) (point-max))))
|
||||
(unless (string= error-data "")
|
||||
(with-temp-file ,async-byte-compile-log-file
|
||||
(erase-buffer)
|
||||
(insert error-data))))))
|
||||
call-back)
|
||||
(unless quiet (message "Started compiling asynchronously directory %s" directory))))
|
||||
|
||||
(defvar package-archive-contents)
|
||||
(defvar package-alist)
|
||||
(declare-function package-desc-reqs "package.el" (cl-x))
|
||||
|
||||
(defun async-bytecomp--get-package-deps (pkgs)
|
||||
;; Same as `package--get-deps' but parse instead `package-archive-contents'
|
||||
;; because PKG is not already installed and not present in `package-alist'.
|
||||
;; However fallback to `package-alist' in case PKG no more present
|
||||
;; in `package-archive-contents' due to modification to `package-archives'.
|
||||
;; See issue #58.
|
||||
(let ((seen '()))
|
||||
(while pkgs
|
||||
(let ((pkg (pop pkgs)))
|
||||
(unless (memq pkg seen)
|
||||
(let ((pkg-desc (cadr (or (assq pkg package-archive-contents)
|
||||
(assq pkg package-alist)))))
|
||||
(when pkg-desc
|
||||
(push pkg seen)
|
||||
(setq pkgs (append (mapcar #'car (package-desc-reqs pkg-desc))
|
||||
pkgs)))))))
|
||||
seen))
|
||||
|
||||
(defadvice package--compile (around byte-compile-async)
|
||||
(let ((cur-package (package-desc-name pkg-desc))
|
||||
(pkg-dir (package-desc-dir pkg-desc)))
|
||||
(if (or (member async-bytecomp-allowed-packages '(t all (all)))
|
||||
(memq cur-package (async-bytecomp--get-package-deps
|
||||
async-bytecomp-allowed-packages)))
|
||||
(progn
|
||||
(when (eq cur-package 'async)
|
||||
(fmakunbound 'async-byte-recompile-directory))
|
||||
;; Add to `load-path' the latest version of async and
|
||||
;; reload it when reinstalling async.
|
||||
(when (string= cur-package "async")
|
||||
(cl-pushnew pkg-dir load-path)
|
||||
(load "async-bytecomp"))
|
||||
;; `async-byte-recompile-directory' will add directory
|
||||
;; as needed to `load-path'.
|
||||
(async-byte-recompile-directory (package-desc-dir pkg-desc) t))
|
||||
ad-do-it)))
|
||||
|
||||
;;;###autoload
|
||||
(define-minor-mode async-bytecomp-package-mode
|
||||
"Byte compile asynchronously packages installed with package.el.
|
||||
Async compilation of packages can be controlled by
|
||||
`async-bytecomp-allowed-packages'."
|
||||
:group 'async
|
||||
:global t
|
||||
(if async-bytecomp-package-mode
|
||||
(ad-activate 'package--compile)
|
||||
(ad-deactivate 'package--compile)))
|
||||
|
||||
;;;###autoload
|
||||
(defun async-byte-compile-file (file)
|
||||
"Byte compile Lisp code FILE asynchronously.
|
||||
|
||||
Same as `byte-compile-file' but asynchronous."
|
||||
(interactive "fFile: ")
|
||||
(let ((call-back
|
||||
(lambda (&optional _ignore)
|
||||
(let ((bn (file-name-nondirectory file)))
|
||||
(if (file-exists-p async-byte-compile-log-file)
|
||||
(let ((buf (get-buffer-create byte-compile-log-buffer))
|
||||
start)
|
||||
(with-current-buffer buf
|
||||
(goto-char (setq start (point-max)))
|
||||
(let ((inhibit-read-only t))
|
||||
(insert-file-contents async-byte-compile-log-file)
|
||||
(compilation-mode))
|
||||
(display-buffer buf)
|
||||
(delete-file async-byte-compile-log-file)
|
||||
(save-excursion
|
||||
(goto-char start)
|
||||
(if (re-search-forward "^.*:Error:" nil t)
|
||||
(message "Failed to compile `%s'" bn)
|
||||
(message "`%s' compiled asynchronously with warnings" bn)))))
|
||||
(message "`%s' compiled asynchronously with success" bn))))))
|
||||
(async-start
|
||||
`(lambda ()
|
||||
(require 'bytecomp)
|
||||
,(async-inject-variables "\\`load-path\\'")
|
||||
(let ((default-directory ,(file-name-directory file)))
|
||||
(add-to-list 'load-path default-directory)
|
||||
(byte-compile-file ,file)
|
||||
(when (get-buffer byte-compile-log-buffer)
|
||||
(setq error-data (with-current-buffer byte-compile-log-buffer
|
||||
(buffer-substring-no-properties (point-min) (point-max))))
|
||||
(unless (string= error-data "")
|
||||
(with-temp-file ,async-byte-compile-log-file
|
||||
(erase-buffer)
|
||||
(insert error-data))))))
|
||||
call-back)))
|
||||
|
||||
(provide 'async-bytecomp)
|
||||
|
||||
;;; async-bytecomp.el ends here
|
BIN
elpa/async-20191030.2138/async-bytecomp.elc
Normal file
BIN
elpa/async-20191030.2138/async-bytecomp.elc
Normal file
Binary file not shown.
6
elpa/async-20191030.2138/async-pkg.el
Normal file
6
elpa/async-20191030.2138/async-pkg.el
Normal file
|
@ -0,0 +1,6 @@
|
|||
(define-package "async" "20191030.2138" "Asynchronous processing in Emacs" 'nil :keywords
|
||||
'("async")
|
||||
:url "https://github.com/jwiegley/emacs-async")
|
||||
;; Local Variables:
|
||||
;; no-byte-compile: t
|
||||
;; End:
|
408
elpa/async-20191030.2138/async.el
Normal file
408
elpa/async-20191030.2138/async.el
Normal file
|
@ -0,0 +1,408 @@
|
|||
;;; async.el --- Asynchronous processing in Emacs -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2012-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: John Wiegley <jwiegley@gmail.com>
|
||||
;; Created: 18 Jun 2012
|
||||
;; Version: 1.9.3
|
||||
|
||||
;; Keywords: async
|
||||
;; X-URL: https://github.com/jwiegley/emacs-async
|
||||
|
||||
;; This program 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 2, or (at
|
||||
;; your option) any later version.
|
||||
|
||||
;; This program 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; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
;; Boston, MA 02111-1307, USA.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Adds the ability to call asynchronous functions and process with ease. See
|
||||
;; the documentation for `async-start' and `async-start-process'.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(eval-when-compile (require 'cl-lib))
|
||||
|
||||
(defgroup async nil
|
||||
"Simple asynchronous processing in Emacs"
|
||||
:group 'emacs)
|
||||
|
||||
(defcustom async-variables-noprops-function #'async--purecopy
|
||||
"Default function to remove text properties in variables."
|
||||
:group 'async
|
||||
:type 'function)
|
||||
|
||||
(defvar async-debug nil)
|
||||
(defvar async-send-over-pipe t)
|
||||
(defvar async-in-child-emacs nil)
|
||||
(defvar async-callback nil)
|
||||
(defvar async-callback-for-process nil)
|
||||
(defvar async-callback-value nil)
|
||||
(defvar async-callback-value-set nil)
|
||||
(defvar async-current-process nil)
|
||||
(defvar async--procvar nil)
|
||||
|
||||
(defun async--purecopy (object)
|
||||
"Remove text properties in OBJECT.
|
||||
|
||||
Argument OBJECT may be a list or a string, if anything else it
|
||||
is returned unmodified."
|
||||
(cond ((stringp object)
|
||||
(substring-no-properties object))
|
||||
((consp object)
|
||||
(cl-loop for elm in object
|
||||
;; A string.
|
||||
if (stringp elm)
|
||||
collect (substring-no-properties elm)
|
||||
else
|
||||
;; Proper lists.
|
||||
if (and (consp elm) (null (cdr (last elm))))
|
||||
collect (async--purecopy elm)
|
||||
else
|
||||
;; Dotted lists.
|
||||
;; We handle here only dotted list where car and cdr
|
||||
;; are atoms i.e. (x . y) and not (x . (x . y)) or
|
||||
;; (x . (x y)) which should fit most cases.
|
||||
if (and (consp elm) (cdr (last elm)))
|
||||
collect (let ((key (car elm))
|
||||
(val (cdr elm)))
|
||||
(cons (if (stringp key)
|
||||
(substring-no-properties key)
|
||||
key)
|
||||
(if (stringp val)
|
||||
(substring-no-properties val)
|
||||
val)))
|
||||
else
|
||||
collect elm))
|
||||
(t object)))
|
||||
|
||||
(defun async-inject-variables
|
||||
(include-regexp &optional predicate exclude-regexp noprops)
|
||||
"Return a `setq' form that replicates part of the calling environment.
|
||||
|
||||
It sets the value for every variable matching INCLUDE-REGEXP and
|
||||
also PREDICATE. It will not perform injection for any variable
|
||||
matching EXCLUDE-REGEXP (if present) or representing a syntax-table
|
||||
i.e. ending by \"-syntax-table\".
|
||||
When NOPROPS is non nil it tries to strip out text properties of each
|
||||
variable's value with `async-variables-noprops-function'.
|
||||
|
||||
It is intended to be used as follows:
|
||||
|
||||
(async-start
|
||||
`(lambda ()
|
||||
(require 'smtpmail)
|
||||
(with-temp-buffer
|
||||
(insert ,(buffer-substring-no-properties (point-min) (point-max)))
|
||||
;; Pass in the variable environment for smtpmail
|
||||
,(async-inject-variables \"\\`\\(smtpmail\\|\\(user-\\)?mail\\)-\")
|
||||
(smtpmail-send-it)))
|
||||
'ignore)"
|
||||
`(setq
|
||||
,@(let (bindings)
|
||||
(mapatoms
|
||||
(lambda (sym)
|
||||
(let* ((sname (and (boundp sym) (symbol-name sym)))
|
||||
(value (and sname (symbol-value sym))))
|
||||
(when (and sname
|
||||
(or (null include-regexp)
|
||||
(string-match include-regexp sname))
|
||||
(or (null exclude-regexp)
|
||||
(not (string-match exclude-regexp sname)))
|
||||
(not (string-match "-syntax-table\\'" sname)))
|
||||
(unless (or (stringp value)
|
||||
(memq value '(nil t))
|
||||
(numberp value)
|
||||
(vectorp value))
|
||||
(setq value `(quote ,value)))
|
||||
(when noprops
|
||||
(setq value (funcall async-variables-noprops-function
|
||||
value)))
|
||||
(when (or (null predicate)
|
||||
(funcall predicate sym))
|
||||
(setq bindings (cons value bindings)
|
||||
bindings (cons sym bindings)))))))
|
||||
bindings)))
|
||||
|
||||
(defalias 'async-inject-environment 'async-inject-variables)
|
||||
|
||||
(defun async-handle-result (func result buf)
|
||||
(if (null func)
|
||||
(progn
|
||||
(set (make-local-variable 'async-callback-value) result)
|
||||
(set (make-local-variable 'async-callback-value-set) t))
|
||||
(unwind-protect
|
||||
(if (and (listp result)
|
||||
(eq 'async-signal (nth 0 result)))
|
||||
(signal (car (nth 1 result))
|
||||
(cdr (nth 1 result)))
|
||||
(funcall func result))
|
||||
(unless async-debug
|
||||
(kill-buffer buf)))))
|
||||
|
||||
(defun async-when-done (proc &optional _change)
|
||||
"Process sentinel used to retrieve the value from the child process."
|
||||
(when (eq 'exit (process-status proc))
|
||||
(with-current-buffer (process-buffer proc)
|
||||
(let ((async-current-process proc))
|
||||
(if (= 0 (process-exit-status proc))
|
||||
(if async-callback-for-process
|
||||
(if async-callback
|
||||
(prog1
|
||||
(funcall async-callback proc)
|
||||
(unless async-debug
|
||||
(kill-buffer (current-buffer))))
|
||||
(set (make-local-variable 'async-callback-value) proc)
|
||||
(set (make-local-variable 'async-callback-value-set) t))
|
||||
(goto-char (point-max))
|
||||
(backward-sexp)
|
||||
(async-handle-result async-callback (read (current-buffer))
|
||||
(current-buffer)))
|
||||
(set (make-local-variable 'async-callback-value)
|
||||
(list 'error
|
||||
(format "Async process '%s' failed with exit code %d"
|
||||
(process-name proc) (process-exit-status proc))))
|
||||
(set (make-local-variable 'async-callback-value-set) t))))))
|
||||
|
||||
(defun async--receive-sexp (&optional stream)
|
||||
(let ((sexp (decode-coding-string (base64-decode-string
|
||||
(read stream)) 'utf-8-auto))
|
||||
;; Parent expects UTF-8 encoded text.
|
||||
(coding-system-for-write 'utf-8-auto))
|
||||
(if async-debug
|
||||
(message "Received sexp {{{%s}}}" (pp-to-string sexp)))
|
||||
(setq sexp (read sexp))
|
||||
(if async-debug
|
||||
(message "Read sexp {{{%s}}}" (pp-to-string sexp)))
|
||||
(eval sexp)))
|
||||
|
||||
(defun async--insert-sexp (sexp)
|
||||
(let (print-level
|
||||
print-length
|
||||
(print-escape-nonascii t)
|
||||
(print-circle t))
|
||||
(prin1 sexp (current-buffer))
|
||||
;; Just in case the string we're sending might contain EOF
|
||||
(encode-coding-region (point-min) (point-max) 'utf-8-auto)
|
||||
(base64-encode-region (point-min) (point-max) t)
|
||||
(goto-char (point-min)) (insert ?\")
|
||||
(goto-char (point-max)) (insert ?\" ?\n)))
|
||||
|
||||
(defun async--transmit-sexp (process sexp)
|
||||
(with-temp-buffer
|
||||
(if async-debug
|
||||
(message "Transmitting sexp {{{%s}}}" (pp-to-string sexp)))
|
||||
(async--insert-sexp sexp)
|
||||
(process-send-region process (point-min) (point-max))))
|
||||
|
||||
(defun async-batch-invoke ()
|
||||
"Called from the child Emacs process' command-line."
|
||||
;; Make sure 'message' and 'prin1' encode stuff in UTF-8, as parent
|
||||
;; process expects.
|
||||
(let ((coding-system-for-write 'utf-8-auto))
|
||||
(setq async-in-child-emacs t
|
||||
debug-on-error async-debug)
|
||||
(if debug-on-error
|
||||
(prin1 (funcall
|
||||
(async--receive-sexp (unless async-send-over-pipe
|
||||
command-line-args-left))))
|
||||
(condition-case err
|
||||
(prin1 (funcall
|
||||
(async--receive-sexp (unless async-send-over-pipe
|
||||
command-line-args-left))))
|
||||
(error
|
||||
(prin1 (list 'async-signal err)))))))
|
||||
|
||||
(defun async-ready (future)
|
||||
"Query a FUTURE to see if it is ready.
|
||||
|
||||
I.e., if no blocking
|
||||
would result from a call to `async-get' on that FUTURE."
|
||||
(and (memq (process-status future) '(exit signal))
|
||||
(let ((buf (process-buffer future)))
|
||||
(if (buffer-live-p buf)
|
||||
(with-current-buffer buf
|
||||
async-callback-value-set)
|
||||
t))))
|
||||
|
||||
(defun async-wait (future)
|
||||
"Wait for FUTURE to become ready."
|
||||
(while (not (async-ready future))
|
||||
(sleep-for 0.05)))
|
||||
|
||||
(defun async-get (future)
|
||||
"Get the value from process FUTURE when it is ready.
|
||||
FUTURE is returned by `async-start' or `async-start-process' when
|
||||
its FINISH-FUNC is nil."
|
||||
(and future (async-wait future))
|
||||
(let ((buf (process-buffer future)))
|
||||
(when (buffer-live-p buf)
|
||||
(with-current-buffer buf
|
||||
(async-handle-result
|
||||
#'identity async-callback-value (current-buffer))))))
|
||||
|
||||
(defun async-message-p (value)
|
||||
"Return true of VALUE is an async.el message packet."
|
||||
(and (listp value)
|
||||
(plist-get value :async-message)))
|
||||
|
||||
(defun async-send (&rest args)
|
||||
"Send the given messages to the asychronous Emacs PROCESS."
|
||||
(let ((args (append args '(:async-message t))))
|
||||
(if async-in-child-emacs
|
||||
(if async-callback
|
||||
(funcall async-callback args))
|
||||
(async--transmit-sexp (car args) (list 'quote (cdr args))))))
|
||||
|
||||
(defun async-receive ()
|
||||
"Send the given messages to the asychronous Emacs PROCESS."
|
||||
(async--receive-sexp))
|
||||
|
||||
;;;###autoload
|
||||
(defun async-start-process (name program finish-func &rest program-args)
|
||||
"Start the executable PROGRAM asynchronously. See `async-start'.
|
||||
PROGRAM is passed PROGRAM-ARGS, calling FINISH-FUNC with the
|
||||
process object when done. If FINISH-FUNC is nil, the future
|
||||
object will return the process object when the program is
|
||||
finished. Set DEFAULT-DIRECTORY to change PROGRAM's current
|
||||
working directory."
|
||||
(let* ((buf (generate-new-buffer (concat "*" name "*")))
|
||||
(proc (let ((process-connection-type nil))
|
||||
(apply #'start-process name buf program program-args))))
|
||||
(with-current-buffer buf
|
||||
(set (make-local-variable 'async-callback) finish-func)
|
||||
(set-process-sentinel proc #'async-when-done)
|
||||
(unless (string= name "emacs")
|
||||
(set (make-local-variable 'async-callback-for-process) t))
|
||||
proc)))
|
||||
|
||||
(defvar async-quiet-switch "-Q"
|
||||
"The Emacs parameter to use to call emacs without config.
|
||||
Can be one of \"-Q\" or \"-q\".
|
||||
Default is \"-Q\" but it is sometimes useful to use \"-q\" to have a
|
||||
enhanced config or some more variables loaded.")
|
||||
|
||||
;;;###autoload
|
||||
(defun async-start (start-func &optional finish-func)
|
||||
"Execute START-FUNC (often a lambda) in a subordinate Emacs process.
|
||||
When done, the return value is passed to FINISH-FUNC. Example:
|
||||
|
||||
(async-start
|
||||
;; What to do in the child process
|
||||
(lambda ()
|
||||
(message \"This is a test\")
|
||||
(sleep-for 3)
|
||||
222)
|
||||
|
||||
;; What to do when it finishes
|
||||
(lambda (result)
|
||||
(message \"Async process done, result should be 222: %s\"
|
||||
result)))
|
||||
|
||||
If FINISH-FUNC is nil or missing, a future is returned that can
|
||||
be inspected using `async-get', blocking until the value is
|
||||
ready. Example:
|
||||
|
||||
(let ((proc (async-start
|
||||
;; What to do in the child process
|
||||
(lambda ()
|
||||
(message \"This is a test\")
|
||||
(sleep-for 3)
|
||||
222))))
|
||||
|
||||
(message \"I'm going to do some work here\") ;; ....
|
||||
|
||||
(message \"Waiting on async process, result should be 222: %s\"
|
||||
(async-get proc)))
|
||||
|
||||
If you don't want to use a callback, and you don't care about any
|
||||
return value from the child process, pass the `ignore' symbol as
|
||||
the second argument (if you don't, and never call `async-get', it
|
||||
will leave *emacs* process buffers hanging around):
|
||||
|
||||
(async-start
|
||||
(lambda ()
|
||||
(delete-file \"a remote file on a slow link\" nil))
|
||||
'ignore)
|
||||
|
||||
Note: Even when FINISH-FUNC is present, a future is still
|
||||
returned except that it yields no value (since the value is
|
||||
passed to FINISH-FUNC). Call `async-get' on such a future always
|
||||
returns nil. It can still be useful, however, as an argument to
|
||||
`async-ready' or `async-wait'."
|
||||
(let ((sexp start-func)
|
||||
;; Subordinate Emacs will send text encoded in UTF-8.
|
||||
(coding-system-for-read 'utf-8-auto))
|
||||
(setq async--procvar
|
||||
(async-start-process
|
||||
"emacs" (file-truename
|
||||
(expand-file-name invocation-name
|
||||
invocation-directory))
|
||||
finish-func
|
||||
async-quiet-switch "-l"
|
||||
;; Using `locate-library' ensure we use the right file
|
||||
;; when the .elc have been deleted.
|
||||
(locate-library "async")
|
||||
"-batch" "-f" "async-batch-invoke"
|
||||
(if async-send-over-pipe
|
||||
"<none>"
|
||||
(with-temp-buffer
|
||||
(async--insert-sexp (list 'quote sexp))
|
||||
(buffer-string)))))
|
||||
(if async-send-over-pipe
|
||||
(async--transmit-sexp async--procvar (list 'quote sexp)))
|
||||
async--procvar))
|
||||
|
||||
(defmacro async-sandbox(func)
|
||||
"Evaluate FUNC in a separate Emacs process, synchronously."
|
||||
`(async-get (async-start ,func)))
|
||||
|
||||
(defun async--fold-left (fn forms bindings)
|
||||
(let ((res forms))
|
||||
(dolist (binding bindings)
|
||||
(setq res (funcall fn res
|
||||
(if (listp binding)
|
||||
binding
|
||||
(list binding)))))
|
||||
res))
|
||||
|
||||
(defmacro async-let (bindings &rest forms)
|
||||
"Implements `let', but each binding is established asynchronously.
|
||||
For example:
|
||||
|
||||
(async-let ((x (foo))
|
||||
(y (bar)))
|
||||
(message \"%s %s\" x y))
|
||||
|
||||
expands to ==>
|
||||
|
||||
(async-start (foo)
|
||||
(lambda (x)
|
||||
(async-start (bar)
|
||||
(lambda (y)
|
||||
(message \"%s %s\" x y)))))"
|
||||
(declare (indent 1))
|
||||
(async--fold-left
|
||||
(lambda (acc binding)
|
||||
(let ((fun (pcase (cadr binding)
|
||||
((and (pred functionp) f) f)
|
||||
(f `(lambda () ,f)))))
|
||||
`(async-start ,fun
|
||||
(lambda (,(car binding))
|
||||
,acc))))
|
||||
`(progn ,@forms)
|
||||
(reverse bindings)))
|
||||
|
||||
(provide 'async)
|
||||
|
||||
;;; async.el ends here
|
BIN
elpa/async-20191030.2138/async.elc
Normal file
BIN
elpa/async-20191030.2138/async.elc
Normal file
Binary file not shown.
408
elpa/async-20191030.2138/dired-async.el
Normal file
408
elpa/async-20191030.2138/dired-async.el
Normal file
|
@ -0,0 +1,408 @@
|
|||
;;; dired-async.el --- Asynchronous dired actions -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2012-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Authors: John Wiegley <jwiegley@gmail.com>
|
||||
;; Thierry Volpiatto <thierry.volpiatto@gmail.com>
|
||||
|
||||
;; Keywords: dired async network
|
||||
;; X-URL: https://github.com/jwiegley/dired-async
|
||||
|
||||
;; This program 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 2, or (at
|
||||
;; your option) any later version.
|
||||
|
||||
;; This program 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; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
;; Boston, MA 02111-1307, USA.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; This file provide a redefinition of `dired-create-file' function,
|
||||
;; performs copies, moves and all what is handled by `dired-create-file'
|
||||
;; in the background using a slave Emacs process,
|
||||
;; by means of the async.el module.
|
||||
;; To use it, put this in your .emacs:
|
||||
|
||||
;; (dired-async-mode 1)
|
||||
|
||||
;; This will enable async copy/rename etc...
|
||||
;; in dired and helm.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'cl-lib)
|
||||
(require 'dired-aux)
|
||||
(require 'async)
|
||||
|
||||
(eval-when-compile
|
||||
(defvar async-callback))
|
||||
|
||||
(defgroup dired-async nil
|
||||
"Copy rename files asynchronously from dired."
|
||||
:group 'dired)
|
||||
|
||||
(defcustom dired-async-env-variables-regexp
|
||||
"\\`\\(tramp-\\(default\\|connection\\|remote\\)\\|ange-ftp\\)-.*"
|
||||
"Variables matching this regexp will be loaded on Child Emacs."
|
||||
:type 'regexp
|
||||
:group 'dired-async)
|
||||
|
||||
(defcustom dired-async-message-function 'dired-async-mode-line-message
|
||||
"Function to use to notify result when operation finish.
|
||||
Should take same args as `message'."
|
||||
:group 'dired-async
|
||||
:type 'function)
|
||||
|
||||
(defcustom dired-async-log-file "/tmp/dired-async.log"
|
||||
"File use to communicate errors from Child Emacs to host Emacs."
|
||||
:group 'dired-async
|
||||
:type 'string)
|
||||
|
||||
(defcustom dired-async-mode-lighter '(:eval
|
||||
(when (eq major-mode 'dired-mode)
|
||||
" Async"))
|
||||
"Mode line lighter used for `dired-async-mode'."
|
||||
:group 'dired-async
|
||||
:risky t
|
||||
:type 'sexp)
|
||||
|
||||
(defface dired-async-message
|
||||
'((t (:foreground "yellow")))
|
||||
"Face used for mode-line message."
|
||||
:group 'dired-async)
|
||||
|
||||
(defface dired-async-failures
|
||||
'((t (:foreground "red")))
|
||||
"Face used for mode-line message."
|
||||
:group 'dired-async)
|
||||
|
||||
(defface dired-async-mode-message
|
||||
'((t (:foreground "Gold")))
|
||||
"Face used for `dired-async--modeline-mode' lighter."
|
||||
:group 'dired-async)
|
||||
|
||||
(define-minor-mode dired-async--modeline-mode
|
||||
"Notify mode-line that an async process run."
|
||||
:group 'dired-async
|
||||
:global t
|
||||
:lighter (:eval (propertize (format " [%s Async job(s) running]"
|
||||
(length (dired-async-processes)))
|
||||
'face 'dired-async-mode-message))
|
||||
(unless dired-async--modeline-mode
|
||||
(let ((visible-bell t)) (ding))))
|
||||
|
||||
(defun dired-async-mode-line-message (text face &rest args)
|
||||
"Notify end of operation in `mode-line'."
|
||||
(message nil)
|
||||
(let ((mode-line-format (concat
|
||||
" " (propertize
|
||||
(if args
|
||||
(apply #'format text args)
|
||||
text)
|
||||
'face face))))
|
||||
(force-mode-line-update)
|
||||
(sit-for 3)
|
||||
(force-mode-line-update)))
|
||||
|
||||
(defun dired-async-processes ()
|
||||
(cl-loop for p in (process-list)
|
||||
when (cl-loop for c in (process-command p) thereis
|
||||
(string= "async-batch-invoke" c))
|
||||
collect p))
|
||||
|
||||
(defun dired-async-kill-process ()
|
||||
(interactive)
|
||||
(let* ((processes (dired-async-processes))
|
||||
(proc (car (last processes))))
|
||||
(and proc (delete-process proc))
|
||||
(unless (> (length processes) 1)
|
||||
(dired-async--modeline-mode -1))))
|
||||
|
||||
(defun dired-async-after-file-create (total operation failures skipped)
|
||||
"Callback function used for operation handled by `dired-create-file'."
|
||||
(unless (dired-async-processes)
|
||||
;; Turn off mode-line notification
|
||||
;; only when last process end.
|
||||
(dired-async--modeline-mode -1))
|
||||
(when operation
|
||||
(if (file-exists-p dired-async-log-file)
|
||||
(progn
|
||||
(pop-to-buffer (get-buffer-create dired-log-buffer))
|
||||
(goto-char (point-max))
|
||||
(setq inhibit-read-only t)
|
||||
(insert "Error: ")
|
||||
(insert-file-contents dired-async-log-file)
|
||||
(special-mode)
|
||||
(shrink-window-if-larger-than-buffer)
|
||||
(delete-file dired-async-log-file))
|
||||
(run-with-timer
|
||||
0.1 nil
|
||||
(lambda ()
|
||||
;; First send error messages.
|
||||
(cond (failures
|
||||
(funcall dired-async-message-function
|
||||
"%s failed for %d of %d file%s -- See *Dired log* buffer"
|
||||
'dired-async-failures
|
||||
(car operation) (length failures)
|
||||
total (dired-plural-s total)))
|
||||
(skipped
|
||||
(funcall dired-async-message-function
|
||||
"%s: %d of %d file%s skipped -- See *Dired log* buffer"
|
||||
'dired-async-failures
|
||||
(car operation) (length skipped) total
|
||||
(dired-plural-s total))))
|
||||
(when dired-buffers
|
||||
(cl-loop for (_f . b) in dired-buffers
|
||||
when (buffer-live-p b)
|
||||
do (with-current-buffer b
|
||||
(when (and (not (file-remote-p default-directory nil t))
|
||||
(file-exists-p default-directory))
|
||||
(revert-buffer nil t)))))
|
||||
;; Finally send the success message.
|
||||
(funcall dired-async-message-function
|
||||
"Asynchronous %s of %s on %s file%s done"
|
||||
'dired-async-message
|
||||
(car operation) (cadr operation)
|
||||
total (dired-plural-s total)))))))
|
||||
|
||||
(defun dired-async-maybe-kill-ftp ()
|
||||
"Return a form to kill ftp process in child emacs."
|
||||
(quote
|
||||
(progn
|
||||
(require 'cl-lib)
|
||||
(let ((buf (cl-loop for b in (buffer-list)
|
||||
thereis (and (string-match
|
||||
"\\`\\*ftp.*"
|
||||
(buffer-name b)) b))))
|
||||
(when buf (kill-buffer buf))))))
|
||||
|
||||
(defvar overwrite-query)
|
||||
(defun dired-async-create-files (file-creator operation fn-list name-constructor
|
||||
&optional _marker-char)
|
||||
"Same as `dired-create-files' but asynchronous.
|
||||
|
||||
See `dired-create-files' for the behavior of arguments."
|
||||
(setq overwrite-query nil)
|
||||
(let ((total (length fn-list))
|
||||
failures async-fn-list skipped callback
|
||||
async-quiet-switch)
|
||||
(let (to)
|
||||
(dolist (from fn-list)
|
||||
(setq to (funcall name-constructor from))
|
||||
(if (and (equal to from)
|
||||
(null (eq file-creator 'backup-file)))
|
||||
(progn
|
||||
(setq to nil)
|
||||
(dired-log "Cannot %s to same file: %s\n"
|
||||
(downcase operation) from)))
|
||||
(if (not to)
|
||||
(setq skipped (cons (dired-make-relative from) skipped))
|
||||
(let* ((overwrite (and (null (eq file-creator 'backup-file))
|
||||
(file-exists-p to)))
|
||||
(dired-overwrite-confirmed ; for dired-handle-overwrite
|
||||
(and overwrite
|
||||
(let ((help-form `(format "\
|
||||
Type SPC or `y' to overwrite file `%s',
|
||||
DEL or `n' to skip to next,
|
||||
ESC or `q' to not overwrite any of the remaining files,
|
||||
`!' to overwrite all remaining files with no more questions." ,to)))
|
||||
(dired-query 'overwrite-query "Overwrite `%s'?" to)))))
|
||||
;; Handle the `dired-copy-file' file-creator specially
|
||||
;; When copying a directory to another directory or
|
||||
;; possibly to itself or one of its subdirectories.
|
||||
;; e.g "~/foo/" => "~/test/"
|
||||
;; or "~/foo/" =>"~/foo/"
|
||||
;; or "~/foo/ => ~/foo/bar/")
|
||||
;; In this case the 'name-constructor' have set the destination
|
||||
;; TO to "~/test/foo" because the old emacs23 behavior
|
||||
;; of `copy-directory' was to not create the subdirectory
|
||||
;; and instead copy the contents.
|
||||
;; With the new behavior of `copy-directory'
|
||||
;; (similar to the `cp' shell command) we don't
|
||||
;; need such a construction of the target directory,
|
||||
;; so modify the destination TO to "~/test/" instead of "~/test/foo/".
|
||||
(let ((destname (file-name-directory to)))
|
||||
(when (and (file-directory-p from)
|
||||
(file-directory-p to)
|
||||
(eq file-creator 'dired-copy-file))
|
||||
(setq to destname))
|
||||
;; If DESTNAME is a subdirectory of FROM, not a symlink,
|
||||
;; and the method in use is copying, signal an error.
|
||||
(and (eq t (car (file-attributes destname)))
|
||||
(eq file-creator 'dired-copy-file)
|
||||
(file-in-directory-p destname from)
|
||||
(error "Cannot copy `%s' into its subdirectory `%s'"
|
||||
from to)))
|
||||
(if overwrite
|
||||
(or (and dired-overwrite-confirmed
|
||||
(push (cons from to) async-fn-list))
|
||||
(progn
|
||||
(push (dired-make-relative from) failures)
|
||||
(dired-log "%s `%s' to `%s' failed\n"
|
||||
operation from to)))
|
||||
(push (cons from to) async-fn-list)))))
|
||||
;; Fix tramp issue #80 with emacs-26, use "-q" only when needed.
|
||||
(setq async-quiet-switch
|
||||
(if (and (boundp 'tramp-cache-read-persistent-data)
|
||||
async-fn-list
|
||||
(cl-loop for (_from . to) in async-fn-list
|
||||
thereis (file-remote-p to)))
|
||||
"-q" "-Q"))
|
||||
;; When failures have been printed to dired log add the date at bob.
|
||||
(when (or failures skipped) (dired-log t))
|
||||
;; When async-fn-list is empty that's mean only one file
|
||||
;; had to be copied and user finally answer NO.
|
||||
;; In this case async process will never start and callback
|
||||
;; will have no chance to run, so notify failures here.
|
||||
(unless async-fn-list
|
||||
(cond (failures
|
||||
(funcall dired-async-message-function
|
||||
"%s failed for %d of %d file%s -- See *Dired log* buffer"
|
||||
'dired-async-failures
|
||||
operation (length failures)
|
||||
total (dired-plural-s total)))
|
||||
(skipped
|
||||
(funcall dired-async-message-function
|
||||
"%s: %d of %d file%s skipped -- See *Dired log* buffer"
|
||||
'dired-async-failures
|
||||
operation (length skipped) total
|
||||
(dired-plural-s total)))))
|
||||
;; Setup callback.
|
||||
(setq callback
|
||||
(lambda (&optional _ignore)
|
||||
(dired-async-after-file-create
|
||||
total (list operation (length async-fn-list)) failures skipped)
|
||||
(when (string= (downcase operation) "rename")
|
||||
(cl-loop for (file . to) in async-fn-list
|
||||
for bf = (get-file-buffer file)
|
||||
for destp = (file-exists-p to)
|
||||
do (and bf destp
|
||||
(with-current-buffer bf
|
||||
(set-visited-file-name to t t))))))))
|
||||
;; Start async process.
|
||||
(when async-fn-list
|
||||
(async-start `(lambda ()
|
||||
(require 'cl-lib) (require 'dired-aux) (require 'dired-x)
|
||||
,(async-inject-variables dired-async-env-variables-regexp)
|
||||
(let ((dired-recursive-copies (quote always))
|
||||
(dired-copy-preserve-time
|
||||
,dired-copy-preserve-time))
|
||||
(setq overwrite-backup-query nil)
|
||||
;; Inline `backup-file' as long as it is not
|
||||
;; available in emacs.
|
||||
(defalias 'backup-file
|
||||
;; Same feature as "cp -f --backup=numbered from to"
|
||||
;; Symlinks are copied as file from source unlike
|
||||
;; `dired-copy-file' which is same as cp -d.
|
||||
;; Directories are omitted.
|
||||
(lambda (from to ok)
|
||||
(cond ((file-directory-p from) (ignore))
|
||||
(t (let ((count 0))
|
||||
(while (let ((attrs (file-attributes to)))
|
||||
(and attrs (null (nth 0 attrs))))
|
||||
(cl-incf count)
|
||||
(setq to (concat (file-name-sans-versions to)
|
||||
(format ".~%s~" count)))))
|
||||
(condition-case err
|
||||
(copy-file from to ok dired-copy-preserve-time)
|
||||
(file-date-error
|
||||
(dired-log "Can't set date on %s:\n%s\n" from err)))))))
|
||||
;; Now run the FILE-CREATOR function on files.
|
||||
(cl-loop with fn = (quote ,file-creator)
|
||||
for (from . dest) in (quote ,async-fn-list)
|
||||
do (condition-case err
|
||||
(funcall fn from dest t)
|
||||
(file-error
|
||||
(dired-log "%s: %s\n" (car err) (cdr err)))
|
||||
nil))
|
||||
(when (get-buffer dired-log-buffer)
|
||||
(dired-log t)
|
||||
(with-current-buffer dired-log-buffer
|
||||
(write-region (point-min) (point-max)
|
||||
,dired-async-log-file))))
|
||||
,(dired-async-maybe-kill-ftp))
|
||||
callback)
|
||||
;; Run mode-line notifications while process running.
|
||||
(dired-async--modeline-mode 1)
|
||||
(message "%s proceeding asynchronously..." operation))))
|
||||
|
||||
(defvar wdired-use-interactive-rename)
|
||||
(defun dired-async-wdired-do-renames (old-fn &rest args)
|
||||
;; Perhaps a better fix would be to ask for renaming BEFORE starting
|
||||
;; OLD-FN when `wdired-use-interactive-rename' is non-nil. For now
|
||||
;; just bind it to nil to ensure no questions will be asked between
|
||||
;; each rename.
|
||||
(let (wdired-use-interactive-rename)
|
||||
(apply old-fn args)))
|
||||
|
||||
(defadvice wdired-do-renames (around wdired-async)
|
||||
(let (wdired-use-interactive-rename)
|
||||
ad-do-it))
|
||||
|
||||
(defadvice dired-create-files (around dired-async)
|
||||
(dired-async-create-files file-creator operation fn-list
|
||||
name-constructor marker-char))
|
||||
|
||||
;;;###autoload
|
||||
(define-minor-mode dired-async-mode
|
||||
"Do dired actions asynchronously."
|
||||
:group 'dired-async
|
||||
:lighter dired-async-mode-lighter
|
||||
:global t
|
||||
(if dired-async-mode
|
||||
(if (fboundp 'advice-add)
|
||||
(progn (advice-add 'dired-create-files :override #'dired-async-create-files)
|
||||
(advice-add 'wdired-do-renames :around #'dired-async-wdired-do-renames))
|
||||
(ad-activate 'dired-create-files)
|
||||
(ad-activate 'wdired-do-renames))
|
||||
(if (fboundp 'advice-remove)
|
||||
(progn (advice-remove 'dired-create-files #'dired-async-create-files)
|
||||
(advice-remove 'wdired-do-renames #'dired-async-wdired-do-renames))
|
||||
(ad-deactivate 'dired-create-files)
|
||||
(ad-deactivate 'wdired-do-renames))))
|
||||
|
||||
(defmacro dired-async--with-async-create-files (&rest body)
|
||||
"Evaluate BODY with ‘dired-create-files’ set to ‘dired-async-create-files’."
|
||||
(declare (indent 0))
|
||||
`(cl-letf (((symbol-function 'dired-create-files) #'dired-async-create-files))
|
||||
,@body))
|
||||
|
||||
;;;###autoload
|
||||
(defun dired-async-do-copy (&optional arg)
|
||||
"Run ‘dired-do-copy’ asynchronously."
|
||||
(interactive "P")
|
||||
(dired-async--with-async-create-files
|
||||
(dired-do-copy arg)))
|
||||
|
||||
;;;###autoload
|
||||
(defun dired-async-do-symlink (&optional arg)
|
||||
"Run ‘dired-do-symlink’ asynchronously."
|
||||
(interactive "P")
|
||||
(dired-async--with-async-create-files
|
||||
(dired-do-symlink arg)))
|
||||
|
||||
;;;###autoload
|
||||
(defun dired-async-do-hardlink (&optional arg)
|
||||
"Run ‘dired-do-hardlink’ asynchronously."
|
||||
(interactive "P")
|
||||
(dired-async--with-async-create-files
|
||||
(dired-do-hardlink arg)))
|
||||
|
||||
;;;###autoload
|
||||
(defun dired-async-do-rename (&optional arg)
|
||||
"Run ‘dired-do-rename’ asynchronously."
|
||||
(interactive "P")
|
||||
(dired-async--with-async-create-files
|
||||
(dired-do-rename arg)))
|
||||
|
||||
(provide 'dired-async)
|
||||
|
||||
;;; dired-async.el ends here
|
BIN
elpa/async-20191030.2138/dired-async.elc
Normal file
BIN
elpa/async-20191030.2138/dired-async.elc
Normal file
Binary file not shown.
73
elpa/async-20191030.2138/smtpmail-async.el
Normal file
73
elpa/async-20191030.2138/smtpmail-async.el
Normal file
|
@ -0,0 +1,73 @@
|
|||
;;; smtpmail-async.el --- Send e-mail with smtpmail.el asynchronously -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2012-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: John Wiegley <jwiegley@gmail.com>
|
||||
;; Created: 18 Jun 2012
|
||||
|
||||
;; Keywords: email async
|
||||
;; X-URL: https://github.com/jwiegley/emacs-async
|
||||
|
||||
;; This program 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 2, or (at
|
||||
;; your option) any later version.
|
||||
|
||||
;; This program 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; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
;; Boston, MA 02111-1307, USA.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Send e-mail with smtpmail.el asynchronously. To use:
|
||||
;;
|
||||
;; (require 'smtpmail-async)
|
||||
;;
|
||||
;; (setq send-mail-function 'async-smtpmail-send-it
|
||||
;; message-send-mail-function 'async-smtpmail-send-it)
|
||||
;;
|
||||
;; This assumes you already have smtpmail.el working.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(defgroup smtpmail-async nil
|
||||
"Send e-mail with smtpmail.el asynchronously"
|
||||
:group 'smptmail)
|
||||
|
||||
(require 'async)
|
||||
(require 'smtpmail)
|
||||
(require 'message)
|
||||
|
||||
(defvar async-smtpmail-before-send-hook nil
|
||||
"Hook running in the child emacs in `async-smtpmail-send-it'.
|
||||
It is called just before calling `smtpmail-send-it'.")
|
||||
|
||||
(defun async-smtpmail-send-it ()
|
||||
(let ((to (message-field-value "To"))
|
||||
(buf-content (buffer-substring-no-properties
|
||||
(point-min) (point-max))))
|
||||
(message "Delivering message to %s..." to)
|
||||
(async-start
|
||||
`(lambda ()
|
||||
(require 'smtpmail)
|
||||
(with-temp-buffer
|
||||
(insert ,buf-content)
|
||||
(set-buffer-multibyte nil)
|
||||
;; Pass in the variable environment for smtpmail
|
||||
,(async-inject-variables
|
||||
"\\`\\(smtpmail\\|async-smtpmail\\|\\(user-\\)?mail\\)-\\|auth-sources\\|epg\\|nsm"
|
||||
nil "\\`\\(mail-header-format-function\\|smtpmail-address-buffer\\|mail-mode-abbrev-table\\)")
|
||||
(run-hooks 'async-smtpmail-before-send-hook)
|
||||
(smtpmail-send-it)))
|
||||
(lambda (&optional _ignore)
|
||||
(message "Delivering message to %s...done" to)))))
|
||||
|
||||
(provide 'smtpmail-async)
|
||||
|
||||
;;; smtpmail-async.el ends here
|
BIN
elpa/async-20191030.2138/smtpmail-async.elc
Normal file
BIN
elpa/async-20191030.2138/smtpmail-async.elc
Normal file
Binary file not shown.
53
elpa/git-commit-20191116.2035/git-commit-autoloads.el
Normal file
53
elpa/git-commit-20191116.2035/git-commit-autoloads.el
Normal file
|
@ -0,0 +1,53 @@
|
|||
;;; git-commit-autoloads.el --- automatically extracted autoloads
|
||||
;;
|
||||
;;; Code:
|
||||
|
||||
(add-to-list 'load-path (directory-file-name
|
||||
(or (file-name-directory #$) (car load-path))))
|
||||
|
||||
|
||||
;;;### (autoloads nil "git-commit" "git-commit.el" (0 0 0 0))
|
||||
;;; Generated autoloads from git-commit.el
|
||||
|
||||
(defvar global-git-commit-mode t "\
|
||||
Non-nil if Global Git-Commit mode is enabled.
|
||||
See the `global-git-commit-mode' command
|
||||
for a description of this minor mode.
|
||||
Setting this variable directly does not take effect;
|
||||
either customize it (see the info node `Easy Customization')
|
||||
or call the function `global-git-commit-mode'.")
|
||||
|
||||
(custom-autoload 'global-git-commit-mode "git-commit" nil)
|
||||
|
||||
(autoload 'global-git-commit-mode "git-commit" "\
|
||||
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.
|
||||
|
||||
\(fn &optional ARG)" t nil)
|
||||
|
||||
(defconst git-commit-filename-regexp "/\\(\\(\\(COMMIT\\|NOTES\\|PULLREQ\\|MERGEREQ\\|TAG\\)_EDIT\\|MERGE_\\|\\)MSG\\|\\(BRANCH\\|EDIT\\)_DESCRIPTION\\)\\'")
|
||||
|
||||
(autoload 'git-commit-setup-check-buffer "git-commit" "\
|
||||
|
||||
|
||||
\(fn)" nil nil)
|
||||
|
||||
(autoload 'git-commit-setup "git-commit" "\
|
||||
|
||||
|
||||
\(fn)" nil nil)
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "git-commit" '("git-commit-")))
|
||||
|
||||
;;;***
|
||||
|
||||
;; Local Variables:
|
||||
;; version-control: never
|
||||
;; no-byte-compile: t
|
||||
;; no-update-autoloads: t
|
||||
;; coding: utf-8
|
||||
;; End:
|
||||
;;; git-commit-autoloads.el ends here
|
2
elpa/git-commit-20191116.2035/git-commit-pkg.el
Normal file
2
elpa/git-commit-20191116.2035/git-commit-pkg.el
Normal file
|
@ -0,0 +1,2 @@
|
|||
;;; -*- no-byte-compile: t -*-
|
||||
(define-package "git-commit" "20191116.2035" "Edit Git commit messages" '((emacs "25.1") (dash "20180910") (with-editor "20181103")) :commit "e311e444bddbd92ec945872e99c9cbf85d679d07" :keywords '("git" "tools" "vc") :maintainer '("Jonas Bernoulli" . "jonas@bernoul.li") :url "https://github.com/magit/magit")
|
993
elpa/git-commit-20191116.2035/git-commit.el
Normal file
993
elpa/git-commit-20191116.2035/git-commit.el
Normal file
|
@ -0,0 +1,993 @@
|
|||
;;; git-commit.el --- Edit Git commit messages -*- lexical-binding: t; -*-
|
||||
|
||||
;; Copyright (C) 2010-2019 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 <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>
|
||||
|
||||
;; Package-Requires: ((emacs "25.1") (dash "20180910") (with-editor "20181103"))
|
||||
;; Package-Version: 20191116.2035
|
||||
;; Keywords: git tools vc
|
||||
;; Homepage: https://github.com/magit/magit
|
||||
|
||||
;; This file is not part of GNU Emacs.
|
||||
|
||||
;; 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; This package assists the user in writing good Git commit messages.
|
||||
|
||||
;; While Git allows for the message to be provided on the command
|
||||
;; line, it is preferable to tell Git to create the commit without
|
||||
;; actually passing it a message. Git then invokes the `$GIT_EDITOR'
|
||||
;; (or if that is undefined `$EDITOR') asking the user to provide the
|
||||
;; message by editing the file ".git/COMMIT_EDITMSG" (or another file
|
||||
;; in that directory, e.g. ".git/MERGE_MSG" for merge commits).
|
||||
|
||||
;; When `global-git-commit-mode' is enabled, which it is by default,
|
||||
;; then opening such a file causes the features described below, to
|
||||
;; be enabled in that buffer. Normally this would be done using a
|
||||
;; major-mode but to allow the use of any major-mode, as the user sees
|
||||
;; fit, it is done here by running a setup function, which among other
|
||||
;; things turns on the preferred major-mode, by default `text-mode'.
|
||||
|
||||
;; Git waits for the `$EDITOR' to finish and then either creates the
|
||||
;; commit using the contents of the file as commit message, or, if the
|
||||
;; editor process exited with a non-zero exit status, aborts without
|
||||
;; creating a commit. Unfortunately Emacsclient (which is what Emacs
|
||||
;; users should be using as `$EDITOR' or at least as `$GIT_EDITOR')
|
||||
;; does not differentiate between "successfully" editing a file and
|
||||
;; aborting; not out of the box that is.
|
||||
|
||||
;; By making use of the `with-editor' package this package provides
|
||||
;; both ways of finish an editing session. In either case the file
|
||||
;; is saved, but Emacseditor's exit code differs.
|
||||
;;
|
||||
;; C-c C-c Finish the editing session successfully by returning
|
||||
;; with exit code 0. Git then creates the commit using
|
||||
;; the message it finds in the file.
|
||||
;;
|
||||
;; C-c C-k Aborts the edit editing session by returning with exit
|
||||
;; code 1. Git then aborts the commit.
|
||||
|
||||
;; Aborting the commit does not cause the message to be lost, but
|
||||
;; relying solely on the file not being tampered with is risky. This
|
||||
;; package additionally stores all aborted messages for the duration
|
||||
;; of the current session (i.e. until you close Emacs). To get back
|
||||
;; an aborted message use M-p and M-n while editing a message.
|
||||
;;
|
||||
;; M-p Replace the buffer contents with the previous message
|
||||
;; from the message ring. Of course only after storing
|
||||
;; the current content there too.
|
||||
;;
|
||||
;; M-n Replace the buffer contents with the next message from
|
||||
;; the message ring, after storing the current content.
|
||||
|
||||
;; Some support for pseudo headers as used in some projects is
|
||||
;; provided by these commands:
|
||||
;;
|
||||
;; C-c C-s Insert a Signed-off-by header.
|
||||
;; C-c C-a Insert a Acked-by header.
|
||||
;; C-c C-m Insert a Modified-by header.
|
||||
;; C-c C-t Insert a Tested-by header.
|
||||
;; C-c C-r Insert a Reviewed-by header.
|
||||
;; C-c C-o Insert a Cc header.
|
||||
;; C-c C-p Insert a Reported-by header.
|
||||
;; C-c C-i Insert a Suggested-by header.
|
||||
|
||||
;; When Git requests a commit message from the user, it does so by
|
||||
;; having her edit a file which initially contains some comments,
|
||||
;; instructing her what to do, and providing useful information, such
|
||||
;; as which files were modified. These comments, even when left
|
||||
;; intact by the user, do not become part of the commit message. This
|
||||
;; package ensures these comments are propertizes as such and further
|
||||
;; prettifies them by using different faces for various parts, such as
|
||||
;; files.
|
||||
|
||||
;; Finally this package highlights style errors, like lines that are
|
||||
;; too long, or when the second line is not empty. It may even nag
|
||||
;; you when you attempt to finish the commit without having fixed
|
||||
;; these issues. The style checks and many other settings can easily
|
||||
;; be configured:
|
||||
;;
|
||||
;; M-x customize-group RET git-commit RET
|
||||
|
||||
;;; Code:
|
||||
;;;; Dependencies
|
||||
|
||||
(require 'dash)
|
||||
(require 'log-edit)
|
||||
(require 'magit-git nil t)
|
||||
(require 'magit-utils nil t)
|
||||
(require 'ring)
|
||||
(require 'server)
|
||||
(require 'with-editor)
|
||||
|
||||
(eval-when-compile
|
||||
(require 'recentf)
|
||||
(require 'subr-x))
|
||||
|
||||
;;;; Declarations
|
||||
|
||||
(defvar diff-default-read-only)
|
||||
(defvar flyspell-generic-check-word-predicate)
|
||||
(defvar font-lock-beg)
|
||||
(defvar font-lock-end)
|
||||
|
||||
(declare-function magit-expand-git-file-name "magit-git" (filename))
|
||||
(declare-function magit-list-local-branch-names "magit-git" ())
|
||||
(declare-function magit-list-remote-branch-names "magit-git"
|
||||
(&optional remote relative))
|
||||
|
||||
;;; Options
|
||||
;;;; Variables
|
||||
|
||||
(defgroup git-commit nil
|
||||
"Edit Git commit messages."
|
||||
:prefix "git-commit-"
|
||||
: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."
|
||||
:group 'git-commit
|
||||
:type 'boolean
|
||||
:global t
|
||||
:init-value t
|
||||
:initialize (lambda (symbol exp)
|
||||
(custom-initialize-default symbol exp)
|
||||
(when global-git-commit-mode
|
||||
(add-hook 'find-file-hook 'git-commit-setup-check-buffer)))
|
||||
(if global-git-commit-mode
|
||||
(add-hook 'find-file-hook 'git-commit-setup-check-buffer)
|
||||
(remove-hook 'find-file-hook 'git-commit-setup-check-buffer)))
|
||||
|
||||
(defcustom git-commit-major-mode 'text-mode
|
||||
"Major mode used to edit Git commit messages.
|
||||
The major mode configured here is turned on by the minor mode
|
||||
`git-commit-mode'."
|
||||
:group 'git-commit
|
||||
:type '(choice (function-item text-mode)
|
||||
(const :tag "No major mode")))
|
||||
|
||||
(defcustom git-commit-setup-hook
|
||||
'(git-commit-save-message
|
||||
git-commit-setup-changelog-support
|
||||
git-commit-turn-on-auto-fill
|
||||
git-commit-propertize-diff
|
||||
bug-reference-mode
|
||||
with-editor-usage-message)
|
||||
"Hook run at the end of `git-commit-setup'."
|
||||
:group 'git-commit
|
||||
:type 'hook
|
||||
:get (and (featurep 'magit-utils) 'magit-hook-custom-get)
|
||||
:options '(git-commit-save-message
|
||||
git-commit-setup-changelog-support
|
||||
git-commit-turn-on-auto-fill
|
||||
git-commit-turn-on-flyspell
|
||||
git-commit-propertize-diff
|
||||
bug-reference-mode
|
||||
with-editor-usage-message))
|
||||
|
||||
(defcustom git-commit-post-finish-hook nil
|
||||
"Hook run after the user finished writing a commit message.
|
||||
|
||||
\\<with-editor-mode-map>\
|
||||
This hook is only run after pressing \\[with-editor-finish] in a buffer used
|
||||
to edit a commit message. If a commit is created without the
|
||||
user typing a message into a buffer, then this hook is not run.
|
||||
|
||||
This hook is not run until the new commit has been created. If
|
||||
doing so takes Git longer than one second, then this hook isn't
|
||||
run at all. For certain commands such as `magit-rebase-continue'
|
||||
this hook is never run because doing so would lead to a race
|
||||
condition.
|
||||
|
||||
This hook is only run if `magit' is available.
|
||||
|
||||
Also see `magit-post-commit-hook'."
|
||||
:group 'git-commit
|
||||
:type 'hook
|
||||
:get (and (featurep 'magit-utils) 'magit-hook-custom-get))
|
||||
|
||||
(defcustom git-commit-finish-query-functions
|
||||
'(git-commit-check-style-conventions)
|
||||
"List of functions called to query before performing commit.
|
||||
|
||||
The commit message buffer is current while the functions are
|
||||
called. If any of them returns nil, then the commit is not
|
||||
performed and the buffer is not killed. The user should then
|
||||
fix the issue and try again.
|
||||
|
||||
The functions are called with one argument. If it is non-nil,
|
||||
then that indicates that the user used a prefix argument to
|
||||
force finishing the session despite issues. Functions should
|
||||
usually honor this wish and return non-nil."
|
||||
:options '(git-commit-check-style-conventions)
|
||||
:type 'hook
|
||||
:group 'git-commit)
|
||||
|
||||
(defcustom git-commit-style-convention-checks '(non-empty-second-line)
|
||||
"List of checks performed by `git-commit-check-style-conventions'.
|
||||
Valid members are `non-empty-second-line' and `overlong-summary-line'.
|
||||
That function is a member of `git-commit-finish-query-functions'."
|
||||
:options '(non-empty-second-line overlong-summary-line)
|
||||
:type '(list :convert-widget custom-hook-convert-widget)
|
||||
:group 'git-commit)
|
||||
|
||||
(defcustom git-commit-summary-max-length 68
|
||||
"Column beyond which characters in the summary lines are highlighted.
|
||||
|
||||
The highlighting indicates that the summary is getting too long
|
||||
by some standards. It does in no way imply that going over the
|
||||
limit a few characters or in some cases even many characters is
|
||||
anything that deserves shaming. It's just a friendly reminder
|
||||
that if you can make the summary shorter, then you might want
|
||||
to consider doing so."
|
||||
:group 'git-commit
|
||||
:safe 'numberp
|
||||
:type 'number)
|
||||
|
||||
(defcustom git-commit-fill-column nil
|
||||
"Override `fill-column' in commit message buffers.
|
||||
|
||||
If this is non-nil, then it should be an integer. If that is the
|
||||
case and the buffer-local value of `fill-column' is not already
|
||||
set by the time `git-commit-turn-on-auto-fill' is called as a
|
||||
member of `git-commit-setup-hook', then that function sets the
|
||||
buffer-local value of `fill-column' to the value of this option.
|
||||
|
||||
This option exists mostly for historic reasons. If you are not
|
||||
already using it, then you probably shouldn't start doing so."
|
||||
:group 'git-commit
|
||||
:safe 'numberp
|
||||
:type '(choice (const :tag "use regular fill-column")
|
||||
number))
|
||||
|
||||
(make-obsolete-variable 'git-commit-fill-column 'fill-column
|
||||
"Magit 2.11.0" 'set)
|
||||
|
||||
(defcustom git-commit-known-pseudo-headers
|
||||
'("Signed-off-by" "Acked-by" "Modified-by" "Cc"
|
||||
"Suggested-by" "Reported-by" "Tested-by" "Reviewed-by"
|
||||
"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)))
|
||||
:type '(repeat string))
|
||||
|
||||
;;;; Faces
|
||||
|
||||
(defgroup git-commit-faces nil
|
||||
"Faces used for highlighting Git commit messages."
|
||||
:prefix "git-commit-"
|
||||
:group 'git-commit
|
||||
:group 'faces)
|
||||
|
||||
(defface git-commit-summary
|
||||
'((t :inherit font-lock-type-face))
|
||||
"Face used for the summary in commit messages."
|
||||
:group 'git-commit-faces)
|
||||
|
||||
(defface git-commit-overlong-summary
|
||||
'((t :inherit font-lock-warning-face))
|
||||
"Face used for the tail of overlong commit message summaries."
|
||||
:group 'git-commit-faces)
|
||||
|
||||
(defface git-commit-nonempty-second-line
|
||||
'((t :inherit font-lock-warning-face))
|
||||
"Face used for non-whitespace on the second line of commit messages."
|
||||
:group 'git-commit-faces)
|
||||
|
||||
(defface git-commit-keyword
|
||||
'((t :inherit font-lock-string-face))
|
||||
"Face used for keywords in commit messages.
|
||||
In this context a \"keyword\" is text surrounded be brackets."
|
||||
:group 'git-commit-faces)
|
||||
|
||||
(define-obsolete-face-alias 'git-commit-note
|
||||
'git-commit-keyword "Git-Commit 2.91.0")
|
||||
|
||||
(defface git-commit-pseudo-header
|
||||
'((t :inherit font-lock-string-face))
|
||||
"Face used for pseudo headers in commit messages."
|
||||
:group 'git-commit-faces)
|
||||
|
||||
(defface git-commit-known-pseudo-header
|
||||
'((t :inherit font-lock-keyword-face))
|
||||
"Face used for the keywords of known pseudo headers in commit messages."
|
||||
:group 'git-commit-faces)
|
||||
|
||||
(defface git-commit-comment-branch-local
|
||||
(if (featurep 'magit)
|
||||
'((t :inherit magit-branch-local))
|
||||
'((t :inherit font-lock-variable-name-face)))
|
||||
"Face used for names of local branches in commit message comments."
|
||||
:group 'git-commit-faces)
|
||||
|
||||
(define-obsolete-face-alias 'git-commit-comment-branch
|
||||
'git-commit-comment-branch-local "Git-Commit 2.12.0")
|
||||
|
||||
(defface git-commit-comment-branch-remote
|
||||
(if (featurep 'magit)
|
||||
'((t :inherit magit-branch-remote))
|
||||
'((t :inherit font-lock-variable-name-face)))
|
||||
"Face used for names of remote branches in commit message comments.
|
||||
This is only used if Magit is available."
|
||||
:group 'git-commit-faces)
|
||||
|
||||
(defface git-commit-comment-detached
|
||||
'((t :inherit git-commit-comment-branch-local))
|
||||
"Face used for detached `HEAD' in commit message comments."
|
||||
:group 'git-commit-faces)
|
||||
|
||||
(defface git-commit-comment-heading
|
||||
'((t :inherit git-commit-known-pseudo-header))
|
||||
"Face used for headings in commit message comments."
|
||||
:group 'git-commit-faces)
|
||||
|
||||
(defface git-commit-comment-file
|
||||
'((t :inherit git-commit-pseudo-header))
|
||||
"Face used for file names in commit message comments."
|
||||
:group 'git-commit-faces)
|
||||
|
||||
(defface git-commit-comment-action
|
||||
'((t :inherit bold))
|
||||
"Face used for actions in commit message comments."
|
||||
:group 'git-commit-faces)
|
||||
|
||||
;;; Keymap
|
||||
|
||||
(defvar git-commit-mode-map
|
||||
(let ((map (make-sparse-keymap)))
|
||||
(cond ((featurep 'jkl)
|
||||
(define-key map (kbd "C-M-i") 'git-commit-prev-message)
|
||||
(define-key map (kbd "C-M-k") 'git-commit-next-message))
|
||||
(t
|
||||
(define-key map (kbd "M-p") 'git-commit-prev-message)
|
||||
(define-key map (kbd "M-n") 'git-commit-next-message)
|
||||
;; Old bindings to avoid confusion
|
||||
(define-key map (kbd "C-c C-x a") 'git-commit-ack)
|
||||
(define-key map (kbd "C-c C-x i") 'git-commit-suggested)
|
||||
(define-key map (kbd "C-c C-x m") 'git-commit-modified)
|
||||
(define-key map (kbd "C-c C-x o") 'git-commit-cc)
|
||||
(define-key map (kbd "C-c C-x p") 'git-commit-reported)
|
||||
(define-key map (kbd "C-c C-x r") 'git-commit-review)
|
||||
(define-key map (kbd "C-c C-x s") 'git-commit-signoff)
|
||||
(define-key map (kbd "C-c C-x t") 'git-commit-test)))
|
||||
(define-key map (kbd "C-c C-a") 'git-commit-ack)
|
||||
(define-key map (kbd "C-c C-i") 'git-commit-suggested)
|
||||
(define-key map (kbd "C-c C-m") 'git-commit-modified)
|
||||
(define-key map (kbd "C-c C-o") 'git-commit-cc)
|
||||
(define-key map (kbd "C-c C-p") 'git-commit-reported)
|
||||
(define-key map (kbd "C-c C-r") 'git-commit-review)
|
||||
(define-key map (kbd "C-c C-s") 'git-commit-signoff)
|
||||
(define-key map (kbd "C-c C-t") 'git-commit-test)
|
||||
(define-key map (kbd "C-c M-s") 'git-commit-save-message)
|
||||
map)
|
||||
"Key map used by `git-commit-mode'.")
|
||||
|
||||
;;; Menu
|
||||
|
||||
(require 'easymenu)
|
||||
(easy-menu-define git-commit-mode-menu git-commit-mode-map
|
||||
"Git Commit Mode Menu"
|
||||
'("Commit"
|
||||
["Previous" git-commit-prev-message t]
|
||||
["Next" git-commit-next-message t]
|
||||
"-"
|
||||
["Ack" git-commit-ack :active t
|
||||
:help "Insert an 'Acked-by' header"]
|
||||
["Sign-Off" git-commit-signoff :active t
|
||||
:help "Insert a 'Signed-off-by' header"]
|
||||
["Modified-by" git-commit-modified :active t
|
||||
:help "Insert a 'Modified-by' header"]
|
||||
["Tested-by" git-commit-test :active t
|
||||
:help "Insert a 'Tested-by' header"]
|
||||
["Reviewed-by" git-commit-review :active t
|
||||
:help "Insert a 'Reviewed-by' header"]
|
||||
["CC" git-commit-cc t
|
||||
:help "Insert a 'Cc' header"]
|
||||
["Reported" git-commit-reported :active t
|
||||
:help "Insert a 'Reported-by' header"]
|
||||
["Suggested" git-commit-suggested t
|
||||
:help "Insert a 'Suggested-by' header"]
|
||||
["Co-authored-by" git-commit-co-authored t
|
||||
:help "Insert a 'Co-authored-by' header"]
|
||||
"-"
|
||||
["Save" git-commit-save-message t]
|
||||
["Cancel" with-editor-cancel t]
|
||||
["Commit" with-editor-finish t]))
|
||||
|
||||
;;; 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))
|
||||
|
||||
(add-to-list 'with-editor-file-name-history-exclude git-commit-filename-regexp)
|
||||
|
||||
(defun git-commit-setup-font-lock-in-buffer ()
|
||||
(and buffer-file-name
|
||||
(string-match-p git-commit-filename-regexp buffer-file-name)
|
||||
(git-commit-setup-font-lock)))
|
||||
|
||||
(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)
|
||||
(git-commit-setup)))
|
||||
|
||||
(defvar git-commit-mode)
|
||||
|
||||
(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))
|
||||
(let ((inhibit-read-only t))
|
||||
(insert-file-contents it t)
|
||||
t))))
|
||||
|
||||
(when (eq system-type 'windows-nt)
|
||||
(add-hook 'find-file-not-found-functions #'git-commit-file-not-found))
|
||||
|
||||
(defconst git-commit-usage-message "\
|
||||
Type \\[with-editor-finish] to finish, \
|
||||
\\[with-editor-cancel] to cancel, and \
|
||||
\\[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))
|
||||
;; Pretend that git-commit-mode is a major-mode,
|
||||
;; so that directory-local settings can be used.
|
||||
(let ((default-directory
|
||||
(or (and (not (file-exists-p ".dir-locals.el"))
|
||||
;; When $GIT_DIR/.dir-locals.el doesn't exist,
|
||||
;; fallback to $GIT_WORK_TREE/.dir-locals.el,
|
||||
;; because the maintainer can use the latter
|
||||
;; to enforce conventions, while s/he has no
|
||||
;; control over the former.
|
||||
(fboundp 'magit-toplevel) ; silence byte-compiler
|
||||
(magit-toplevel))
|
||||
default-directory)))
|
||||
(let ((buffer-file-name nil) ; trick hack-dir-local-variables
|
||||
(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)
|
||||
(unless with-editor-mode
|
||||
;; Maybe already enabled when using `shell-command' or an Emacs shell.
|
||||
(with-editor-mode 1))
|
||||
(add-hook 'with-editor-finish-query-functions
|
||||
'git-commit-finish-query-functions nil t)
|
||||
(add-hook 'with-editor-pre-finish-hook
|
||||
'git-commit-save-message nil t)
|
||||
(add-hook 'with-editor-pre-cancel-hook
|
||||
'git-commit-save-message nil t)
|
||||
(when (and (fboundp 'magit-rev-parse)
|
||||
(not (memq last-command
|
||||
'(magit-sequencer-continue
|
||||
magit-sequencer-skip
|
||||
magit-am-continue
|
||||
magit-am-skip
|
||||
magit-rebase-continue
|
||||
magit-rebase-skip))))
|
||||
(add-hook 'with-editor-post-finish-hook
|
||||
(apply-partially 'git-commit-run-post-finish-hook
|
||||
(magit-rev-parse "HEAD"))
|
||||
nil t)
|
||||
(when (fboundp 'magit-wip-maybe-add-commit-hook)
|
||||
(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)
|
||||
(when (boundp 'save-place)
|
||||
(setq save-place nil))
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(when (looking-at "\\`\\(\\'\\|\n[^\n]\\)")
|
||||
(open-line 1)))
|
||||
(with-demoted-errors "Error running git-commit-setup-hook: %S"
|
||||
(run-hooks 'git-commit-setup-hook))
|
||||
(set-buffer-modified-p nil))
|
||||
|
||||
(defun git-commit-run-post-finish-hook (previous)
|
||||
(when (and git-commit-post-finish-hook
|
||||
(require 'magit nil t)
|
||||
(fboundp 'magit-rev-parse))
|
||||
(cl-block nil
|
||||
(let ((break (time-add (current-time)
|
||||
(seconds-to-time 1))))
|
||||
(while (equal (magit-rev-parse "HEAD") previous)
|
||||
(if (time-less-p (current-time) break)
|
||||
(sit-for 0.01)
|
||||
(message "No commit created after 1 second. Not running %s."
|
||||
'git-commit-post-finish-hook)
|
||||
(cl-return))))
|
||||
(run-hooks 'git-commit-post-finish-hook))))
|
||||
|
||||
(define-minor-mode git-commit-mode
|
||||
"Auxiliary minor mode used when editing Git commit messages.
|
||||
This mode is only responsible for setting up some key bindings.
|
||||
Don't use it directly, instead enable `global-git-commit-mode'."
|
||||
:lighter "")
|
||||
|
||||
(put 'git-commit-mode 'permanent-local t)
|
||||
|
||||
(defun git-commit-setup-changelog-support ()
|
||||
"Treat ChangeLog entries as unindented paragraphs."
|
||||
(setq-local fill-indent-according-to-mode t)
|
||||
(setq-local paragraph-start (concat paragraph-start "\\|\\*\\|(")))
|
||||
|
||||
(defun git-commit-turn-on-auto-fill ()
|
||||
"Unconditionally turn on Auto Fill mode.
|
||||
If `git-commit-fill-column' is non-nil, and `fill-column'
|
||||
doesn't already have a buffer-local value, then set that
|
||||
to `git-commit-fill-column'."
|
||||
(when (and (numberp git-commit-fill-column)
|
||||
(not (local-variable-p 'fill-column)))
|
||||
(setq fill-column git-commit-fill-column))
|
||||
(setq-local comment-auto-fill-only-comments nil)
|
||||
(turn-on-auto-fill))
|
||||
|
||||
(defun git-commit-turn-on-flyspell ()
|
||||
"Unconditionally turn on Flyspell mode.
|
||||
Also prevent comments from being checked and
|
||||
finally check current non-comment text."
|
||||
(require 'flyspell)
|
||||
(turn-on-flyspell)
|
||||
(setq flyspell-generic-check-word-predicate
|
||||
'git-commit-flyspell-verify)
|
||||
(let ((end)
|
||||
(comment-start-regex (format "^\\(%s\\|$\\)" comment-start)))
|
||||
(save-excursion
|
||||
(goto-char (point-max))
|
||||
(while (and (not (bobp)) (looking-at comment-start-regex))
|
||||
(forward-line -1))
|
||||
(unless (looking-at comment-start-regex)
|
||||
(forward-line))
|
||||
(setq end (point)))
|
||||
(flyspell-region (point-min) end)))
|
||||
|
||||
(defun git-commit-flyspell-verify ()
|
||||
(not (= (char-after (line-beginning-position))
|
||||
(aref comment-start 0))))
|
||||
|
||||
(defun git-commit-finish-query-functions (force)
|
||||
(run-hook-with-args-until-failure
|
||||
'git-commit-finish-query-functions force))
|
||||
|
||||
(defun git-commit-check-style-conventions (force)
|
||||
"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
|
||||
conventions are checked."
|
||||
(or force
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(re-search-forward (git-commit-summary-regexp) nil t)
|
||||
(if (equal (match-string 1) "")
|
||||
t ; Just try; we don't know whether --allow-empty-message was used.
|
||||
(and (or (not (memq 'overlong-summary-line
|
||||
git-commit-style-convention-checks))
|
||||
(equal (match-string 2) "")
|
||||
(y-or-n-p "Summary line is too long. Commit anyway? "))
|
||||
(or (not (memq 'non-empty-second-line
|
||||
git-commit-style-convention-checks))
|
||||
(not (match-string 3))
|
||||
(y-or-n-p "Second line is not empty. Commit anyway? ")))))))
|
||||
|
||||
(defun git-commit-cancel-message ()
|
||||
(message
|
||||
(concat "Commit canceled"
|
||||
(and (memq 'git-commit-save-message with-editor-pre-cancel-hook)
|
||||
". Message saved to `log-edit-comment-ring'"))))
|
||||
|
||||
;;; History
|
||||
|
||||
(defun git-commit-prev-message (arg)
|
||||
"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)))
|
||||
|
||||
(defun git-commit-next-message (arg)
|
||||
"Cycle forward through message history, after saving current message.
|
||||
With a numeric prefix ARG, go forward ARG comments."
|
||||
(interactive "*p")
|
||||
(git-commit-prev-message (- arg)))
|
||||
|
||||
(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)))
|
||||
|
||||
(defun git-commit-buffer-message ()
|
||||
(let ((flush (concat "^" comment-start))
|
||||
(str (buffer-substring-no-properties (point-min) (point-max))))
|
||||
(with-temp-buffer
|
||||
(insert str)
|
||||
(goto-char (point-min))
|
||||
(when (re-search-forward (concat flush " -+ >8 -+$") nil t)
|
||||
(delete-region (point-at-bol) (point-max)))
|
||||
(goto-char (point-min))
|
||||
(flush-lines flush)
|
||||
(goto-char (point-max))
|
||||
(unless (eq (char-before) ?\n)
|
||||
(insert ?\n))
|
||||
(setq str (buffer-string)))
|
||||
(unless (string-match "\\`[ \t\n\r]*\\'" str)
|
||||
(when (string-match "\\`\n\\{2,\\}" str)
|
||||
(setq str (replace-match "\n" t t str)))
|
||||
(when (string-match "\n\\{2,\\}\\'" str)
|
||||
(setq str (replace-match "\n" t t str)))
|
||||
str)))
|
||||
|
||||
;;; Headers
|
||||
|
||||
(defun git-commit-ack (name mail)
|
||||
"Insert a header acknowledging that you have looked at the commit."
|
||||
(interactive (git-commit-self-ident))
|
||||
(git-commit-insert-header "Acked-by" name mail))
|
||||
|
||||
(defun git-commit-modified (name mail)
|
||||
"Insert a header to signal that you have modified the commit."
|
||||
(interactive (git-commit-self-ident))
|
||||
(git-commit-insert-header "Modified-by" name mail))
|
||||
|
||||
(defun git-commit-review (name mail)
|
||||
"Insert a header acknowledging that you have reviewed the commit."
|
||||
(interactive (git-commit-self-ident))
|
||||
(git-commit-insert-header "Reviewed-by" name mail))
|
||||
|
||||
(defun git-commit-signoff (name mail)
|
||||
"Insert a header to sign off the commit."
|
||||
(interactive (git-commit-self-ident))
|
||||
(git-commit-insert-header "Signed-off-by" name mail))
|
||||
|
||||
(defun git-commit-test (name mail)
|
||||
"Insert a header acknowledging that you have tested the commit."
|
||||
(interactive (git-commit-self-ident))
|
||||
(git-commit-insert-header "Tested-by" name mail))
|
||||
|
||||
(defun git-commit-cc (name mail)
|
||||
"Insert a header mentioning someone who might be interested."
|
||||
(interactive (git-commit-read-ident))
|
||||
(git-commit-insert-header "Cc" name mail))
|
||||
|
||||
(defun git-commit-reported (name mail)
|
||||
"Insert a header mentioning the person who reported the issue."
|
||||
(interactive (git-commit-read-ident))
|
||||
(git-commit-insert-header "Reported-by" name mail))
|
||||
|
||||
(defun git-commit-suggested (name mail)
|
||||
"Insert a header mentioning the person who suggested the change."
|
||||
(interactive (git-commit-read-ident))
|
||||
(git-commit-insert-header "Suggested-by" name mail))
|
||||
|
||||
(defun git-commit-co-authored (name mail)
|
||||
"Insert a header mentioning the person who co-authored the commit."
|
||||
(interactive (git-commit-read-ident))
|
||||
(git-commit-insert-header "Co-authored-by" name mail))
|
||||
|
||||
(defun git-commit-self-ident ()
|
||||
(list (or (getenv "GIT_AUTHOR_NAME")
|
||||
(getenv "GIT_COMMITTER_NAME")
|
||||
(ignore-errors (car (process-lines "git" "config" "user.name")))
|
||||
user-full-name
|
||||
(read-string "Name: "))
|
||||
(or (getenv "GIT_AUTHOR_EMAIL")
|
||||
(getenv "GIT_COMMITTER_EMAIL")
|
||||
(getenv "EMAIL")
|
||||
(ignore-errors (car (process-lines "git" "config" "user.email")))
|
||||
(read-string "Email: "))))
|
||||
|
||||
(defun git-commit-read-ident ()
|
||||
(list (read-string "Name: ")
|
||||
(read-string "Email: ")))
|
||||
|
||||
(defun git-commit-insert-header (header name email)
|
||||
(setq header (format "%s: %s <%s>" header name email))
|
||||
(save-excursion
|
||||
(goto-char (point-max))
|
||||
(cond ((re-search-backward "^[-a-zA-Z]+: [^<]+? <[^>]+>" nil t)
|
||||
(end-of-line)
|
||||
(insert ?\n header)
|
||||
(unless (= (char-after) ?\n)
|
||||
(insert ?\n)))
|
||||
(t
|
||||
(while (re-search-backward (concat "^" comment-start) nil t))
|
||||
(unless (looking-back "\n\n" nil)
|
||||
(insert ?\n))
|
||||
(insert header ?\n)))
|
||||
(unless (or (eobp) (= (char-after) ?\n))
|
||||
(insert ?\n))))
|
||||
|
||||
;;; Font-Lock
|
||||
|
||||
(defvar-local git-commit-need-summary-line t
|
||||
"Whether the text should have a heading that is separated from the body.
|
||||
|
||||
For commit messages that is a convention that should not
|
||||
be violated. For notes it is up to the user. If you do
|
||||
not want to insist on an empty second line here, then use
|
||||
something like:
|
||||
|
||||
(add-hook \\='git-commit-setup-hook
|
||||
(lambda ()
|
||||
(when (equal (file-name-nondirectory (buffer-file-name))
|
||||
\"NOTES_EDITMSG\")
|
||||
(setq git-commit-need-summary-line nil))))")
|
||||
|
||||
(defun git-commit-summary-regexp ()
|
||||
(if git-commit-need-summary-line
|
||||
(concat
|
||||
;; Leading empty lines and comments
|
||||
(format "\\`\\(?:^\\(?:\\s-*\\|%s.*\\)\n\\)*" comment-start)
|
||||
;; Summary line
|
||||
(format "\\(.\\{0,%d\\}\\)\\(.*\\)" git-commit-summary-max-length)
|
||||
;; Non-empty non-comment second line
|
||||
(format "\\(?:\n%s\\|\n\\(.+\\)\\)?" comment-start))
|
||||
"\\(EASTER\\) \\(EGG\\)"))
|
||||
|
||||
(defun git-commit-extend-region-summary-line ()
|
||||
"Identify the multiline summary-regexp construct.
|
||||
Added to `font-lock-extend-region-functions'."
|
||||
(save-excursion
|
||||
(save-match-data
|
||||
(goto-char (point-min))
|
||||
(when (looking-at (git-commit-summary-regexp))
|
||||
(let ((summary-beg (match-beginning 0))
|
||||
(summary-end (match-end 0)))
|
||||
(when (or (< summary-beg font-lock-beg summary-end)
|
||||
(< summary-beg font-lock-end summary-end))
|
||||
(setq font-lock-beg (min font-lock-beg summary-beg))
|
||||
(setq font-lock-end (max font-lock-end summary-end))))))))
|
||||
|
||||
(defvar-local git-commit--branch-name-regexp nil)
|
||||
|
||||
(defconst git-commit-comment-headings
|
||||
'("Changes to be committed:"
|
||||
"Untracked files:"
|
||||
"Changed but not updated:"
|
||||
"Changes not staged for commit:"
|
||||
"Unmerged paths:"
|
||||
"Author:"
|
||||
"Date:"))
|
||||
|
||||
(defconst git-commit-font-lock-keywords-1
|
||||
'(;; Pseudo headers
|
||||
(eval . `(,(format "^\\(%s:\\)\\( .*\\)"
|
||||
(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)))
|
||||
;; - Keyword [aka "text in brackets"] (overrides summary)
|
||||
("\\[.+?\\]"
|
||||
(0 'git-commit-keyword t))
|
||||
;; - Non-empty second line (overrides summary and note)
|
||||
(eval . `(,(git-commit-summary-regexp)
|
||||
(2 'git-commit-overlong-summary t t)
|
||||
(3 'git-commit-nonempty-second-line t t)))))
|
||||
|
||||
(defconst git-commit-font-lock-keywords-2
|
||||
`(,@git-commit-font-lock-keywords-1
|
||||
;; Comments
|
||||
(eval . `(,(format "^%s.*" comment-start)
|
||||
(0 'font-lock-comment-face)))
|
||||
(eval . `(,(format "^%s On branch \\(.*\\)" comment-start)
|
||||
(1 'git-commit-comment-branch-local t)))
|
||||
(eval . `(,(format "^%s \\(HEAD\\) detached at" comment-start)
|
||||
(1 'git-commit-comment-detached t)))
|
||||
(eval . `(,(format "^%s %s" comment-start
|
||||
(regexp-opt git-commit-comment-headings t))
|
||||
(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)))))
|
||||
|
||||
(defconst git-commit-font-lock-keywords-3
|
||||
`(,@git-commit-font-lock-keywords-2
|
||||
;; More comments
|
||||
(eval
|
||||
;; Your branch is ahead of 'master' by 3 commits.
|
||||
;; Your branch is behind 'master' by 2 commits, and can be fast-forwarded.
|
||||
. `(,(format
|
||||
"^%s Your branch is \\(?:ahead\\|behind\\) of '%s' by \\([0-9]*\\)"
|
||||
comment-start git-commit--branch-name-regexp)
|
||||
(1 'git-commit-comment-branch-local t)
|
||||
(2 'git-commit-comment-branch-remote t)
|
||||
(3 'bold t)))
|
||||
(eval
|
||||
;; 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'"
|
||||
comment-start git-commit--branch-name-regexp)
|
||||
(1 'git-commit-comment-branch-local t)
|
||||
(2 'git-commit-comment-branch-remote t)))
|
||||
(eval
|
||||
;; and have 1 and 2 different commits each, respectively.
|
||||
. `(,(format
|
||||
"^%s and have \\([0-9]*\\) and \\([0-9]*\\) commits each"
|
||||
comment-start)
|
||||
(1 'bold t)
|
||||
(2 'bold t)))))
|
||||
|
||||
(defvar git-commit-font-lock-keywords git-commit-font-lock-keywords-2
|
||||
"Font-Lock keywords for Git-Commit mode.")
|
||||
|
||||
(defun git-commit-setup-font-lock ()
|
||||
(let ((table (make-syntax-table (syntax-table))))
|
||||
(when comment-start
|
||||
(modify-syntax-entry (string-to-char comment-start) "." table))
|
||||
(modify-syntax-entry ?# "." table)
|
||||
(modify-syntax-entry ?\" "." table)
|
||||
(modify-syntax-entry ?\' "." table)
|
||||
(modify-syntax-entry ?` "." table)
|
||||
(set-syntax-table table))
|
||||
(setq-local comment-start
|
||||
(or (ignore-errors
|
||||
(car (process-lines "git" "config" "core.commentchar")))
|
||||
"#"))
|
||||
(setq-local comment-start-skip (format "^%s+[\s\t]*" comment-start))
|
||||
(setq-local comment-end-skip "\n")
|
||||
(setq-local comment-use-syntax nil)
|
||||
(setq-local git-commit--branch-name-regexp
|
||||
(if (and (featurep 'magit-git)
|
||||
;; When using cygwin git, we may end up in a
|
||||
;; non-existing directory, which would cause
|
||||
;; any git calls to signal an error.
|
||||
(file-accessible-directory-p default-directory))
|
||||
(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\\)\\|\\)"
|
||||
(mapconcat #'identity
|
||||
(magit-list-local-branch-names)
|
||||
"\\|")
|
||||
(mapconcat #'identity
|
||||
(magit-list-remote-branch-names)
|
||||
"\\|")))
|
||||
"\\([^']*\\)"))
|
||||
(setq-local font-lock-multiline t)
|
||||
(add-hook 'font-lock-extend-region-functions
|
||||
#'git-commit-extend-region-summary-line
|
||||
t t)
|
||||
(font-lock-add-keywords nil git-commit-font-lock-keywords))
|
||||
|
||||
(defun git-commit-propertize-diff ()
|
||||
(require 'diff-mode)
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(when (re-search-forward "^diff --git" nil t)
|
||||
(beginning-of-line)
|
||||
(let ((buffer (current-buffer)))
|
||||
(insert
|
||||
(with-temp-buffer
|
||||
(insert
|
||||
(with-current-buffer buffer
|
||||
(prog1 (buffer-substring-no-properties (point) (point-max))
|
||||
(delete-region (point) (point-max)))))
|
||||
(let ((diff-default-read-only nil))
|
||||
(diff-mode))
|
||||
(let (font-lock-verbose font-lock-support-mode)
|
||||
(if (fboundp 'font-lock-ensure)
|
||||
(font-lock-ensure)
|
||||
(with-no-warnings
|
||||
(font-lock-fontify-buffer))))
|
||||
(let (next (pos (point-min)))
|
||||
(while (setq next (next-single-property-change pos 'face))
|
||||
(put-text-property pos next 'font-lock-face
|
||||
(get-text-property pos 'face))
|
||||
(setq pos next))
|
||||
(put-text-property pos (point-max) 'font-lock-face
|
||||
(get-text-property pos 'face)))
|
||||
(buffer-string)))))))
|
||||
|
||||
;;; Elisp Text Mode
|
||||
|
||||
(define-derived-mode git-commit-elisp-text-mode text-mode "ElText"
|
||||
"Major mode for editing commit messages of elisp projects.
|
||||
This is intended for use as `git-commit-major-mode' for projects
|
||||
that expect `symbols' to look like this. I.e. like they look in
|
||||
Elisp doc-strings, including this one. Unlike in doc-strings,
|
||||
\"strings\" also look different than the other text."
|
||||
(setq font-lock-defaults '(git-commit-elisp-text-mode-keywords)))
|
||||
|
||||
(defvar git-commit-elisp-text-mode-keywords
|
||||
`((,(concat "[`‘]\\(" lisp-mode-symbol-regexp "\\)['’]")
|
||||
(1 font-lock-constant-face prepend))
|
||||
("\"[^\"]*\"" (0 font-lock-string-face prepend))))
|
||||
|
||||
;;; _
|
||||
(provide 'git-commit)
|
||||
;;; git-commit.el ends here
|
BIN
elpa/git-commit-20191116.2035/git-commit.elc
Normal file
BIN
elpa/git-commit-20191116.2035/git-commit.elc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,4 +1,4 @@
|
|||
(define-package "magit" "20191128.39" "A Git porcelain inside Emacs."
|
||||
(define-package "magit" "20191128.1802" "A Git porcelain inside Emacs."
|
||||
'((emacs "25.1")
|
||||
(async "20180527")
|
||||
(dash "20180910")
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -325,7 +325,7 @@ The return value has the form ((TYPE . VALUE)...)."
|
|||
(and parent
|
||||
(magit-section-ident parent)))))
|
||||
|
||||
(cl-defgeneric magit-section-ident-value (VALUE)
|
||||
(cl-defgeneric magit-section-ident-value (value)
|
||||
"Return a constant representation of VALUE.
|
||||
VALUE is the value of a `magit-section' object. If that is an
|
||||
object itself, then that is not suitable to be used to identify
|
||||
|
@ -1612,7 +1612,8 @@ should not be abused for other side-effects. To remove FUNCTION
|
|||
again use `remove-hook'."
|
||||
(unless (boundp hook)
|
||||
(error "Cannot add function to undefined hook variable %s" hook))
|
||||
(or (default-boundp hook) (set-default hook nil))
|
||||
(unless (default-boundp hook)
|
||||
(set-default hook nil))
|
||||
(let ((value (if local
|
||||
(if (local-variable-p hook)
|
||||
(symbol-value hook)
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue