update packages
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
(define-package "all-the-icons" "20230909.2053" "A library for inserting Developer icons"
|
||||
(define-package "all-the-icons" "20240623.1800" "A library for inserting Developer icons"
|
||||
'((emacs "24.3"))
|
||||
:commit "be9d5dcda9c892e8ca1535e288620eec075eb0be" :authors
|
||||
:commit "39ef44f810c34e8900978788467cc675870bcd19" :authors
|
||||
'(("Dominic Charlesworth" . "dgc336@gmail.com"))
|
||||
:maintainers
|
||||
'(("Dominic Charlesworth" . "dgc336@gmail.com"))
|
||||
|
||||
@@ -168,6 +168,12 @@
|
||||
("dll" all-the-icons-faicon "cogs" :face all-the-icons-silver)
|
||||
("ds_store" all-the-icons-faicon "cogs" :face all-the-icons-silver)
|
||||
;; Source Codes
|
||||
("ada" all-the-icons-fileicon "ada" :v-adjust 0.0 :face all-the-icons-blue)
|
||||
("adb" all-the-icons-fileicon "ada" :v-adjust 0.0 :face all-the-icons-blue)
|
||||
("adc" all-the-icons-fileicon "ada" :v-adjust 0.0 :face all-the-icons-blue)
|
||||
("ads" all-the-icons-fileicon "ada" :v-adjust 0.0 :face all-the-icons-blue)
|
||||
("gpr" all-the-icons-fileicon "ada" :v-adjust 0.0 :face all-the-icons-green)
|
||||
("cgpr" all-the-icons-fileicon "ada" :v-adjust 0.0 :face all-the-icons-green)
|
||||
("scpt" all-the-icons-fileicon "apple" :face all-the-icons-pink)
|
||||
("aup" all-the-icons-fileicon "audacity" :face all-the-icons-yellow)
|
||||
("elm" all-the-icons-fileicon "elm" :face all-the-icons-blue)
|
||||
@@ -184,7 +190,6 @@
|
||||
("eclass" all-the-icons-fileicon "gentoo" :face all-the-icons-blue)
|
||||
("go" all-the-icons-fileicon "go" :height 1.0 :face all-the-icons-blue)
|
||||
("jl" all-the-icons-fileicon "julia" :face all-the-icons-purple :v-adjust 0.0)
|
||||
("magik" all-the-icons-faicon "magic" :face all-the-icons-blue)
|
||||
("matlab" all-the-icons-fileicon "matlab" :face all-the-icons-orange)
|
||||
("nix" all-the-icons-fileicon "nix" :face all-the-icons-blue)
|
||||
("pl" all-the-icons-alltheicon "perl" :face all-the-icons-lorange)
|
||||
@@ -683,6 +688,8 @@ for performance sake.")
|
||||
(perl-mode all-the-icons-alltheicon "perl" :face all-the-icons-lorange)
|
||||
(cperl-mode all-the-icons-alltheicon "perl" :face all-the-icons-lorange)
|
||||
(php-mode all-the-icons-fileicon "php" :face all-the-icons-lsilver)
|
||||
(php-ts-mode all-the-icons-fileicon "php" :face all-the-icons-lsilver)
|
||||
(phps-mode all-the-icons-fileicon "php" :face all-the-icons-lsilver)
|
||||
(prolog-mode all-the-icons-alltheicon "prolog" :height 1.1 :face all-the-icons-lmaroon)
|
||||
(python-mode all-the-icons-alltheicon "python" :height 1.0 :face all-the-icons-dblue)
|
||||
(python-ts-mode all-the-icons-alltheicon "python" :height 1.0 :face all-the-icons-dblue)
|
||||
@@ -695,6 +702,10 @@ for performance sake.")
|
||||
(scheme-mode all-the-icons-fileicon "scheme" :height 1.2 :face all-the-icons-red)
|
||||
(swift-mode all-the-icons-alltheicon "swift" :height 1.0 :v-adjust -0.1 :face all-the-icons-green)
|
||||
(svelte-mode all-the-icons-fileicon "svelte" :v-adjust 0.0 :face all-the-icons-red)
|
||||
(ada-mode all-the-icons-fileicon "ada" :v-adjust 0.0 :face all-the-icons-blue)
|
||||
(ada-ts-mode all-the-icons-fileicon "ada" :v-adjust 0.0 :face all-the-icons-blue)
|
||||
(gpr-mode all-the-icons-fileicon "ada" :v-adjust 0.0 :face all-the-icons-green)
|
||||
(gpr-ts-mode all-the-icons-fileicon "ada" :v-adjust 0.0 :face all-the-icons-green)
|
||||
(c-mode all-the-icons-alltheicon "c-line" :face all-the-icons-blue)
|
||||
(c-ts-mode all-the-icons-alltheicon "c-line" :face all-the-icons-blue)
|
||||
(c++-mode all-the-icons-alltheicon "cplusplus-line" :v-adjust -0.2 :face all-the-icons-blue)
|
||||
@@ -773,8 +784,6 @@ for performance sake.")
|
||||
(emms-tag-editor-mode all-the-icons-faicon "music" :face all-the-icons-silver)
|
||||
(emms-playlist-mode all-the-icons-faicon "music" :face all-the-icons-silver)
|
||||
(lilypond-mode all-the-icons-faicon "music" :face all-the-icons-green)
|
||||
(magik-session-mode all-the-icons-alltheicon "terminal" :face all-the-icons-blue)
|
||||
(magik-cb-mode all-the-icons-faicon "book" :face all-the-icons-blue)
|
||||
(meson-mode all-the-icons-fileicon "meson" :face all-the-icons-purple)
|
||||
(man-common all-the-icons-fileicon "man-page" :face all-the-icons-blue)
|
||||
(ess-r-mode all-the-icons-fileicon "R" :face all-the-icons-lblue)))
|
||||
|
||||
@@ -312,7 +312,7 @@
|
||||
( "objective-j" . "\xe99e" )
|
||||
( "ocaml" . "\xe91a" )
|
||||
( "octave" . "\xea33" )
|
||||
( "odin" . "\eb36" )
|
||||
( "odin" . "\xeb36" )
|
||||
( "onenote" . "\xe9eb" )
|
||||
( "ooc" . "\xe9cb" )
|
||||
( "opa" . "\x2601" )
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
(define-package "anaconda-mode" "20230821.2131" "Code navigation, documentation lookup and completion for Python"
|
||||
(define-package "anaconda-mode" "20231123.1806" "Code navigation, documentation lookup and completion for Python"
|
||||
'((emacs "25.1")
|
||||
(pythonic "0.1.0")
|
||||
(dash "2.6.0")
|
||||
(s "1.9")
|
||||
(f "0.16.2"))
|
||||
:commit "9dbd65b034cef519c01f63703399ae59651f85ca" :authors
|
||||
:commit "92a6295622df7fae563d6b599e2dc8640e940ddf" :authors
|
||||
'(("Artem Malyshev" . "proofit404@gmail.com"))
|
||||
:maintainers
|
||||
'(("Artem Malyshev" . "proofit404@gmail.com"))
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
;; Author: Artem Malyshev <proofit404@gmail.com>
|
||||
;; URL: https://github.com/proofit404/anaconda-mode
|
||||
;; Version: 0.1.15
|
||||
;; Version: 0.1.16
|
||||
;; Package-Requires: ((emacs "25.1") (pythonic "0.1.0") (dash "2.6.0") (s "1.9") (f "0.16.2"))
|
||||
;; Keywords: convenience anaconda
|
||||
|
||||
@@ -94,7 +94,7 @@
|
||||
(declare-function posframe-show "posframe")
|
||||
|
||||
;;; Server.
|
||||
(defvar anaconda-mode-server-version "0.1.15"
|
||||
(defvar anaconda-mode-server-version "0.1.16"
|
||||
"Server version needed to run `anaconda-mode'.")
|
||||
|
||||
(defvar anaconda-mode-process-name "anaconda-mode"
|
||||
|
||||
@@ -25,7 +25,7 @@ if IS_PY2:
|
||||
jedi_dep = ('jedi', '0.17.2')
|
||||
server_directory += '-py2'
|
||||
else:
|
||||
jedi_dep = ('jedi', '0.18.1')
|
||||
jedi_dep = ('jedi', '0.19.1')
|
||||
server_directory += '-py3'
|
||||
service_factory_dep = ('service_factory', '0.1.6')
|
||||
|
||||
|
||||
@@ -22,17 +22,22 @@
|
||||
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
;;; 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.
|
||||
;; your running emacs. Single files can be compiled with
|
||||
;; `async-byte-compile-file'. The benefit is your files will be
|
||||
;; compiled in a clean environment without the old *.el files
|
||||
;; loaded. A mode `async-bytecomp-package-mode' is provided to
|
||||
;; automatically compile packages asynchronously when installing or
|
||||
;; upgrading, 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'.
|
||||
;; NB: This package is advising the function `package--compile' when
|
||||
;; `async-bytecomp-package-mode' is enabled. This mode is useful
|
||||
;; only when using a synchronous package manager (e.g. M-x
|
||||
;; list-package), users of M-x helm-packages don't need this anymore.
|
||||
|
||||
;;; Code:
|
||||
|
||||
@@ -60,6 +65,33 @@ all packages are always compiled asynchronously."
|
||||
(defvar async-bytecomp-load-variable-regexp "\\`load-path\\'"
|
||||
"The variable used by `async-inject-variables' when (re)compiling async.")
|
||||
|
||||
(defun async-bytecomp--file-to-comp-buffer (file-or-dir &optional quiet type)
|
||||
(let ((bn (file-name-nondirectory file-or-dir))
|
||||
(action-name (pcase type
|
||||
('file "File")
|
||||
('directory "Directory"))))
|
||||
(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 bn)
|
||||
(message "%s `%s' compiled asynchronously with warnings"
|
||||
action-name bn)))))
|
||||
(unless quiet
|
||||
(message "%s `%s' compiled asynchronously with success" action-name bn)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun async-byte-recompile-directory (directory &optional quiet)
|
||||
"Compile all *.el files in DIRECTORY asynchronously.
|
||||
@@ -73,26 +105,7 @@ All *.elc files are systematically deleted before proceeding."
|
||||
(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-bytecomp--file-to-comp-buffer directory quiet 'directory))))
|
||||
(async-start
|
||||
`(lambda ()
|
||||
(require 'bytecomp)
|
||||
@@ -140,13 +153,10 @@ All *.elc files are systematically deleted before proceeding."
|
||||
(memq cur-package (async-bytecomp--get-package-deps
|
||||
async-bytecomp-allowed-packages)))
|
||||
(progn
|
||||
;; FIXME: Why do we use (eq cur-package 'async) once
|
||||
;; and (string= cur-package "async") afterwards?
|
||||
(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")
|
||||
(fmakunbound 'async-byte-recompile-directory)
|
||||
;; Add to `load-path' the latest version of async and
|
||||
;; reload it when reinstalling async.
|
||||
(cl-pushnew pkg-dir load-path)
|
||||
(load "async-bytecomp"))
|
||||
;; `async-byte-recompile-directory' will add directory
|
||||
@@ -158,7 +168,10 @@ All *.elc files are systematically deleted before proceeding."
|
||||
(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'."
|
||||
`async-bytecomp-allowed-packages'.
|
||||
NOTE: Use this mode only if you install/upgrade etc... your packages
|
||||
synchronously, if you use a package manager like helm-package.el which
|
||||
by default is async you don't need this."
|
||||
:group 'async
|
||||
:global t
|
||||
(if async-bytecomp-package-mode
|
||||
@@ -173,28 +186,13 @@ 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-bytecomp--file-to-comp-buffer file nil 'file))))
|
||||
(async-start
|
||||
`(lambda ()
|
||||
(require 'bytecomp)
|
||||
,(async-inject-variables async-bytecomp-load-variable-regexp)
|
||||
(let ((default-directory ,(file-name-directory file)))
|
||||
(let ((default-directory ,(file-name-directory file))
|
||||
error-data)
|
||||
(add-to-list 'load-path default-directory)
|
||||
(byte-compile-file ,file)
|
||||
(when (get-buffer byte-compile-log-buffer)
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
;;; async-package.el --- Fetch packages asynchronously -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2014-2022 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Thierry Volpiatto <thievol@posteo.net>
|
||||
|
||||
;; Keywords: dired async byte-compile package
|
||||
;; 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 3 of the License, 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Provide the function `async-package-do-action' to
|
||||
;; (re)install/upgrade packages asynchronously.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(eval-when-compile (require 'cl-lib))
|
||||
(require 'async-bytecomp)
|
||||
(require 'dired-async)
|
||||
(require 'package)
|
||||
|
||||
(define-minor-mode async-package--modeline-mode
|
||||
"Notify mode-line that an async process run."
|
||||
:group 'async
|
||||
:global t
|
||||
:lighter (:eval (propertize (format " [%s async job Installing package(s)]"
|
||||
(length (dired-async-processes
|
||||
'async-pkg-install)))
|
||||
'face 'async-package-message))
|
||||
(unless async-package--modeline-mode
|
||||
(let ((visible-bell t)) (ding))))
|
||||
|
||||
(defvar async-pkg-install-after-hook nil
|
||||
"Hook that run after package installation.
|
||||
The hook runs in the call-back once installation is done in child emacs.")
|
||||
|
||||
(defface async-package-message
|
||||
'((t (:foreground "yellow")))
|
||||
"Face used for mode-line message."
|
||||
:group 'async)
|
||||
|
||||
(defun async-package-do-action (action packages error-file)
|
||||
"Execute ACTION asynchronously on PACKAGES.
|
||||
Argument ACTION can be one of \\='install, \\='upgrade, \\='reinstall.
|
||||
Argument PACKAGES is a list of packages (symbols).
|
||||
Argument ERROR-FILE is the file where errors are logged, if some."
|
||||
(require 'async-bytecomp)
|
||||
(let ((fn (pcase action
|
||||
('install 'package-install)
|
||||
('upgrade 'package-upgrade)
|
||||
('reinstall 'package-reinstall)))
|
||||
(action-string (pcase action
|
||||
('install "Installing")
|
||||
('upgrade "Upgrading")
|
||||
('reinstall "Reinstalling"))))
|
||||
(message "%s %s package(s)..." action-string (length packages))
|
||||
(process-put
|
||||
(async-start
|
||||
`(lambda ()
|
||||
(require 'bytecomp)
|
||||
(setq package-archives ',package-archives
|
||||
package-pinned-packages ',package-pinned-packages
|
||||
package-archive-contents ',package-archive-contents
|
||||
package-user-dir ,package-user-dir
|
||||
package-alist ',package-alist
|
||||
load-path ',load-path)
|
||||
;; Ensure `async-bytecomp-package-mode' doesn't kick in
|
||||
;; (issue #194) as some packages may enable it
|
||||
;; inconditionally. We don't need to compile async as we are
|
||||
;; already async and in a clean environment.
|
||||
(require 'async-bytecomp)
|
||||
(setq async-bytecomp-allowed-packages nil)
|
||||
(prog1
|
||||
(condition-case err
|
||||
(mapc ',fn ',packages)
|
||||
(error
|
||||
(with-temp-file ,error-file
|
||||
(insert
|
||||
(format
|
||||
"%S:\n Please refresh package list before %s"
|
||||
err ,action-string)))))
|
||||
(let (error-data)
|
||||
(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)))))))
|
||||
(lambda (result)
|
||||
(if (file-exists-p error-file)
|
||||
(let ((buf (find-file-noselect error-file)))
|
||||
(pop-to-buffer
|
||||
buf '(nil . ((window-height . fit-window-to-buffer))))
|
||||
(special-mode)
|
||||
(delete-file error-file)
|
||||
(async-package--modeline-mode -1))
|
||||
(when result
|
||||
(let ((pkgs (if (listp result) result (list result))))
|
||||
(when (eq action 'install)
|
||||
(customize-save-variable
|
||||
'package-selected-packages
|
||||
(delete-dups (append pkgs package-selected-packages))))
|
||||
(package-load-all-descriptors) ; refresh package-alist.
|
||||
(mapc #'package-activate pkgs) ; load packages.
|
||||
(async-package--modeline-mode -1)
|
||||
(message "%s %s packages done" action-string (length packages))
|
||||
(run-with-timer
|
||||
0.1 nil
|
||||
(lambda (lst str)
|
||||
(dired-async-mode-line-message
|
||||
"%s %d package(s) done"
|
||||
'async-package-message
|
||||
str (length lst)))
|
||||
packages action-string)
|
||||
(when (file-exists-p async-byte-compile-log-file)
|
||||
(let ((buf (get-buffer-create byte-compile-log-buffer)))
|
||||
(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)))))))
|
||||
(run-hooks 'async-pkg-install-after-hook)))
|
||||
'async-pkg-install t)
|
||||
(async-package--modeline-mode 1)))
|
||||
|
||||
(provide 'async-package)
|
||||
|
||||
;;; async-package.el ends here
|
||||
@@ -1,6 +1,6 @@
|
||||
(define-package "async" "20230528.622" "Asynchronous processing in Emacs"
|
||||
(define-package "async" "20241126.810" "Asynchronous processing in Emacs"
|
||||
'((emacs "24.4"))
|
||||
:commit "3ae74c0a4ba223ba373e0cb636c385e08d8838be" :authors
|
||||
:commit "b99658e831bc7e7d20ed4bb0a85bdb5c7dd74142" :authors
|
||||
'(("John Wiegley" . "jwiegley@gmail.com"))
|
||||
:maintainers
|
||||
'(("Thierry Volpiatto" . "thievol@posteo.net"))
|
||||
|
||||
+58
-14
@@ -6,7 +6,7 @@
|
||||
;; Maintainer: Thierry Volpiatto <thievol@posteo.net>
|
||||
|
||||
;; Created: 18 Jun 2012
|
||||
;; Version: 1.9.7
|
||||
;; Version: 1.9.9
|
||||
;; Package-Requires: ((emacs "24.4"))
|
||||
|
||||
;; Keywords: async
|
||||
@@ -34,6 +34,8 @@
|
||||
|
||||
(eval-when-compile (require 'cl-lib))
|
||||
|
||||
(defvar tramp-password-prompt-regexp)
|
||||
|
||||
(defgroup async nil
|
||||
"Simple asynchronous processing in Emacs"
|
||||
:group 'lisp)
|
||||
@@ -42,6 +44,19 @@
|
||||
"Default function to remove text properties in variables."
|
||||
:type 'function)
|
||||
|
||||
(defcustom async-prompt-for-password t
|
||||
"Prompt for password in parent Emacs if needed when non nil.
|
||||
When this is nil child Emacs will hang forever when a user interaction
|
||||
for password is required unless a password is stored in a \".authinfo\" file."
|
||||
:type 'boolean)
|
||||
|
||||
(defvar async-process-noquery-on-exit nil
|
||||
"Used as the :noquery argument to `make-process'.
|
||||
|
||||
Intended to be let-bound around a call to `async-start' or
|
||||
`async-start-process'. If non-nil, the child Emacs process will
|
||||
be silently killed if the user exits the parent Emacs.")
|
||||
|
||||
(defvar async-debug nil)
|
||||
(defvar async-send-over-pipe t)
|
||||
(defvar async-in-child-emacs nil)
|
||||
@@ -102,14 +117,17 @@ is returned unmodified."
|
||||
collect elm))
|
||||
(t object)))
|
||||
|
||||
(defvar async-inject-variables-exclude-regexps '("-syntax-table\\'")
|
||||
"A list of regexps that `async-inject-variables' should ignore.")
|
||||
|
||||
(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\".
|
||||
matching EXCLUDE-REGEXP (if present) and variables matching one of
|
||||
`async-inject-variables-exclude-regexps'.
|
||||
When NOPROPS is non nil it tries to strip out text properties of each
|
||||
variable's value with `async-variables-noprops-function'.
|
||||
|
||||
@@ -128,14 +146,16 @@ It is intended to be used as follows:
|
||||
,@(let (bindings)
|
||||
(mapatoms
|
||||
(lambda (sym)
|
||||
(let* ((sname (and (boundp sym) (symbol-name sym)))
|
||||
(value (and sname (symbol-value sym))))
|
||||
(let ((sname (and (boundp sym) (symbol-name sym)))
|
||||
value)
|
||||
(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)))
|
||||
(cl-loop for re in async-inject-variables-exclude-regexps
|
||||
never (string-match-p re sname)))
|
||||
(setq value (symbol-value sym))
|
||||
(unless (or (stringp value)
|
||||
(memq value '(nil t))
|
||||
(numberp value)
|
||||
@@ -207,7 +227,7 @@ It is intended to be used as follows:
|
||||
(process-name proc) (process-exit-status proc))))
|
||||
(set (make-local-variable 'async-callback-value-set) t))))))
|
||||
|
||||
(defun async-read-from-client (proc string)
|
||||
(defun async-read-from-client (proc string &optional prompt-for-pwd)
|
||||
"Process text from client process.
|
||||
|
||||
The string chunks usually arrive in maximum of 4096 bytes, so a
|
||||
@@ -217,8 +237,18 @@ function.
|
||||
We use a marker `async-read-marker' to track the position of the
|
||||
lasts complete line. Every time we get new input, we try to look
|
||||
for newline, and if found, process the entire line and bump the
|
||||
marker position to the end of this next line."
|
||||
marker position to the end of this next line.
|
||||
|
||||
Argument PROMPT-FOR-PWD allow binding lexically the value of
|
||||
`async-prompt-for-password', if unspecified its global value
|
||||
is used."
|
||||
(with-current-buffer (process-buffer proc)
|
||||
(when (and prompt-for-pwd
|
||||
(boundp 'tramp-password-prompt-regexp)
|
||||
tramp-password-prompt-regexp
|
||||
(string-match tramp-password-prompt-regexp string))
|
||||
(process-send-string
|
||||
proc (concat (read-passwd (match-string 0 string)) "\n")))
|
||||
(goto-char (point-max))
|
||||
(save-excursion
|
||||
(insert string))
|
||||
@@ -350,7 +380,7 @@ its FINISH-FUNC is nil."
|
||||
(plist-get value :async-message)))
|
||||
|
||||
(defun async-send (process-or-key &rest args)
|
||||
"Send the given message to the asychronous child or parent Emacs.
|
||||
"Send the given message to the asynchronous child or parent Emacs.
|
||||
|
||||
To send messages from the parent to a child, PROCESS-OR-KEY is
|
||||
the child process object. ARGS is a plist. Example:
|
||||
@@ -402,12 +432,14 @@ finished. Set DEFAULT-DIRECTORY to change PROGRAM's current
|
||||
working directory."
|
||||
(let* ((buf (generate-new-buffer (concat "*" name "*")))
|
||||
(buf-err (generate-new-buffer (concat "*" name ":err*")))
|
||||
(prt-for-pwd async-prompt-for-password)
|
||||
(proc (let ((process-connection-type nil))
|
||||
(make-process
|
||||
:name name
|
||||
:buffer buf
|
||||
:stderr buf-err
|
||||
:command (cons program program-args)))))
|
||||
:command (cons program program-args)
|
||||
:noquery async-process-noquery-on-exit))))
|
||||
(set-process-sentinel
|
||||
(get-buffer-process buf-err)
|
||||
(lambda (proc _change)
|
||||
@@ -418,9 +450,12 @@ working directory."
|
||||
(set (make-local-variable 'async-read-marker)
|
||||
(set-marker (make-marker) (point-min) buf))
|
||||
(set-marker-insertion-type async-read-marker nil)
|
||||
|
||||
(set-process-sentinel proc #'async-when-done)
|
||||
(set-process-filter proc #'async-read-from-client)
|
||||
;; Pass the value of `async-prompt-for-password' to the process
|
||||
;; filter fn through the lexical local var prt-for-pwd (Issue#182).
|
||||
(set-process-filter proc (lambda (proc string)
|
||||
(async-read-from-client
|
||||
proc string prt-for-pwd)))
|
||||
(unless (string= name "emacs")
|
||||
(set (make-local-variable 'async-callback-for-process) t))
|
||||
proc)))
|
||||
@@ -431,11 +466,20 @@ 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.")
|
||||
|
||||
(defvar async-library nil
|
||||
"Cache async library path.
|
||||
It is useful only when you run multiple async processes in a loop, to
|
||||
avoid calling many times `locate-library' which is costly.
|
||||
This variable should be let bound around an `async-start' call and not
|
||||
used globally. Should be found with `locate-library'.")
|
||||
|
||||
(defun async--emacs-program-args (&optional sexp)
|
||||
"Return a list of arguments for invoking the child Emacs."
|
||||
;; Using `locate-library' ensure we use the right file
|
||||
;; when the .elc have been deleted.
|
||||
(let ((args (list async-quiet-switch "-l" (locate-library "async"))))
|
||||
;; when the .elc have been deleted, its result can be cached in
|
||||
;; `async-library' see Issue#193.
|
||||
(let ((args (list async-quiet-switch "-l" (or async-library
|
||||
(locate-library "async")))))
|
||||
(when async-child-init
|
||||
(setq args (append args (list "-l" async-child-init))))
|
||||
(append args (list "-batch" "-f" "async-batch-invoke"
|
||||
|
||||
+35
-11
@@ -81,6 +81,10 @@ or rename for `dired-async-skip-fast'."
|
||||
:risky t
|
||||
:type 'integer)
|
||||
|
||||
(defcustom dired-async-large-file-warning-threshold large-file-warning-threshold
|
||||
"Same as `large-file-warning-threshold' but for dired-async."
|
||||
:type 'integer)
|
||||
|
||||
(defface dired-async-message
|
||||
'((t (:foreground "yellow")))
|
||||
"Face used for mode-line message.")
|
||||
@@ -115,9 +119,9 @@ or rename for `dired-async-skip-fast'."
|
||||
(sit-for 3)
|
||||
(force-mode-line-update)))
|
||||
|
||||
(defun dired-async-processes ()
|
||||
(defun dired-async-processes (&optional propname)
|
||||
(cl-loop for p in (process-list)
|
||||
when (process-get p 'dired-async-process)
|
||||
when (process-get p (or propname 'dired-async-process))
|
||||
collect p))
|
||||
|
||||
(defun dired-async-kill-process ()
|
||||
@@ -242,6 +246,14 @@ cases if `dired-async-skip-fast' is non-nil."
|
||||
(funcall old-func file-creator operation
|
||||
(nreverse quick-list) name-constructor marker-char))))
|
||||
|
||||
(defun dired-async--abort-if-file-too-large (size op-type filename)
|
||||
"Warn when FILENAME larger than `dired-async-large-file-warning-threshold'.
|
||||
Same as `abort-if-file-too-large' but without user-error."
|
||||
(when (and dired-async-large-file-warning-threshold size
|
||||
(> size dired-async-large-file-warning-threshold))
|
||||
(files--ask-user-about-large-file
|
||||
size op-type filename nil)))
|
||||
|
||||
(defvar overwrite-query)
|
||||
(defun dired-async-create-files (file-creator operation fn-list name-constructor
|
||||
&optional _marker-char)
|
||||
@@ -299,14 +311,22 @@ ESC or `q' to not overwrite any of the remaining files,
|
||||
(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)))))
|
||||
;; Skip file if it is too large.
|
||||
(if (and (member operation '("Copy" "Rename"))
|
||||
(eq (dired-async--abort-if-file-too-large
|
||||
(file-attribute-size
|
||||
(file-attributes (file-truename from)))
|
||||
(downcase operation) from)
|
||||
'abort))
|
||||
(push from skipped)
|
||||
(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)
|
||||
@@ -361,10 +381,14 @@ ESC or `q' to not overwrite any of the remaining files,
|
||||
(async-start `(lambda ()
|
||||
(require 'cl-lib) (require 'dired-aux) (require 'dired-x)
|
||||
,(async-inject-variables dired-async-env-variables-regexp)
|
||||
(advice-add #'files--ask-user-about-large-file
|
||||
:override (lambda (&rest args) nil))
|
||||
(let ((dired-recursive-copies (quote always))
|
||||
(dired-copy-preserve-time
|
||||
,dired-copy-preserve-time)
|
||||
(dired-create-destination-dirs ',create-dir))
|
||||
(dired-create-destination-dirs ',create-dir)
|
||||
(dired-vc-rename-file ,dired-vc-rename-file)
|
||||
auth-source-save-behavior)
|
||||
(setq overwrite-backup-query nil)
|
||||
;; Inline `backup-file' as long as it is not
|
||||
;; available in emacs.
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
(define-package "avy" "20230420.404" "Jump to arbitrary positions in visible text and select text quickly."
|
||||
(define-package "avy" "20241101.1357" "Jump to arbitrary positions in visible text and select text quickly."
|
||||
'((emacs "24.1")
|
||||
(cl-lib "0.5"))
|
||||
:commit "be612110cb116a38b8603df367942e2bb3d9bdbe" :authors
|
||||
:commit "933d1f36cca0f71e4acb5fac707e9ae26c536264" :authors
|
||||
'(("Oleh Krehel" . "ohwoeowho@gmail.com"))
|
||||
:maintainers
|
||||
'(("Oleh Krehel" . "ohwoeowho@gmail.com"))
|
||||
|
||||
+24
-24
@@ -26,22 +26,22 @@
|
||||
;;; Commentary:
|
||||
;;
|
||||
;; With Avy, you can move point to any position in Emacs – even in a
|
||||
;; different window – using very few keystrokes. For this, you look at
|
||||
;; different window – using very few keystrokes. For this, you look at
|
||||
;; the position where you want point to be, invoke Avy, and then enter
|
||||
;; the sequence of characters displayed at that position.
|
||||
;;
|
||||
;; If the position you want to jump to can be determined after only
|
||||
;; issuing a single keystroke, point is moved to the desired position
|
||||
;; immediately after that keystroke. In case this isn't possible, the
|
||||
;; immediately after that keystroke. In case this isn't possible, the
|
||||
;; sequence of keystrokes you need to enter is comprised of more than
|
||||
;; one character. Avy uses a decision tree where each candidate position
|
||||
;; one character. Avy uses a decision tree where each candidate position
|
||||
;; is a leaf and each edge is described by a character which is distinct
|
||||
;; per level of the tree. By entering those characters, you navigate the
|
||||
;; per level of the tree. By entering those characters, you navigate the
|
||||
;; tree, quickly arriving at the desired candidate position, such that
|
||||
;; Avy can move point to it.
|
||||
;;
|
||||
;; Note that this only makes sense for positions you are able to see
|
||||
;; when invoking Avy. These kinds of positions are supported:
|
||||
;; when invoking Avy. These kinds of positions are supported:
|
||||
;;
|
||||
;; * character positions
|
||||
;; * word or subword start positions
|
||||
@@ -99,7 +99,7 @@ keys different than the following: a, e, i, o, u, y"
|
||||
(function :tag "Other command")))
|
||||
|
||||
(defcustom avy-keys-alist nil
|
||||
"Alist of avy-jump commands to `avy-keys' overriding the default `avy-keys'."
|
||||
"Alist of `avy-jump' commands to `avy-keys' overriding the default `avy-keys'."
|
||||
:type `(alist
|
||||
:key-type ,avy--key-type
|
||||
:value-type (repeat :tag "Keys" character)))
|
||||
@@ -156,27 +156,27 @@ Use `avy-styles-alist' to customize this per-command."
|
||||
(const :tag "Words" words)))
|
||||
|
||||
(defcustom avy-styles-alist nil
|
||||
"Alist of avy-jump commands to the style for each command.
|
||||
"Alist of `avy-jump' commands to the style for each command.
|
||||
If the commands isn't on the list, `avy-style' is used."
|
||||
:type '(alist
|
||||
:key-type (choice :tag "Command"
|
||||
(const avy-goto-char)
|
||||
(const avy-goto-char-2)
|
||||
(const avy-isearch)
|
||||
(const avy-goto-line)
|
||||
(const avy-goto-subword-0)
|
||||
(const avy-goto-subword-1)
|
||||
(const avy-goto-word-0)
|
||||
(const avy-goto-word-1)
|
||||
(const avy-copy-line)
|
||||
(const avy-copy-region)
|
||||
(const avy-move-line)
|
||||
(const avy-move-region)
|
||||
(const avy-kill-whole-line)
|
||||
(const avy-kill-region)
|
||||
(const avy-kill-ring-save-whole-line)
|
||||
(const avy-kill-ring-save-region)
|
||||
(function :tag "Other command"))
|
||||
(const avy-goto-char)
|
||||
(const avy-goto-char-2)
|
||||
(const avy-isearch)
|
||||
(const avy-goto-line)
|
||||
(const avy-goto-subword-0)
|
||||
(const avy-goto-subword-1)
|
||||
(const avy-goto-word-0)
|
||||
(const avy-goto-word-1)
|
||||
(const avy-copy-line)
|
||||
(const avy-copy-region)
|
||||
(const avy-move-line)
|
||||
(const avy-move-region)
|
||||
(const avy-kill-whole-line)
|
||||
(const avy-kill-region)
|
||||
(const avy-kill-ring-save-whole-line)
|
||||
(const avy-kill-ring-save-region)
|
||||
(function :tag "Other command"))
|
||||
:value-type (choice
|
||||
(const :tag "Pre" pre)
|
||||
(const :tag "At" at)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
(define-package "biblio" "20230202.1721" "Browse and import bibliographic references from CrossRef, arXiv, DBLP, HAL, Dissemin, and doi.org"
|
||||
(define-package "biblio" "20250102.1345" "Browse and import bibliographic references and BibTeX records from CrossRef, arXiv, DBLP, HAL, IEEE Xplore, Dissemin, and doi.org"
|
||||
'((emacs "24.3")
|
||||
(biblio-core "0.2"))
|
||||
:commit "ee52f6cda82ea6fbc3b400e7b12132595cc0374c" :authors
|
||||
(biblio-core "0.3"))
|
||||
:commit "b700f0f2929829b2ca971511c5ebe61c67027e9f" :authors
|
||||
'(("Clément Pit-Claudel" . "clement.pitclaudel@live.com"))
|
||||
:maintainers
|
||||
'(("Clément Pit-Claudel" . "clement.pitclaudel@live.com"))
|
||||
:maintainer
|
||||
'("Clément Pit-Claudel" . "clement.pitclaudel@live.com")
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
(define-package "bibtex-completion" "20230918.953" "A BibTeX backend for completion frameworks"
|
||||
'((parsebib "1.0")
|
||||
(define-package "bibtex-completion" "20241116.726" "A BibTeX backend for completion frameworks"
|
||||
'((parsebib "6.0")
|
||||
(s "1.9.0")
|
||||
(dash "2.6.0")
|
||||
(f "0.16.2")
|
||||
(cl-lib "0.5")
|
||||
(biblio "0.2")
|
||||
(emacs "26.1"))
|
||||
:commit "95551744de8210867e9d34feaf47ae639ea04114" :authors
|
||||
:commit "6064e8625b2958f34d6d40312903a85c173b5261" :authors
|
||||
'(("Titus von der Malsburg" . "malsburg@posteo.de")
|
||||
("Justin Burkett" . "justin@burkett.cc"))
|
||||
:maintainers
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
;; Maintainer: Titus von der Malsburg <malsburg@posteo.de>
|
||||
;; URL: https://github.com/tmalsburg/helm-bibtex
|
||||
;; Version: 1.0.0
|
||||
;; Package-Requires: ((parsebib "1.0") (s "1.9.0") (dash "2.6.0") (f "0.16.2") (cl-lib "0.5") (biblio "0.2") (emacs "26.1"))
|
||||
;; Package-Requires: ((parsebib "6.0") (s "1.9.0") (dash "2.6.0") (f "0.16.2") (cl-lib "0.5") (biblio "0.2") (emacs "26.1"))
|
||||
|
||||
;; 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
|
||||
@@ -77,6 +77,20 @@ composed of the BibTeX-key plus a \".pdf\" suffix."
|
||||
:group 'bibtex-completion
|
||||
:type '(choice directory (repeat directory)))
|
||||
|
||||
;; From https://github.com/mwlodarczak/helm-bibtex/commit/4a421cae9b7d4cdb4a0933080633564b1774addb
|
||||
(defcustom bibtex-completion-watch-bibliography t
|
||||
"If non-nil (the default) the bibliography is reloaded
|
||||
proactively every time any of the BibTeX files changes.
|
||||
Changing the value of this variable after you load helm-bibtex
|
||||
has no effect: if you load helm-bibtex with this variable
|
||||
set to t and then decide you do not want to proactively reload the
|
||||
bibliography, you have to restart Emacs with the new setting
|
||||
(and likewise for loading helm-bibtex with the variable set to nil
|
||||
and later deciding you want to proactively reload the bibliography)."
|
||||
:group 'bibtex-completion
|
||||
:type 'boolean)
|
||||
|
||||
|
||||
(defcustom bibtex-completion-pdf-open-function 'find-file
|
||||
"The function used for opening PDF files.
|
||||
This can be an arbitrary function that takes one argument: the
|
||||
@@ -114,6 +128,7 @@ This should be a single character."
|
||||
(defcustom bibtex-completion-format-citation-functions
|
||||
'((org-mode . bibtex-completion-format-citation-ebib)
|
||||
(latex-mode . bibtex-completion-format-citation-cite)
|
||||
(LaTeX-mode . bibtex-completion-format-citation-cite)
|
||||
(markdown-mode . bibtex-completion-format-citation-pandoc-citeproc)
|
||||
(python-mode . bibtex-completion-format-citation-sphinxcontrib-bibtex)
|
||||
(rst-mode . bibtex-completion-format-citation-sphinxcontrib-bibtex)
|
||||
@@ -280,6 +295,7 @@ browser in `helm-browse-url-default-browser-alist'"
|
||||
"Autocite" "autocite*" "Autocite*" "citeauthor" "Citeauthor"
|
||||
"citeauthor*" "Citeauthor*" "citetitle" "citetitle*" "citeyear"
|
||||
"citeyear*" "citedate" "citedate*" "citeurl" "nocite" "fullcite"
|
||||
"citet" "citep" "citet*" "citep*"
|
||||
"footfullcite" "notecite" "Notecite" "pnotecite" "Pnotecite"
|
||||
"fnotecite")
|
||||
"The list of LaTeX cite commands.
|
||||
@@ -414,15 +430,16 @@ Also sets `bibtex-completion-display-formats-internal'."
|
||||
;; watches for automatic reloading of the bibliography when a file
|
||||
;; is changed:
|
||||
(mapc (lambda (file)
|
||||
(if (f-file? file)
|
||||
(let ((watch-descriptor
|
||||
(file-notify-add-watch file
|
||||
'(change)
|
||||
(lambda (event) (bibtex-completion-candidates)))))
|
||||
(setq bibtex-completion-file-watch-descriptors
|
||||
(cons watch-descriptor bibtex-completion-file-watch-descriptors)))
|
||||
(if (f-file? file)
|
||||
(if bibtex-completion-watch-bibliography
|
||||
(let ((watch-descriptor
|
||||
(file-notify-add-watch file
|
||||
'(change)
|
||||
(lambda (event) (bibtex-completion-candidates)))))
|
||||
(setq bibtex-completion-file-watch-descriptors
|
||||
(cons watch-descriptor bibtex-completion-file-watch-descriptors))))
|
||||
(user-error "Bibliography file %s could not be found" file)))
|
||||
(bibtex-completion-normalize-bibliography))
|
||||
(bibtex-completion-normalize-bibliography))
|
||||
|
||||
;; Pre-calculate minimal widths needed by the format strings for
|
||||
;; various entry types:
|
||||
@@ -477,9 +494,10 @@ for string replacement."
|
||||
for entry-type = (parsebib-find-next-item)
|
||||
while entry-type
|
||||
if (string= (downcase entry-type) "string")
|
||||
collect (let ((entry (parsebib-read-string (point) ht)))
|
||||
collect (let ((entry (parsebib-read-string ht)))
|
||||
(puthash (car entry) (cdr entry) ht)
|
||||
entry))))
|
||||
entry)
|
||||
else do (forward-line 1))))
|
||||
(-filter (lambda (x) x) strings)))
|
||||
|
||||
(defun bibtex-completion-update-strings-ht (ht strings)
|
||||
@@ -667,8 +685,8 @@ If HT-STRINGS is provided it is assumed to be a hash table."
|
||||
bibtex-completion-additional-search-fields))
|
||||
for entry-type = (parsebib-find-next-item)
|
||||
while entry-type
|
||||
unless (member-ignore-case entry-type '("preamble" "string" "comment"))
|
||||
collect (let* ((entry (parsebib-read-entry entry-type (point) ht-strings))
|
||||
if (not (member-ignore-case entry-type '("preamble" "string" "comment")))
|
||||
collect (let* ((entry (parsebib-read-entry nil ht-strings))
|
||||
(fields (append
|
||||
(list (if (assoc-string "author" entry 'case-fold)
|
||||
"author"
|
||||
@@ -679,7 +697,8 @@ If HT-STRINGS is provided it is assumed to be a hash table."
|
||||
fields)))
|
||||
(-map (lambda (it)
|
||||
(cons (downcase (car it)) (cdr it)))
|
||||
(bibtex-completion-prepare-entry entry fields)))))
|
||||
(bibtex-completion-prepare-entry entry fields)))
|
||||
else do (forward-line 1)))
|
||||
|
||||
(defun bibtex-completion-get-entry (entry-key)
|
||||
"Given a BibTeX key this function scans all bibliographies listed in `bibtex-completion-bibliography' and returns an alist of the record with that key.
|
||||
@@ -698,9 +717,10 @@ Fields from crossreferenced entries are appended to the requested entry."
|
||||
"\\)[[:space:]]*[\(\{][[:space:]]*"
|
||||
(regexp-quote entry-key) "[[:space:]]*,")
|
||||
nil t)
|
||||
(let ((entry-type (match-string 1)))
|
||||
(progn
|
||||
(goto-char (match-beginning 0))
|
||||
(reverse (bibtex-completion-prepare-entry
|
||||
(parsebib-read-entry entry-type (point) bibtex-completion-string-hash-table) nil do-not-find-pdf)))
|
||||
(parsebib-read-entry nil bibtex-completion-string-hash-table) nil do-not-find-pdf)))
|
||||
(progn
|
||||
(display-warning :warning (concat "Bibtex-completion couldn't find entry with key \"" entry-key "\"."))
|
||||
nil)))))
|
||||
@@ -1185,9 +1205,6 @@ string if FIELD is not present in ENTRY and DEFAULT is nil."
|
||||
("editor-abbrev"
|
||||
(when-let ((value (bibtex-completion-get-value "editor" entry)))
|
||||
(bibtex-completion-apa-format-editors-abbrev value)))
|
||||
((or "journal" "journaltitle")
|
||||
(or (bibtex-completion-get-value "journal" entry)
|
||||
(bibtex-completion-get-value "journaltitle" entry)))
|
||||
(_
|
||||
;; Real fields:
|
||||
(let ((value (bibtex-completion-get-value field entry)))
|
||||
@@ -1214,16 +1231,21 @@ string if FIELD is not present in ENTRY and DEFAULT is nil."
|
||||
"\\(^[^{]*{\\)\\|\\(}[^{]*{\\)\\|\\(}.*$\\)\\|\\(^[^{}]*$\\)"
|
||||
(lambda (x) (downcase (s-replace "\\" "\\\\" x)))
|
||||
value)))))
|
||||
("booktitle" value)
|
||||
("journal"
|
||||
(replace-regexp-in-string "[{}]" "" value))
|
||||
("booktitle"
|
||||
(replace-regexp-in-string "[{}]" "" value))
|
||||
;; Maintain the punctuation and capitalization that is used by
|
||||
;; the journal in its title.
|
||||
("pages" (s-join "–" (s-split "[^0-9]+" value t)))
|
||||
("doi" (s-concat " http://dx.doi.org/" value))
|
||||
("year" value)
|
||||
(_ value))
|
||||
;; If field does not exist, try to retrieve value from
|
||||
;; alternative field (possibly a biblatex field):
|
||||
(pcase field
|
||||
("year" (car (split-string (bibtex-completion-get-value "date" entry "") "-"))))
|
||||
))))
|
||||
("year" (car (split-string (bibtex-completion-get-value "date" entry "") "-")))
|
||||
("journal" (bibtex-completion-get-value "journaltitle" entry "")))))))
|
||||
default ""))
|
||||
|
||||
(defun bibtex-completion-apa-format-authors (value &optional abbrev)
|
||||
@@ -1303,18 +1325,9 @@ When ABBREV is non-nil, format in abbreviated APA style instead."
|
||||
(bibtex-completion-apa-format-editors value t))
|
||||
|
||||
(defun bibtex-completion-get-value (field entry &optional default)
|
||||
"Return the value for FIELD in ENTRY or DEFAULT if the value is not defined.
|
||||
Surrounding curly braces are stripped."
|
||||
"Return the value for FIELD in ENTRY or DEFAULT if the value is not defined."
|
||||
(let ((value (cdr (assoc-string field entry 'case-fold))))
|
||||
(if value
|
||||
(replace-regexp-in-string
|
||||
"\\(^[[:space:]]*[\"{][[:space:]]*\\)\\|\\([[:space:]]*[\"}][[:space:]]*$\\)"
|
||||
""
|
||||
;; Collapse whitespaces when the content is not a path:
|
||||
(if (equal bibtex-completion-pdf-field field)
|
||||
value
|
||||
(s-collapse-whitespace value)))
|
||||
default)))
|
||||
(or value default)))
|
||||
|
||||
(defun bibtex-completion-insert-key (keys)
|
||||
"Insert BibTeX KEYS at point."
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
;;; Code:
|
||||
|
||||
(require 'parse-time)
|
||||
(require 'compat)
|
||||
|
||||
(require 'citeproc-bibtex)
|
||||
|
||||
(defvar citeproc-blt-to-csl-types-alist
|
||||
@@ -473,7 +475,7 @@ biblatex variables in B."
|
||||
(citeproc-blt--get-standard 'address b)))
|
||||
(push (cons csl-place-var ~location) result)))
|
||||
;; url
|
||||
(-when-let (url (or (let ((u (alist-get 'url b))) (and u (citeproc-s-replace "\\" "" u)))
|
||||
(-when-let (url (or (let ((u (alist-get 'url b))) (and u (string-replace "\\" "" u)))
|
||||
(when-let ((~eprinttype (or (alist-get 'eprinttype b)
|
||||
(alist-get 'archiveprefix b)))
|
||||
(~eprint (alist-get 'eprint b))
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
(require 's)
|
||||
(require 'org)
|
||||
(require 'map)
|
||||
(require 'compat)
|
||||
;; Handle the fact that org-bibtex has been renamed to ol-bibtex -- for the time
|
||||
;; being we support both feature names.
|
||||
(or (require 'ol-bibtex nil t)
|
||||
@@ -262,7 +263,7 @@ replacements."
|
||||
(let ((wo-quotes (if (and (string= (substring s 0 1) "\"")
|
||||
(string= (substring s -1) "\""))
|
||||
(substring s 1 -1) s)))
|
||||
(citeproc-s-replace "\\&" "&" wo-quotes)))
|
||||
(string-replace "\\&" "&" wo-quotes)))
|
||||
|
||||
(defun citeproc-bt--to-csl (s &optional with-nocase)
|
||||
"Convert a BibTeX field S to a CSL one.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
;;; citeproc-cite.el --- cite and citation rendering -*- lexical-binding: t; -*-
|
||||
|
||||
;; Copyright (C) 2017-2021 András Simonyi
|
||||
;; Copyright (C) 2017-2024 András Simonyi
|
||||
|
||||
;; Author: András Simonyi <andras.simonyi@gmail.com>
|
||||
|
||||
@@ -40,6 +40,11 @@
|
||||
(require 'citeproc-formatters)
|
||||
(require 'citeproc-sort)
|
||||
(require 'citeproc-subbibs)
|
||||
(require 'citeproc-date)
|
||||
(require 'citeproc-biblatex)
|
||||
|
||||
|
||||
(declare-function citeproc-style-category "citeproc-style" (style))
|
||||
|
||||
(cl-defstruct (citeproc-citation (:constructor citeproc-citation-create))
|
||||
"A struct representing a citation.
|
||||
@@ -77,6 +82,35 @@ Each function takes a single argument, a rich-text, and returns a
|
||||
post-processed rich-text value. The functions are applied in the
|
||||
order they appear in the list.")
|
||||
|
||||
(defun citeproc-cite--parse-locator-extra (s)
|
||||
"Parse extra locator text S into locator-date and locator-extra.
|
||||
Return a pair (LOCATOR-DATE . LOCATOR-EXTRA) where
|
||||
- LOCATOR-DATE is a `citeproc-date' struct or nil, and
|
||||
- LOCATOR-EXTRA is a string or nil."
|
||||
(let (locator-date locator-extra)
|
||||
(if (not (string-match-p "^[0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}" s))
|
||||
(setq locator-extra (and (not (s-blank-str-p s)) s))
|
||||
(setq locator-date (citeproc-date-parse (citeproc-blt--to-csl-date
|
||||
(substring s 0 10))))
|
||||
(let ((extra (substring s 10)))
|
||||
(unless (s-blank-str-p extra) (setq locator-extra extra))))
|
||||
(cons locator-date locator-extra)))
|
||||
|
||||
(defun citeproc-cite--internalize-locator (cite)
|
||||
"Internalize a CITE struct's locator by parsing it into fields.
|
||||
If the \"|\" separator is present in the locator then parse it
|
||||
into `locator', `locator-extra' and `locator-date', and update
|
||||
CITE with these fields accordingly. Returns the possibly modified
|
||||
CITE."
|
||||
(when-let ((locator (alist-get 'locator cite))
|
||||
(separator-pos (cl-position ?| locator)))
|
||||
(setf (alist-get 'locator cite) (substring locator 0 separator-pos))
|
||||
(pcase-let ((`(,locator-date . ,locator-extra) (citeproc-cite--parse-locator-extra
|
||||
(substring locator (1+ separator-pos)))))
|
||||
(when locator-date (push (cons 'locator-date locator-date) cite))
|
||||
(when locator-extra (push (cons 'locator-extra locator-extra) cite))))
|
||||
cite)
|
||||
|
||||
(defun citeproc-cite--varlist (cite)
|
||||
"Return the varlist belonging to CITE."
|
||||
(let* ((itd (alist-get 'itd cite))
|
||||
@@ -87,7 +121,8 @@ order they appear in the list.")
|
||||
'(label locator suppress-author suppress-date
|
||||
stop-rendering-at position near-note
|
||||
first-reference-note-number ignore-et-al
|
||||
bib-entry locator-only use-short-title))
|
||||
bib-entry locator-only use-short-title
|
||||
locator-extra locator-date))
|
||||
cite)))
|
||||
(nconc cite-vv item-vv)))
|
||||
|
||||
@@ -228,7 +263,8 @@ For the optional INTERNAL-LINKS argument see
|
||||
(when outer-attrs
|
||||
(setq result (list outer-attrs result)))
|
||||
;; Prepend author to textual citations
|
||||
(when (eq (citeproc-citation-mode c) 'textual)
|
||||
(when (and (eq (citeproc-citation-mode c) 'textual)
|
||||
(not (member (citeproc-style-category style) '("numeric" "label"))))
|
||||
(let* ((first-elt (car cites)) ;; First elt is either a cite or a cite group.
|
||||
;; If the latter then we need to locate the
|
||||
;; first cite as the 2nd element of the first
|
||||
|
||||
@@ -168,16 +168,6 @@ TYPED RTS is a list of (RICH-TEXT . TYPE) pairs"
|
||||
"Return the first text associated with TERM in CONTEXT."
|
||||
(citeproc-term-text-from-terms term (citeproc-context-terms context)))
|
||||
|
||||
(defun citeproc-term-inflected-text (term form number context)
|
||||
"Return the text associated with TERM having FORM and NUMBER."
|
||||
(let ((matches
|
||||
(--select (string= term (citeproc-term-name it))
|
||||
(citeproc-context-terms context))))
|
||||
(cond ((not matches) nil)
|
||||
((= (length matches) 1)
|
||||
(citeproc-term-text (car matches)))
|
||||
(t (citeproc-term--inflected-text-1 matches form number)))))
|
||||
|
||||
(defconst citeproc--term-form-fallback-alist
|
||||
'((verb-short . verb)
|
||||
(symbol . short)
|
||||
@@ -185,17 +175,21 @@ TYPED RTS is a list of (RICH-TEXT . TYPE) pairs"
|
||||
(short . long))
|
||||
"Alist containing the fallback form for each term form.")
|
||||
|
||||
(defun citeproc-term--inflected-text-1 (matches form number)
|
||||
(let ((match (--first (and (eq form (citeproc-term-form it))
|
||||
(or (not (citeproc-term-number it))
|
||||
(eq number (citeproc-term-number it))))
|
||||
matches)))
|
||||
(if match
|
||||
(citeproc-term-text match)
|
||||
(citeproc-term--inflected-text-1
|
||||
matches
|
||||
(alist-get form citeproc--term-form-fallback-alist)
|
||||
number))))
|
||||
(defun citeproc-term-inflected-text (term form number context)
|
||||
"Return the text associated with TERM having FORM and NUMBER."
|
||||
(let ((matches
|
||||
(--select (string= term (citeproc-term-name it))
|
||||
(citeproc-context-terms context))))
|
||||
(if (not matches) nil
|
||||
(let (match)
|
||||
(while (and (not match) form)
|
||||
(setq match (--first (and (eq form (citeproc-term-form it))
|
||||
(or (not (citeproc-term-number it))
|
||||
(eq number (citeproc-term-number it))))
|
||||
matches))
|
||||
(unless match
|
||||
(setq form (alist-get form citeproc--term-form-fallback-alist))))
|
||||
(when match (citeproc-term-text match))))))
|
||||
|
||||
(defun citeproc-term-get-gender (term context)
|
||||
"Return the gender of TERM or nil if none is given."
|
||||
@@ -224,6 +218,20 @@ no internal links should be produced."
|
||||
;; Else link each cite to the corresponding bib item.
|
||||
(if (eq mode 'cite) 'cited-item-no 'bib-item-no)))))
|
||||
|
||||
(defun citeproc-context-maybe-stop-rendering
|
||||
(trigger context result &optional var)
|
||||
"Stop rendering if a (`stop-rendering-at'. TRIGGER) pair is present in CONTEXT.
|
||||
In case of stopping return with RESULT. If the optional VAR
|
||||
symbol is non-nil then rendering is stopped only if VAR is eq to
|
||||
TRIGGER."
|
||||
(if (and (eq trigger (alist-get 'stop-rendering-at (citeproc-context-vars context)))
|
||||
(or (not var) (eq var trigger))
|
||||
(eq (cdr result) 'present-var))
|
||||
(let ((rt-result (car result)))
|
||||
(push '(stopped-rendering . t) (car rt-result))
|
||||
(throw 'stop-rendering (citeproc-rt-render-affixes rt-result)))
|
||||
result))
|
||||
|
||||
(defun citeproc-render-varlist-in-rt (var-alist style mode render-mode &optional
|
||||
internal-links no-external-links)
|
||||
"Render an item described by VAR-ALIST with STYLE in rich-text.
|
||||
@@ -263,7 +271,7 @@ external links."
|
||||
(citeproc-context-int-link-attrval
|
||||
style internal-links mode (alist-get 'position var-alist)))
|
||||
(cite-no-attr-val (cons cite-no-attr
|
||||
(alist-get 'citation-number var-alist))))
|
||||
(alist-get 'citation-number var-alist))))
|
||||
(cond ((consp rendered) (setf (car rendered)
|
||||
(-snoc (car rendered) cite-no-attr-val)))
|
||||
((stringp rendered) (setq rendered
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
(require 'citeproc-lib)
|
||||
(require 'citeproc-rt)
|
||||
(require 'citeproc-context)
|
||||
(require 'citeproc-number)
|
||||
|
||||
(cl-defstruct (citeproc-date (:constructor citeproc-date-create))
|
||||
"Struct for representing dates.
|
||||
@@ -94,7 +95,7 @@ Set the remaining slots to the values SEASON and CIRCA."
|
||||
(cons nil 'empty-vars)))
|
||||
(cons nil 'empty-vars))))
|
||||
;; Handle `year' citation mode by stopping if needed
|
||||
(citeproc-lib-maybe-stop-rendering 'issued context result var-sym)))
|
||||
(citeproc-context-maybe-stop-rendering 'issued context result var-sym)))
|
||||
|
||||
(defun citeproc--date-part (attrs _context &rest _body)
|
||||
"Function corresponding to the date-part CSL element."
|
||||
|
||||
@@ -33,8 +33,11 @@
|
||||
(require 's)
|
||||
(require 'cl-lib)
|
||||
|
||||
(cl-defstruct (citeproc-formatter (:constructor citeproc-formatter-create))
|
||||
"Output formatter struct with slots RT, CITE, BIB-ITEM and BIB.
|
||||
(require 'citeproc-s)
|
||||
(require 'citeproc-rt)
|
||||
|
||||
(cl-defstruct (citeproc-formatter (:constructor citeproc-formatter-create))
|
||||
"Output formatter struct with slots RT, CITE, BIB-ITEM and BIB.
|
||||
RT is a one-argument function mapping a rich-text to its
|
||||
formatted version,
|
||||
CITE is a one-argument function mapping the output of RT for a
|
||||
@@ -48,9 +51,9 @@ BIB is a two-argument function mapping a list of formatted
|
||||
bibliography,
|
||||
NO-EXTERNAL-LINKS is non-nil if the formatter doesn't support
|
||||
external linking."
|
||||
rt (cite #'identity) (bib-item (lambda (x _) x))
|
||||
(bib (lambda (x _) (mapconcat #'identity x "\n\n")))
|
||||
(no-external-links nil))
|
||||
rt (cite #'identity) (bib-item (lambda (x _) x))
|
||||
(bib (lambda (x _) (mapconcat #'identity x "\n\n")))
|
||||
(no-external-links nil))
|
||||
|
||||
(defun citeproc-formatter-fun-create (fmt-alist)
|
||||
"Return a rich-text formatter function based on FMT-ALIST.
|
||||
@@ -164,13 +167,18 @@ Performs finalization by removing unnecessary zero-width spaces."
|
||||
(setq result (citeproc-s-replace-all-seq
|
||||
result '((" " . " ") (" " . " ") ("," . ",") (";" . ";")
|
||||
(":" . ":") ("." . "."))))
|
||||
;; Starting and ending z-w spaces are also removed, but not before an
|
||||
;; asterisk to avoid creating an Org heading.
|
||||
;; Starting and ending z-w spaces are also removed, but not before an asterisk
|
||||
;; to avoid creating an Org heading.
|
||||
(when (and (= (aref result 0) 8203)
|
||||
(not (= (aref result 1) ?*)))
|
||||
(setq result (substring result 1)))
|
||||
(when (= (aref result (- (length result) 1)) 8203)
|
||||
(setq result (substring result 0 -1))))
|
||||
(setq result (substring result 0 -1)))
|
||||
;; Prepend a zero width no-break space when the text starts with
|
||||
;; superscript to make Org parse it correctly.
|
||||
;; NOTE: This is a workaround, ideally should be fixed in Org.
|
||||
(when (= (aref result 0) ?^)
|
||||
(setq result (concat "" result))))
|
||||
result))
|
||||
|
||||
;; HTML
|
||||
@@ -257,11 +265,16 @@ CSL tests."
|
||||
"Return the LaTeX-escaped version of string S."
|
||||
(replace-regexp-in-string citeproc-fmt--latex-esc-regex "\\\\\\&" s))
|
||||
|
||||
(defconst citeproc-fmt--latex-uri-esc-regex
|
||||
(regexp-opt '("#" "%"))
|
||||
"Regular expression matching characters to be escaped in URIs for LaTeX output.")
|
||||
|
||||
(defun citeproc-fmt--latex-href (text uri)
|
||||
(let ((escaped-uri (replace-regexp-in-string "%" "\\\\%" uri)))
|
||||
(if (string-prefix-p "http" text)
|
||||
(concat "\\url{" escaped-uri "}")
|
||||
(concat "\\href{" escaped-uri "}{" text "}"))))
|
||||
(let ((escaped-uri (replace-regexp-in-string
|
||||
citeproc-fmt--latex-uri-esc-regex "\\\\\\&" uri)))
|
||||
(if (string-prefix-p "http" text)
|
||||
(concat "\\url{" escaped-uri "}")
|
||||
(concat "\\href{" escaped-uri "}{" text "}"))))
|
||||
|
||||
(defconst citeproc-fmt--latex-alist
|
||||
`((unformatted . ,#'citeproc-fmt--latex-escape)
|
||||
|
||||
@@ -143,7 +143,7 @@
|
||||
(setq type (cdr macro-val)))))
|
||||
;; We stop if only the title had to be rendered.
|
||||
(let ((result (cons (citeproc-rt-format-single attrs content context) type)))
|
||||
(citeproc-lib-maybe-stop-rendering
|
||||
(citeproc-context-maybe-stop-rendering
|
||||
'title context result (or (and .variable (intern .variable)) t))))))
|
||||
|
||||
(provide 'citeproc-generic-elements)
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
)
|
||||
|
||||
(defconst citeproc--date-vars
|
||||
'(accessed available-date event-date issued original-date submitted)
|
||||
'(accessed available-date event-date issued original-date submitted locator-date)
|
||||
"CSL date variables.")
|
||||
|
||||
(defconst citeproc--name-vars
|
||||
@@ -145,20 +145,6 @@ numeric content."
|
||||
(s-matches-p "\\`[[:alpha:]]?[[:digit:]]+[[:alpha:]]*\\(\\( *\\([,&-]\\|--\\) *\\)?[[:alpha:]]?[[:digit:]]+[[:alpha:]]*\\)?\\'"
|
||||
val))))
|
||||
|
||||
(defun citeproc-lib-maybe-stop-rendering
|
||||
(trigger context result &optional var)
|
||||
"Stop rendering if a (`stop-rendering-at'. TRIGGER) pair is present in CONTEXT.
|
||||
In case of stopping return with RESULT. If the optional VAR
|
||||
symbol is non-nil then rendering is stopped only if VAR is eq to
|
||||
TRIGGER."
|
||||
(if (and (eq trigger (alist-get 'stop-rendering-at (citeproc-context-vars context)))
|
||||
(or (not var) (eq var trigger))
|
||||
(eq (cdr result) 'present-var))
|
||||
(let ((rt-result (car result)))
|
||||
(push '(stopped-rendering . t) (car rt-result))
|
||||
(throw 'stop-rendering (citeproc-rt-render-affixes rt-result)))
|
||||
result))
|
||||
|
||||
(provide 'citeproc-lib)
|
||||
|
||||
;;; citeproc-lib.el ends here
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
(define-package "citeproc" "20230228.1414" "A CSL 1.0.2 Citation Processor"
|
||||
(define-package "citeproc" "20240722.1110" "A CSL 1.0.2 Citation Processor"
|
||||
'((emacs "26")
|
||||
(dash "2.13.0")
|
||||
(s "1.12.0")
|
||||
@@ -6,8 +6,9 @@
|
||||
(queue "0.2")
|
||||
(string-inflection "1.0")
|
||||
(org "9")
|
||||
(parsebib "2.4"))
|
||||
:commit "290320fc579f886255f00d7268600df7fa5cc7e8" :authors
|
||||
(parsebib "2.4")
|
||||
(compat "28.1"))
|
||||
:commit "54184baaff555b5c7993d566d75dd04ed485b5c0" :authors
|
||||
'(("András Simonyi" . "andras.simonyi@gmail.com"))
|
||||
:maintainers
|
||||
'(("András Simonyi" . "andras.simonyi@gmail.com"))
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'citeproc-s)
|
||||
|
||||
(defun citeproc-prange--end-significant (start end len)
|
||||
"Return the significant digits of the end in page range START END.
|
||||
START and END are strings of equal length containing integers. If
|
||||
|
||||
@@ -230,6 +230,14 @@ Return the PROC-internal representation of REP."
|
||||
(let ((filters (citeproc-proc-bib-filters proc)))
|
||||
(and filters (not (equal filters '(nil))))))
|
||||
|
||||
(defun citeproc-proc-max-offset (itds)
|
||||
"Return the maximal first field width of bibitems in ITDS.
|
||||
ITDS should be the value of the itemdata field of a citeproc-proc
|
||||
structure."
|
||||
(cl-loop for itd being the hash-values of itds
|
||||
when (listp (citeproc-itemdata-rawbibitem itd)) maximize
|
||||
(length (citeproc-rt-to-plain (cadr (citeproc-itemdata-rawbibitem itd))))))
|
||||
|
||||
(provide 'citeproc-proc)
|
||||
|
||||
;;; citeproc-proc.el ends here
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
(require 'cl-lib)
|
||||
(require 'let-alist)
|
||||
(require 's)
|
||||
(require 'compat)
|
||||
|
||||
(require 'citeproc-s)
|
||||
(require 'citeproc-lib)
|
||||
@@ -148,7 +149,7 @@ If optional SKIP-NOCASE is non-nil then skip spans with the
|
||||
|
||||
(defun citeproc-rt-strip-periods (rts)
|
||||
"Remove all periods from rich-texts RTS."
|
||||
(citeproc-rt-map-strings (lambda (x) (citeproc-s-replace "." "" x)) rts))
|
||||
(citeproc-rt-map-strings (lambda (x) (string-replace "." "" x)) rts))
|
||||
|
||||
(defun citeproc-rt-length (rt)
|
||||
"Return the length of rich-text RT as a string."
|
||||
@@ -532,12 +533,6 @@ The values are ordered depth-first."
|
||||
|
||||
;;; Helpers for bibliography rendering
|
||||
|
||||
(defun citeproc-rt-max-offset (itemdata)
|
||||
"Return the maximal first field width in rich-texts RTS."
|
||||
(cl-loop for itd being the hash-values of itemdata
|
||||
when (listp (citeproc-itemdata-rawbibitem itd)) maximize
|
||||
(length (citeproc-rt-to-plain (cadr (citeproc-itemdata-rawbibitem itd))))))
|
||||
|
||||
(defun citeproc-rt-subsequent-author-substitute (bib s)
|
||||
"Substitute S for subsequent author(s) in BIB.
|
||||
BIB is a list of bib entries in rich-text format. Return the
|
||||
|
||||
+13
-12
@@ -27,11 +27,7 @@
|
||||
|
||||
(require 'thingatpt)
|
||||
(require 's)
|
||||
|
||||
;; Handle the unavailability of `string-replace' in early Emacs versions
|
||||
(if (fboundp 'string-replace)
|
||||
(defalias 'citeproc-s-replace #'string-replace)
|
||||
(defalias 'citeproc-s-replace #'s-replace))
|
||||
(require 'compat)
|
||||
|
||||
(defun citeproc-s-camelcase-p (s)
|
||||
"Return whether string S is in camel case."
|
||||
@@ -151,12 +147,12 @@ first word is not in lowercase then return S."
|
||||
(buffer-string))
|
||||
s))
|
||||
|
||||
(defun citeproc-s-sentence-case-title (s omit-nocase)
|
||||
(defun citeproc-s-sentence-case-title (s &optional omit-nocase)
|
||||
"Return a sentence-cased version of title string S.
|
||||
If optional OMIT-NOCASE is non-nil then omit the nocase tags from the output."
|
||||
(if (s-blank-p s) s
|
||||
(let ((sliced (citeproc-s-slice-by-matches
|
||||
s "\\(<span class=\"nocase\">\\|</span>\\|: +\\w\\)"))
|
||||
s "\\(<span class=\"nocase\">\\|</span>\\|: +[\"'“‘]*[[:alpha:]]\\)"))
|
||||
(protect-level 0)
|
||||
(first t)
|
||||
result)
|
||||
@@ -165,13 +161,18 @@ If optional OMIT-NOCASE is non-nil then omit the nocase tags from the output."
|
||||
(pcase slice
|
||||
("<span class=\"nocase\">" (cl-incf protect-level) (if omit-nocase nil slice))
|
||||
("</span>" (cl-decf protect-level) (if omit-nocase nil slice))
|
||||
;; Don't touch the first letter after a colon since it is probably a subtitle.
|
||||
((pred (string-match-p "^:")) slice)
|
||||
;; Don't touch the first letter after a colon since it probably
|
||||
;; starts a subtitle.
|
||||
((pred (string-match-p "^: +[\"'“‘]*[[:alpha:]]")) (setq first nil) slice)
|
||||
(_ (cond ((< 0 protect-level) (setq first nil) slice)
|
||||
((not first) (downcase slice))
|
||||
(t (setq first nil)
|
||||
(concat (upcase (substring slice 0 1))
|
||||
(downcase (substring slice 1)))))))
|
||||
;; We upcase the first letter and downcase the rest.
|
||||
(let ((pos (string-match "[[:alpha:]]" slice)))
|
||||
(if pos (concat (substring slice 0 pos)
|
||||
(upcase (substring slice pos (1+ pos)))
|
||||
(downcase (substring slice (1+ pos))))
|
||||
slice))))))
|
||||
result))
|
||||
(apply #'concat (nreverse result)))))
|
||||
|
||||
@@ -232,7 +233,7 @@ OQ is the opening quote, CQ is the closing quote to use."
|
||||
REPLACEMENTS is an alist with (FROM . TO) elements."
|
||||
(let ((result s))
|
||||
(pcase-dolist (`(,from . ,to) replacements)
|
||||
(setq result (citeproc-s-replace from to result)))
|
||||
(setq result (string-replace from to result)))
|
||||
result))
|
||||
|
||||
(defun citeproc-s-replace-all-sim (s regex replacements)
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
(require 'citeproc-macro)
|
||||
(require 'citeproc-proc)
|
||||
(require 'citeproc-name)
|
||||
(require 'citeproc-number)
|
||||
|
||||
(defun citeproc--sort (_attrs _context &rest body)
|
||||
"Placeholder function corresponding to the cs:sort element of CSL."
|
||||
@@ -172,17 +173,17 @@ MODE is either `cite' or `bib'."
|
||||
(let ((is-sorted-bib (citeproc-style-bib-sort (citeproc-proc-style proc)))
|
||||
(is-filtered (citeproc-proc-filtered-bib-p proc)))
|
||||
(when (or is-sorted-bib is-filtered)
|
||||
(let* ((itds (hash-table-values (citeproc-proc-itemdata proc)))
|
||||
(sorted (if is-sorted-bib
|
||||
(let ((sort-orders (citeproc-style-bib-sort-orders
|
||||
(let* ((itds (citeproc-sort-itds-on-citnum
|
||||
(hash-table-values (citeproc-proc-itemdata proc)))))
|
||||
(when is-sorted-bib
|
||||
(let ((sort-orders (citeproc-style-bib-sort-orders
|
||||
(citeproc-proc-style proc))))
|
||||
(citeproc-sort-itds itds sort-orders))
|
||||
(citeproc-sort-itds-on-citnum itds))))
|
||||
(setq itds (citeproc-sort-itds itds sort-orders))))
|
||||
;; Additionally sort according to subbibliographies if there are filters.
|
||||
(when is-filtered
|
||||
(setq sorted (sort sorted #'citeproc-sort-itds-on-subbib)))
|
||||
(setq itds (sort itds #'citeproc-sort-itds-on-subbib)))
|
||||
;; Set the CSL citation-number field according to the sort order.
|
||||
(--each-indexed sorted
|
||||
(--each-indexed itds
|
||||
(citeproc-itd-setvar it 'citation-number
|
||||
(number-to-string (1+ it-index))))))))
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
|
||||
(cl-defstruct (citeproc-style (:constructor citeproc-style--create))
|
||||
"A struct representing a parsed and localized CSL style.
|
||||
CATEGORY is the style's category as a string,
|
||||
INFO is the style's general info (currently simply the
|
||||
corresponding fragment of the parsed xml),
|
||||
OPTS, BIB-OPTS, CITE-OPTS and LOCALE-OPTS are alists of general
|
||||
@@ -49,7 +50,6 @@ BIB-SORT-ORDERS and CITE-SORT-ORDERS are the lists of sort orders
|
||||
the n-th key should be in ascending or desending order,
|
||||
CITE-LAYOUT-ATTRS contains the attributes of the citation layout
|
||||
as an alist,
|
||||
CITE-NOTE is non-nil iff the style's citation-format is \"note\",
|
||||
DATE-TEXT and DATE-NUMERIC are the style's date formats,
|
||||
LOCALE contains the locale to be used or nil if not set,
|
||||
MACROS is an alist with macro names as keys and corresponding
|
||||
@@ -57,8 +57,8 @@ MACROS is an alist with macro names as keys and corresponding
|
||||
TERMS is the style's parsed term-list,
|
||||
USES-YS-VAR is non-nil iff the style uses the YEAR-SUFFIX
|
||||
CSL-variable."
|
||||
info opts bib-opts bib-sort bib-sort-orders
|
||||
bib-layout cite-opts cite-note cite-sort cite-sort-orders
|
||||
category info opts bib-opts bib-sort bib-sort-orders
|
||||
bib-layout cite-opts cite-sort cite-sort-orders
|
||||
cite-layout cite-layout-attrs locale-opts macros terms
|
||||
uses-ys-var date-text date-numeric locale)
|
||||
|
||||
@@ -98,12 +98,13 @@ in-style locale information will be loaded (if available)."
|
||||
(--each (cddr parsed-style)
|
||||
(pcase (car it)
|
||||
('info
|
||||
(let ((info-lst (cddr it)))
|
||||
(setf (citeproc-style-info style) info-lst
|
||||
(citeproc-style-cite-note style)
|
||||
(not (not (member '(category
|
||||
((citation-format . "note")))
|
||||
info-lst))))))
|
||||
(let* ((info-lst (cddr it))
|
||||
(category-info (cl-find-if
|
||||
(lambda (x) (and (eq 'category (car x))
|
||||
(eq 'citation-format (caaadr x))))
|
||||
info-lst))
|
||||
(category (cdaadr category-info)))
|
||||
(setf (citeproc-style-category style) category)))
|
||||
('locale
|
||||
(let ((lang (alist-get 'lang (cadr it))))
|
||||
(when (and (citeproc-locale--compatible-p lang locale)
|
||||
@@ -310,7 +311,16 @@ position and before the (possibly empty) body."
|
||||
(cons str (cdr result)))
|
||||
result)))
|
||||
;; Handle `author' citation mode by stopping if needed
|
||||
(citeproc-lib-maybe-stop-rendering 'names context final)))))
|
||||
(citeproc-context-maybe-stop-rendering 'names context final)))))
|
||||
|
||||
(defun citeproc-style-cite-note (style)
|
||||
"Return whether csl STYLE is a note style."
|
||||
(string= (citeproc-style-category style) "note"))
|
||||
|
||||
(defun citeproc-style-cite-superscript-p (style)
|
||||
"Return whether csl STYLE has a superscript citaton layout."
|
||||
(string= (alist-get 'vertical-align (citeproc-style-cite-layout-attrs style))
|
||||
"sup"))
|
||||
|
||||
(defun citeproc-style-global-opts (style layout)
|
||||
"Return the global opts in STYLE for LAYOUT.
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'subr-x)
|
||||
(require 'compat)
|
||||
(require 'dash)
|
||||
|
||||
(require 'citeproc-proc)
|
||||
@@ -39,7 +41,8 @@ see the documentation of `citeproc-add-subbib-filters'."
|
||||
(let* ((csl-type (alist-get 'type vv))
|
||||
(type (or (alist-get 'blt-type vv) csl-type))
|
||||
(keyword (alist-get 'keyword vv))
|
||||
(keywords (and keyword (split-string keyword "[ ,;]" t))))
|
||||
(keywords (and keyword (mapcar #'string-clean-whitespace
|
||||
(split-string keyword "[,;]" t)))))
|
||||
(--every-p
|
||||
(pcase it
|
||||
(`(type . ,key) (string= type key))
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
;;; citeproc.el --- A CSL 1.0.2 Citation Processor -*- lexical-binding: t; -*-
|
||||
|
||||
;; Copyright (C) 2017-2023 András Simonyi
|
||||
;; Copyright (C) 2017-2024 András Simonyi
|
||||
|
||||
;; Author: András Simonyi <andras.simonyi@gmail.com>
|
||||
;; Maintainer: András Simonyi <andras.simonyi@gmail.com>
|
||||
;; URL: https://github.com/andras-simonyi/citeproc-el
|
||||
;; Keywords: bib
|
||||
;; Package-Requires: ((emacs "26") (dash "2.13.0") (s "1.12.0") (f "0.18.0") (queue "0.2") (string-inflection "1.0") (org "9") (parsebib "2.4"))
|
||||
;; Package-Requires: ((emacs "26") (dash "2.13.0") (s "1.12.0") (f "0.18.0") (queue "0.2") (string-inflection "1.0") (org "9") (parsebib "2.4")(compat "28.1"))
|
||||
;; Version: 0.9.3
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
@@ -87,10 +87,12 @@ CITATIONS is a list of `citeproc-citation' structures."
|
||||
(new-ids (--remove (gethash it itemdata) uniq-ids)))
|
||||
;; Add all new items in one pass
|
||||
(citeproc-proc-put-items-by-id proc new-ids)
|
||||
;; Add itemdata to the cite structs and add them to the cite queue.
|
||||
;; Internalize the cites dealing with locator-extra if present, add itemdata to
|
||||
;; the cite structs and add them to the cite queue.
|
||||
(dolist (citation citations)
|
||||
(setf (citeproc-citation-cites citation)
|
||||
(--map (cons (cons 'itd (gethash (alist-get 'id it) itemdata)) it)
|
||||
(--map (cons (cons 'itd (gethash (alist-get 'id it) itemdata))
|
||||
(citeproc-cite--internalize-locator it))
|
||||
(citeproc-citation-cites citation)))
|
||||
(queue-append (citeproc-proc-citations proc) citation))
|
||||
(setf (citeproc-proc-finalized proc) nil))))
|
||||
@@ -239,8 +241,12 @@ formatting parameters keyed to the parameter names as symbols:
|
||||
raw-bib)
|
||||
raw-bib))
|
||||
;; Calculate formatting params.
|
||||
(max-offset (if (alist-get 'second-field-align bib-opts)
|
||||
(citeproc-rt-max-offset itemdata)
|
||||
;; NOTE: This is the only place where we check whether there are
|
||||
;; bibliography items in the processor, even though the empty case
|
||||
;; could be handled way more efficiently.
|
||||
(max-offset (if (and (alist-get 'second-field-align bib-opts)
|
||||
(not (hash-table-empty-p itemdata)))
|
||||
(citeproc-proc-max-offset itemdata)
|
||||
0))
|
||||
(format-params (cons (cons 'max-offset max-offset)
|
||||
(citeproc-style-bib-opts-to-formatting-params bib-opts)))
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
;;; company-abbrev.el --- company-mode completion backend for abbrev
|
||||
;;; company-abbrev.el --- company-mode completion backend for abbrev -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2009-2011, 2013-2015, 2021 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2009-2011, 2013-2015, 2021, 2023 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Nikolaj Schumacher
|
||||
|
||||
@@ -29,21 +29,23 @@
|
||||
(require 'cl-lib)
|
||||
(require 'abbrev)
|
||||
|
||||
(defun company-abbrev-insert (match)
|
||||
(defun company-abbrev-insert (_match)
|
||||
"Replace MATCH with the expanded abbrev."
|
||||
(expand-abbrev))
|
||||
|
||||
;;;###autoload
|
||||
(defun company-abbrev (command &optional arg &rest ignored)
|
||||
(defun company-abbrev (command &optional arg &rest _ignored)
|
||||
"`company-mode' completion backend for abbrev."
|
||||
(interactive (list 'interactive))
|
||||
(cl-case command
|
||||
(interactive (company-begin-backend 'company-abbrev
|
||||
'company-abbrev-insert))
|
||||
(prefix (company-grab-symbol))
|
||||
(candidates (nconc
|
||||
(delete "" (all-completions arg global-abbrev-table))
|
||||
(delete "" (all-completions arg local-abbrev-table))))
|
||||
(candidates (apply
|
||||
#'nconc
|
||||
(mapcar (lambda (table)
|
||||
(delete "" (all-completions arg table)))
|
||||
(abbrev--active-tables))))
|
||||
(kind 'snippet)
|
||||
(meta (abbrev-expansion arg))
|
||||
(post-completion (expand-abbrev))))
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
;;; company-bbdb.el --- company-mode completion backend for BBDB in message-mode
|
||||
;;; company-bbdb.el --- company-mode completion backend for BBDB in message-mode -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2013-2016, 2020 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2013-2016, 2020, 2023 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Jan Tatarik <jan.tatarik@gmail.com>
|
||||
|
||||
@@ -23,9 +23,7 @@
|
||||
(require 'cl-lib)
|
||||
|
||||
(declare-function bbdb-record-get-field "bbdb")
|
||||
(declare-function bbdb-records "bbdb")
|
||||
(declare-function bbdb-dwim-mail "bbdb-com")
|
||||
(declare-function bbdb-search "bbdb-com")
|
||||
|
||||
(defgroup company-bbdb nil
|
||||
"Completion backend for BBDB."
|
||||
@@ -40,10 +38,12 @@
|
||||
(cl-mapcan (lambda (record)
|
||||
(mapcar (lambda (mail) (bbdb-dwim-mail record mail))
|
||||
(bbdb-record-get-field record 'mail)))
|
||||
(eval '(bbdb-search (bbdb-records) arg nil arg))))
|
||||
(eval `(let ((arg ,arg))
|
||||
(bbdb-search (bbdb-records) :all-names arg :mail arg))
|
||||
t)))
|
||||
|
||||
;;;###autoload
|
||||
(defun company-bbdb (command &optional arg &rest ignore)
|
||||
(defun company-bbdb (command &optional arg &rest _ignore)
|
||||
"`company-mode' completion backend for BBDB."
|
||||
(interactive (list 'interactive))
|
||||
(cl-case command
|
||||
|
||||
+106
-89
@@ -1,6 +1,6 @@
|
||||
;;; company-capf.el --- company-mode completion-at-point-functions backend -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2013-2022 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2013-2024 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
;;; Commentary:
|
||||
;;
|
||||
;; The CAPF back-end provides a bridge to the standard
|
||||
@@ -32,13 +31,27 @@
|
||||
(require 'company)
|
||||
(require 'cl-lib)
|
||||
|
||||
(defgroup company-capf nil
|
||||
"Completion backend as adapter for `completion-at-point-functions'."
|
||||
:group 'company)
|
||||
|
||||
(defcustom company-capf-disabled-functions '(tags-completion-at-point-function
|
||||
ispell-completion-at-point)
|
||||
"List of completion functions which should be ignored in this backend.
|
||||
|
||||
By default it contains the functions that duplicate the built-in backends
|
||||
but don't support the corresponding configuration options and/or alter the
|
||||
intended priority of the default backends' configuration."
|
||||
:type 'hook
|
||||
:package-version '(company . "1.0.0"))
|
||||
|
||||
;; Amortizes several calls to a c-a-p-f from the same position.
|
||||
(defvar company--capf-cache nil)
|
||||
|
||||
;; FIXME: Provide a way to save this info once in Company itself
|
||||
;; (https://github.com/company-mode/company-mode/pull/845).
|
||||
(defvar-local company-capf--current-completion-data nil
|
||||
"Value last returned by `company-capf' when called with `candidates'.
|
||||
"Value last returned by `company-capf' in response to `candidates'.
|
||||
For most properties/actions, this is just what we need: the exact values
|
||||
that accompanied the completion table that's currently is use.
|
||||
|
||||
@@ -46,6 +59,9 @@ that accompanied the completion table that's currently is use.
|
||||
a completion session (most importantly, by `company-sort-by-occurrence'),
|
||||
so we can't just use the preceding variable instead.")
|
||||
|
||||
(defvar-local company-capf--current-completion-metadata nil
|
||||
"Metadata computed with the current prefix and data above.")
|
||||
|
||||
(defun company--capf-data ()
|
||||
(let ((cache company--capf-cache))
|
||||
(if (and (equal (current-buffer) (car cache))
|
||||
@@ -57,79 +73,51 @@ so we can't just use the preceding variable instead.")
|
||||
(list (current-buffer) (point) (buffer-chars-modified-tick) data))
|
||||
data))))
|
||||
|
||||
(defun company--contains (elt lst)
|
||||
(when-let ((cur (car lst)))
|
||||
(cond
|
||||
((symbolp cur)
|
||||
(or (eq elt cur)
|
||||
(company--contains elt (cdr lst))))
|
||||
((listp cur)
|
||||
(or (company--contains elt cur)
|
||||
(company--contains elt (cdr lst)))))))
|
||||
|
||||
(defun company--capf-data-real ()
|
||||
(cl-letf* (((default-value 'completion-at-point-functions)
|
||||
(if (company--contains 'company-etags company-backends)
|
||||
;; Ignore tags-completion-at-point-function because it subverts
|
||||
;; company-etags in the default value of company-backends, where
|
||||
;; the latter comes later.
|
||||
(remove 'tags-completion-at-point-function
|
||||
(default-value 'completion-at-point-functions))
|
||||
(default-value 'completion-at-point-functions)))
|
||||
(completion-at-point-functions (company--capf-workaround))
|
||||
(data (run-hook-wrapped 'completion-at-point-functions
|
||||
;; Ignore misbehaving functions.
|
||||
#'company--capf-wrapper 'optimist)))
|
||||
(let ((data (run-hook-wrapped 'completion-at-point-functions
|
||||
;; Ignore disabled and misbehaving functions.
|
||||
#'company--capf-wrapper 'optimist)))
|
||||
(when (and (consp (cdr data)) (integer-or-marker-p (nth 1 data))) data)))
|
||||
|
||||
(defun company--capf-wrapper (fun which)
|
||||
(let ((buffer-read-only t)
|
||||
(inhibit-read-only nil)
|
||||
(completion-in-region-function
|
||||
(lambda (beg end coll pred)
|
||||
(throw 'company--illegal-completion-in-region
|
||||
(list fun beg end coll :predicate pred)))))
|
||||
(catch 'company--illegal-completion-in-region
|
||||
(condition-case nil
|
||||
(completion--capf-wrapper fun which)
|
||||
(buffer-read-only nil)))))
|
||||
;; E.g. tags-completion-at-point-function subverts company-etags in the
|
||||
;; default value of company-backends, where the latter comes later.
|
||||
(unless (memq fun company-capf-disabled-functions)
|
||||
(let ((buffer-read-only t)
|
||||
(inhibit-read-only nil)
|
||||
(completion-in-region-function
|
||||
(lambda (beg end coll pred)
|
||||
(throw 'company--illegal-completion-in-region
|
||||
(list fun beg end coll :predicate pred)))))
|
||||
(catch 'company--illegal-completion-in-region
|
||||
(condition-case nil
|
||||
(completion--capf-wrapper fun which)
|
||||
(buffer-read-only nil))))))
|
||||
|
||||
(declare-function python-shell-get-process "python")
|
||||
|
||||
(defun company--capf-workaround ()
|
||||
;; For http://debbugs.gnu.org/cgi/bugreport.cgi?bug=18067
|
||||
(if (or (not (listp completion-at-point-functions))
|
||||
(not (memq 'python-completion-complete-at-point completion-at-point-functions))
|
||||
(python-shell-get-process))
|
||||
completion-at-point-functions
|
||||
(remq 'python-completion-complete-at-point completion-at-point-functions)))
|
||||
|
||||
(defun company-capf--save-current-data (data)
|
||||
(setq company-capf--current-completion-data data)
|
||||
(defun company-capf--save-current-data (data metadata)
|
||||
(setq company-capf--current-completion-data data
|
||||
company-capf--current-completion-metadata metadata)
|
||||
(add-hook 'company-after-completion-hook
|
||||
#'company-capf--clear-current-data nil t))
|
||||
|
||||
(defun company-capf--clear-current-data (_ignored)
|
||||
(setq company-capf--current-completion-data nil))
|
||||
(setq company-capf--current-completion-data nil
|
||||
company-capf--current-completion-metadata nil))
|
||||
|
||||
(defvar-local company-capf--sorted nil)
|
||||
(defvar-local company-capf--current-boundaries nil)
|
||||
|
||||
(defun company-capf (command &optional arg &rest _args)
|
||||
(defun company-capf (command &optional arg &rest rest)
|
||||
"`company-mode' backend using `completion-at-point-functions'."
|
||||
(interactive (list 'interactive))
|
||||
(pcase command
|
||||
(`interactive (company-begin-backend 'company-capf))
|
||||
(`prefix
|
||||
(let ((res (company--capf-data)))
|
||||
(when res
|
||||
(let ((length (plist-get (nthcdr 4 res) :company-prefix-length))
|
||||
(prefix (buffer-substring-no-properties (nth 1 res) (point))))
|
||||
(cond
|
||||
((> (nth 2 res) (point)) 'stop)
|
||||
(length (cons prefix length))
|
||||
(t prefix))))))
|
||||
(company-capf--prefix))
|
||||
(`candidates
|
||||
(company-capf--candidates arg))
|
||||
(company-capf--candidates arg (car rest)))
|
||||
(`sorted
|
||||
company-capf--sorted)
|
||||
(`match
|
||||
@@ -168,20 +156,35 @@ so we can't just use the preceding variable instead.")
|
||||
(plist-get (nthcdr 4 (company--capf-data)) :company-require-match))
|
||||
(`init nil) ;Don't bother: plenty of other ways to initialize the code.
|
||||
(`post-completion
|
||||
(company--capf-post-completion arg))
|
||||
(company-capf--post-completion arg))
|
||||
(`adjust-boundaries
|
||||
(company--capf-boundaries
|
||||
company-capf--current-boundaries))
|
||||
(`expand-common
|
||||
(company-capf--expand-common arg (car rest)))
|
||||
))
|
||||
|
||||
(defun company-capf--prefix ()
|
||||
(let ((res (company--capf-data)))
|
||||
(when res
|
||||
(let ((length (plist-get (nthcdr 4 res) :company-prefix-length))
|
||||
(prefix (buffer-substring-no-properties (nth 1 res) (point)))
|
||||
(suffix (buffer-substring-no-properties (point) (nth 2 res))))
|
||||
(list prefix suffix length)))))
|
||||
|
||||
(defun company-capf--expand-common (prefix suffix)
|
||||
(let* ((data company-capf--current-completion-data)
|
||||
(table (nth 3 data))
|
||||
(pred (plist-get (nthcdr 4 data) :predicate)))
|
||||
(company--capf-expand-common prefix suffix table pred
|
||||
company-capf--current-completion-metadata)))
|
||||
|
||||
(defun company-capf--annotation (arg)
|
||||
(let* ((f (or (plist-get (nthcdr 4 company-capf--current-completion-data)
|
||||
:annotation-function)
|
||||
;; FIXME: Add a test.
|
||||
(cdr (assq 'annotation-function
|
||||
(completion-metadata
|
||||
(buffer-substring (nth 1 company-capf--current-completion-data)
|
||||
(nth 2 company-capf--current-completion-data))
|
||||
(nth 3 company-capf--current-completion-data)
|
||||
(plist-get (nthcdr 4 company-capf--current-completion-data)
|
||||
:predicate))))))
|
||||
company-capf--current-completion-metadata))))
|
||||
(annotation (when f (funcall f arg))))
|
||||
(if (and company-format-margin-function
|
||||
(equal annotation " <f>") ; elisp-completion-at-point, pre-icons
|
||||
@@ -190,40 +193,54 @@ so we can't just use the preceding variable instead.")
|
||||
nil
|
||||
annotation)))
|
||||
|
||||
(defun company-capf--candidates (input)
|
||||
(let ((res (company--capf-data)))
|
||||
(company-capf--save-current-data res)
|
||||
(when res
|
||||
(let* ((table (nth 3 res))
|
||||
(pred (plist-get (nthcdr 4 res) :predicate))
|
||||
(meta (completion-metadata
|
||||
(buffer-substring (nth 1 res) (nth 2 res))
|
||||
table pred))
|
||||
(candidates (completion-all-completions input table pred
|
||||
(length input)
|
||||
meta))
|
||||
(defun company-capf--candidates (input suffix)
|
||||
(let* ((current-capf (car company-capf--current-completion-data))
|
||||
(res (company--capf-data))
|
||||
(table (nth 3 res))
|
||||
(pred (plist-get (nthcdr 4 res) :predicate))
|
||||
(meta (and res
|
||||
(completion-metadata
|
||||
(buffer-substring (nth 1 res) (nth 2 res))
|
||||
table pred))))
|
||||
(when (and res
|
||||
(or (not current-capf)
|
||||
(equal current-capf (car res))))
|
||||
(let* ((interrupt (plist-get (nthcdr 4 res) :company-use-while-no-input))
|
||||
(all-result (company-capf--candidates-1 input suffix
|
||||
table pred
|
||||
meta
|
||||
(and non-essential
|
||||
(eq interrupt t))))
|
||||
(sortfun (cdr (assq 'display-sort-function meta)))
|
||||
(last (last candidates))
|
||||
(base-size (and (numberp (cdr last)) (cdr last))))
|
||||
(when base-size
|
||||
(setcdr last nil))
|
||||
(candidates (assoc-default :completions all-result)))
|
||||
(setq company-capf--sorted (functionp sortfun))
|
||||
(when candidates
|
||||
(company-capf--save-current-data res meta)
|
||||
(setq company-capf--current-boundaries
|
||||
(company--capf-boundaries-markers
|
||||
(assoc-default :boundaries all-result)
|
||||
company-capf--current-boundaries)))
|
||||
(when sortfun
|
||||
(setq candidates (funcall sortfun candidates)))
|
||||
(if (not (zerop (or base-size 0)))
|
||||
(let ((before (substring input 0 base-size)))
|
||||
(mapcar (lambda (candidate)
|
||||
(concat before candidate))
|
||||
candidates))
|
||||
candidates)))))
|
||||
candidates))))
|
||||
|
||||
(defun company--capf-post-completion (arg)
|
||||
(defun company-capf--candidates-1 (prefix suffix table pred meta interrupt-on-input)
|
||||
(if (not interrupt-on-input)
|
||||
(company--capf-completions prefix suffix table pred meta)
|
||||
(let (res)
|
||||
(and (while-no-input
|
||||
(setq res
|
||||
(company--capf-completions prefix suffix table pred meta))
|
||||
nil)
|
||||
(throw 'interrupted 'new-input))
|
||||
res)))
|
||||
|
||||
(defun company-capf--post-completion (arg)
|
||||
(let* ((res company-capf--current-completion-data)
|
||||
(exit-function (plist-get (nthcdr 4 res) :exit-function))
|
||||
(table (nth 3 res)))
|
||||
(if exit-function
|
||||
;; We can more or less know when the user is done with completion,
|
||||
;; so we do something different than `completion--done'.
|
||||
;; Follow the example of `completion--done'.
|
||||
(funcall exit-function arg
|
||||
;; FIXME: Should probably use an additional heuristic:
|
||||
;; completion-at-point doesn't know when the user picked a
|
||||
@@ -232,7 +249,7 @@ so we can't just use the preceding variable instead.")
|
||||
;; RET (or use implicit completion with company-tng).
|
||||
(if (= (car (completion-boundaries arg table nil ""))
|
||||
(length arg))
|
||||
'sole
|
||||
'exact
|
||||
'finished)))))
|
||||
|
||||
(provide 'company-capf)
|
||||
|
||||
@@ -335,8 +335,8 @@ or automatically through a custom `company-clang-prefix-guesser'."
|
||||
|
||||
(defun company-clang--prefix ()
|
||||
(if company-clang-begin-after-member-access
|
||||
(company-grab-symbol-cons "\\.\\|->\\|::" 2)
|
||||
(company-grab-symbol)))
|
||||
(company-grab-symbol-parts "\\.\\|->\\|::" 2)
|
||||
(company-grab-symbol-parts)))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
;;; company-cmake.el --- company-mode completion backend for CMake
|
||||
;;; company-cmake.el --- company-mode completion backend for CMake -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2013-2015, 2017-2018, 2020 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2013-2015, 2017-2018, 2020, 2023 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Chen Bin <chenbin DOT sh AT gmail>
|
||||
;; Version: 0.2
|
||||
@@ -49,7 +49,7 @@ They affect which types of symbols we get completion candidates for.")
|
||||
"^\\(%s[a-zA-Z0-9_<>]%s\\)$"
|
||||
"Regexp to match the candidates.")
|
||||
|
||||
(defvar company-cmake-modes '(cmake-mode)
|
||||
(defvar company-cmake-modes '(cmake-mode cmake-ts-mode)
|
||||
"Major modes in which cmake may complete.")
|
||||
|
||||
(defvar company-cmake--candidates-cache nil
|
||||
@@ -94,12 +94,10 @@ They affect which types of symbols we get completion candidates for.")
|
||||
))
|
||||
|
||||
(defun company-cmake--parse (prefix content cmd)
|
||||
(let ((start 0)
|
||||
(pattern (format company-cmake--completion-pattern
|
||||
(let ((pattern (format company-cmake--completion-pattern
|
||||
(regexp-quote prefix)
|
||||
(if (zerop (length prefix)) "+" "*")))
|
||||
(lines (split-string content "\n"))
|
||||
match
|
||||
rlt)
|
||||
(dolist (line lines)
|
||||
(when (string-match pattern line)
|
||||
@@ -185,7 +183,7 @@ They affect which types of symbols we get completion candidates for.")
|
||||
(and (eq (char-before (point)) ?\{)
|
||||
(eq (char-before (1- (point))) ?$))))
|
||||
|
||||
(defun company-cmake (command &optional arg &rest ignored)
|
||||
(defun company-cmake (command &optional arg &rest _ignored)
|
||||
"`company-mode' completion backend for CMake.
|
||||
CMake is a cross-platform, open-source make system."
|
||||
(interactive (list 'interactive))
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
;;; company-dabbrev-code.el --- dabbrev-like company-mode backend for code -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2009-2011, 2013-2016, 2021-2023 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2009-2011, 2013-2016, 2021-2024 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Nikolaj Schumacher
|
||||
|
||||
@@ -48,13 +48,16 @@ complete only symbols, not text in comments or strings. In other modes
|
||||
(defcustom company-dabbrev-code-other-buffers t
|
||||
"Determines whether `company-dabbrev-code' should search other buffers.
|
||||
If `all', search all other buffers, except the ignored ones. If t, search
|
||||
buffers with the same major mode. If `code', search all buffers with major
|
||||
modes in `company-dabbrev-code-modes', or derived from one of them. See
|
||||
also `company-dabbrev-code-time-limit'."
|
||||
buffers with the same major mode. If `code', search all
|
||||
buffers with major modes in `company-dabbrev-code-modes', or derived from one of
|
||||
them. This can also be a function that takes the current buffer as
|
||||
parameter and returns a list of major modes to search. See also
|
||||
`company-dabbrev-code-time-limit'."
|
||||
:type '(choice (const :tag "Off" nil)
|
||||
(const :tag "Same major mode" t)
|
||||
(const :tag "Code major modes" code)
|
||||
(const :tag "All" all)))
|
||||
(const :tag "All" all)
|
||||
(function :tag "Function to return similar major-modes" group)))
|
||||
|
||||
(defcustom company-dabbrev-code-time-limit .1
|
||||
"Determines how long `company-dabbrev-code' should look for matches."
|
||||
@@ -73,12 +76,16 @@ also `company-dabbrev-code-time-limit'."
|
||||
"Non-nil to use the completion styles for fuzzy matching."
|
||||
:type '(choice (const :tag "Prefix matching only" nil)
|
||||
(const :tag "Matching according to `completion-styles'" t)
|
||||
(list :tag "Custom list of styles" symbol)))
|
||||
(list :tag "Custom list of styles" symbol))
|
||||
:package-version '(company . "1.0.0"))
|
||||
|
||||
(defvar-local company-dabbrev--boundaries nil)
|
||||
(defvar-local company-dabbrev-code--sorted nil)
|
||||
|
||||
(defun company-dabbrev-code--make-regexp (prefix)
|
||||
(let ((prefix-re
|
||||
(cond
|
||||
((equal prefix "")
|
||||
((string-empty-p prefix)
|
||||
"\\([a-zA-Z]\\|\\s_\\)")
|
||||
((not company-dabbrev-code-completion-styles)
|
||||
(regexp-quote prefix))
|
||||
@@ -88,13 +95,15 @@ also `company-dabbrev-code-time-limit'."
|
||||
(let ((prefix (if (>= (length prefix) 2)
|
||||
(substring prefix 0 2)
|
||||
prefix)))
|
||||
(mapconcat #'regexp-quote
|
||||
(mapcar #'string prefix)
|
||||
"\\(\\sw\\|\\s_\\)*"))))))
|
||||
(concat
|
||||
"\\(\\sw\\|\\s_\\)*"
|
||||
(mapconcat #'regexp-quote
|
||||
(mapcar #'string prefix)
|
||||
"\\(\\sw\\|\\s_\\)*")))))))
|
||||
(concat "\\_<" prefix-re "\\(\\sw\\|\\s_\\)*\\_>")))
|
||||
|
||||
;;;###autoload
|
||||
(defun company-dabbrev-code (command &optional arg &rest _ignored)
|
||||
(defun company-dabbrev-code (command &optional arg &rest rest)
|
||||
"dabbrev-like `company-mode' backend for code.
|
||||
The backend looks for all symbols in the current buffer that aren't in
|
||||
comments or strings."
|
||||
@@ -102,50 +111,77 @@ comments or strings."
|
||||
(cl-case command
|
||||
(interactive (company-begin-backend 'company-dabbrev-code))
|
||||
(prefix (and (or (eq t company-dabbrev-code-modes)
|
||||
(apply #'derived-mode-p company-dabbrev-code-modes))
|
||||
(cl-some #'derived-mode-p company-dabbrev-code-modes))
|
||||
(or company-dabbrev-code-everywhere
|
||||
(not (company-in-string-or-comment)))
|
||||
(or (company-grab-symbol) 'stop)))
|
||||
(candidates
|
||||
(let* ((case-fold-search company-dabbrev-code-ignore-case)
|
||||
(regexp (company-dabbrev-code--make-regexp arg)))
|
||||
(company-dabbrev-code--filter
|
||||
arg
|
||||
(company-cache-fetch
|
||||
'dabbrev-code-candidates
|
||||
(lambda ()
|
||||
(company-dabbrev--search
|
||||
regexp
|
||||
company-dabbrev-code-time-limit
|
||||
(pcase company-dabbrev-code-other-buffers
|
||||
(`t (list major-mode))
|
||||
(`code company-dabbrev-code-modes)
|
||||
(`all `all))
|
||||
(not company-dabbrev-code-everywhere)))
|
||||
:expire t
|
||||
:check-tag regexp))))
|
||||
(company-grab-symbol-parts)))
|
||||
(candidates (company-dabbrev--candidates arg (car rest)))
|
||||
(adjust-boundaries (and company-dabbrev-code-completion-styles
|
||||
(company--capf-boundaries
|
||||
company-dabbrev--boundaries)))
|
||||
(expand-common (company-dabbrev-code--expand-common arg (car rest)))
|
||||
(kind 'text)
|
||||
(sorted company-dabbrev-code--sorted)
|
||||
(no-cache t)
|
||||
(ignore-case company-dabbrev-code-ignore-case)
|
||||
(match (when company-dabbrev-code-completion-styles
|
||||
(company--match-from-capf-face arg)))
|
||||
(duplicates t)))
|
||||
|
||||
(defun company-dabbrev-code--filter (prefix table)
|
||||
(defun company-dabbrev-code--expand-common (prefix suffix)
|
||||
(when company-dabbrev-code-completion-styles
|
||||
(let ((completion-styles (if (listp company-dabbrev-code-completion-styles)
|
||||
company-dabbrev-code-completion-styles
|
||||
completion-styles)))
|
||||
(company--capf-expand-common prefix suffix
|
||||
(company-dabbrev-code--table prefix)))))
|
||||
|
||||
(defun company-dabbrev--candidates (prefix suffix)
|
||||
(let* ((case-fold-search company-dabbrev-code-ignore-case))
|
||||
(company-dabbrev-code--filter
|
||||
prefix suffix
|
||||
(company-dabbrev-code--table prefix))))
|
||||
|
||||
(defun company-dabbrev-code--table (prefix)
|
||||
(let ((regexp (company-dabbrev-code--make-regexp prefix)))
|
||||
(company-cache-fetch
|
||||
'dabbrev-code-candidates
|
||||
(lambda ()
|
||||
(company-dabbrev--search
|
||||
regexp
|
||||
company-dabbrev-code-time-limit
|
||||
(pcase company-dabbrev-code-other-buffers
|
||||
(`t (list major-mode))
|
||||
(`code company-dabbrev-code-modes)
|
||||
((pred functionp) (funcall company-dabbrev-code-other-buffers (current-buffer)))
|
||||
(`all `all))
|
||||
(not company-dabbrev-code-everywhere)))
|
||||
:expire t
|
||||
:check-tag
|
||||
(cons regexp company-dabbrev-code-completion-styles))))
|
||||
|
||||
(defun company-dabbrev-code--filter (prefix suffix table)
|
||||
(let ((completion-ignore-case company-dabbrev-code-ignore-case)
|
||||
(completion-styles (if (listp company-dabbrev-code-completion-styles)
|
||||
company-dabbrev-code-completion-styles
|
||||
completion-styles))
|
||||
(metadata (completion-metadata prefix table nil))
|
||||
res)
|
||||
(if (not company-dabbrev-code-completion-styles)
|
||||
(all-completions prefix table)
|
||||
(setq res (completion-all-completions
|
||||
prefix
|
||||
table
|
||||
nil (length prefix)))
|
||||
(if (numberp (cdr (last res)))
|
||||
(setcdr (last res) nil))
|
||||
res)))
|
||||
(setq res (company--capf-completions
|
||||
prefix suffix
|
||||
table nil
|
||||
metadata))
|
||||
(when-let* ((sort-fn (completion-metadata-get metadata 'display-sort-function)))
|
||||
(setq company-dabbrev-code--sorted t)
|
||||
(setf (alist-get :completions res)
|
||||
(funcall sort-fn (alist-get :completions res))))
|
||||
(setq company-dabbrev--boundaries
|
||||
(company--capf-boundaries-markers
|
||||
(assoc-default :boundaries res)
|
||||
company-dabbrev--boundaries))
|
||||
(assoc-default :completions res))))
|
||||
|
||||
(provide 'company-dabbrev-code)
|
||||
;;; company-dabbrev-code.el ends here
|
||||
|
||||
@@ -35,10 +35,13 @@
|
||||
(defcustom company-dabbrev-other-buffers 'all
|
||||
"Determines whether `company-dabbrev' should search other buffers.
|
||||
If `all', search all other buffers, except the ignored ones. If t, search
|
||||
buffers with the same major mode. See also `company-dabbrev-time-limit'."
|
||||
buffers with the same major mode. This can also be a function that takes
|
||||
the current buffer as parameter and returns a list of major modes to
|
||||
search. See also `company-dabbrev-time-limit'."
|
||||
:type '(choice (const :tag "Off" nil)
|
||||
(const :tag "Same major mode" t)
|
||||
(const :tag "All" all)))
|
||||
(const :tag "All" all)
|
||||
(function :tag "Function to return similar major-modes" group)))
|
||||
|
||||
(defcustom company-dabbrev-ignore-buffers "\\`[ *]"
|
||||
"Regexp matching the names of buffers to ignore.
|
||||
@@ -156,7 +159,7 @@ This variable affects both `company-dabbrev' and `company-dabbrev-code'."
|
||||
(funcall company-dabbrev-ignore-buffers buffer))
|
||||
(with-current-buffer buffer
|
||||
(when (or (eq other-buffer-modes 'all)
|
||||
(apply #'derived-mode-p other-buffer-modes))
|
||||
(cl-some #'derived-mode-p other-buffer-modes))
|
||||
(setq symbols
|
||||
(company-dabbrev--search-buffer regexp nil symbols start
|
||||
limit ignore-comments)))))
|
||||
@@ -166,12 +169,13 @@ This variable affects both `company-dabbrev' and `company-dabbrev-code'."
|
||||
symbols))
|
||||
|
||||
(defun company-dabbrev--prefix ()
|
||||
;; Not in the middle of a word.
|
||||
(unless (looking-at company-dabbrev-char-regexp)
|
||||
;; Emacs can't do greedy backward-search.
|
||||
(company-grab-line (format "\\(?:^\\| \\)[^ ]*?\\(\\(?:%s\\)*\\)"
|
||||
company-dabbrev-char-regexp)
|
||||
1)))
|
||||
;; Emacs can't do greedy backward-search.
|
||||
(list
|
||||
(company-grab-line (format "\\(?:^\\| \\)[^ ]*?\\(\\(?:%s\\)*\\)"
|
||||
company-dabbrev-char-regexp)
|
||||
1)
|
||||
(and (looking-at (format "\\(?:%s\\)*" company-dabbrev-char-regexp))
|
||||
(match-string 0))))
|
||||
|
||||
(defun company-dabbrev--filter (prefix candidates)
|
||||
(let* ((completion-ignore-case company-dabbrev-ignore-case)
|
||||
@@ -195,6 +199,7 @@ This variable affects both `company-dabbrev' and `company-dabbrev-code'."
|
||||
company-dabbrev-time-limit
|
||||
(pcase company-dabbrev-other-buffers
|
||||
(`t (list major-mode))
|
||||
((pred functionp) (funcall company-dabbrev-other-buffers (current-buffer)))
|
||||
(`all `all))))
|
||||
|
||||
;;;###autoload
|
||||
@@ -207,6 +212,7 @@ This variable affects both `company-dabbrev' and `company-dabbrev-code'."
|
||||
(candidates
|
||||
(company-dabbrev--filter
|
||||
arg
|
||||
;; FIXME: Only cache the result of non-interrupted scans?
|
||||
(company-cache-fetch 'dabbrev-candidates #'company-dabbrev--fetch
|
||||
:expire t)))
|
||||
(kind 'text)
|
||||
|
||||
@@ -1,226 +0,0 @@
|
||||
;;; company-elisp.el --- company-mode completion backend for Emacs Lisp -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2009-2015, 2017, 2020 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Nikolaj Schumacher
|
||||
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;; GNU Emacs is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; GNU Emacs is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
;;; Commentary:
|
||||
;;
|
||||
;; In newer versions of Emacs, company-capf is used instead.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'company)
|
||||
(require 'cl-lib)
|
||||
(require 'help-mode)
|
||||
(require 'find-func)
|
||||
|
||||
(defgroup company-elisp nil
|
||||
"Completion backend for Emacs Lisp."
|
||||
:group 'company)
|
||||
|
||||
(defcustom company-elisp-detect-function-context t
|
||||
"If enabled, offer Lisp functions only in appropriate contexts.
|
||||
Functions are offered for completion only after \\=' and \(."
|
||||
:type '(choice (const :tag "Off" nil)
|
||||
(const :tag "On" t)))
|
||||
|
||||
(defcustom company-elisp-show-locals-first t
|
||||
"If enabled, locally bound variables and functions are displayed
|
||||
first in the candidates list."
|
||||
:type '(choice (const :tag "Off" nil)
|
||||
(const :tag "On" t)))
|
||||
|
||||
(defun company-elisp--prefix ()
|
||||
(let ((prefix (company-grab-symbol)))
|
||||
(if prefix
|
||||
(when (if (company-in-string-or-comment)
|
||||
(= (char-before (- (point) (length prefix))) ?`)
|
||||
(company-elisp--should-complete))
|
||||
prefix)
|
||||
'stop)))
|
||||
|
||||
(defun company-elisp--predicate (symbol)
|
||||
(or (boundp symbol)
|
||||
(fboundp symbol)
|
||||
(facep symbol)
|
||||
(featurep symbol)))
|
||||
|
||||
(defun company-elisp--fns-regexp (&rest names)
|
||||
(concat "\\_<\\(?:cl-\\)?" (regexp-opt names) "\\*?\\_>"))
|
||||
|
||||
(defvar company-elisp-parse-limit 30)
|
||||
(defvar company-elisp-parse-depth 100)
|
||||
|
||||
(defvar company-elisp-defun-names '("defun" "defmacro" "defsubst"))
|
||||
|
||||
(defvar company-elisp-var-binding-regexp
|
||||
(apply #'company-elisp--fns-regexp "let" "lambda" "lexical-let"
|
||||
company-elisp-defun-names)
|
||||
"Regular expression matching head of a multiple variable bindings form.")
|
||||
|
||||
(defvar company-elisp-var-binding-regexp-1
|
||||
(company-elisp--fns-regexp "dolist" "dotimes")
|
||||
"Regular expression matching head of a form with one variable binding.")
|
||||
|
||||
(defvar company-elisp-fun-binding-regexp
|
||||
(company-elisp--fns-regexp "flet" "labels")
|
||||
"Regular expression matching head of a function bindings form.")
|
||||
|
||||
(defvar company-elisp-defuns-regexp
|
||||
(concat "([ \t\n]*"
|
||||
(apply #'company-elisp--fns-regexp company-elisp-defun-names)))
|
||||
|
||||
(defun company-elisp--should-complete ()
|
||||
(let ((start (point))
|
||||
(depth (car (syntax-ppss))))
|
||||
(not
|
||||
(when (> depth 0)
|
||||
(save-excursion
|
||||
(up-list (- depth))
|
||||
(when (looking-at company-elisp-defuns-regexp)
|
||||
(forward-char)
|
||||
(forward-sexp 1)
|
||||
(unless (= (point) start)
|
||||
(condition-case nil
|
||||
(let ((args-end (scan-sexps (point) 2)))
|
||||
(or (null args-end)
|
||||
(> args-end start)))
|
||||
(scan-error
|
||||
t)))))))))
|
||||
|
||||
(defun company-elisp--locals (prefix functions-p)
|
||||
(let ((regexp (concat "[ \t\n]*\\(\\_<" (regexp-quote prefix)
|
||||
"\\(?:\\sw\\|\\s_\\)*\\_>\\)"))
|
||||
(pos (point))
|
||||
res)
|
||||
(condition-case nil
|
||||
(save-excursion
|
||||
(dotimes (_ company-elisp-parse-depth)
|
||||
(up-list -1)
|
||||
(save-excursion
|
||||
(when (eq (char-after) ?\()
|
||||
(forward-char 1)
|
||||
(when (ignore-errors
|
||||
(save-excursion (forward-list)
|
||||
(<= (point) pos)))
|
||||
(skip-chars-forward " \t\n")
|
||||
(cond
|
||||
((looking-at (if functions-p
|
||||
company-elisp-fun-binding-regexp
|
||||
company-elisp-var-binding-regexp))
|
||||
(down-list 1)
|
||||
(condition-case nil
|
||||
(dotimes (_ company-elisp-parse-limit)
|
||||
(save-excursion
|
||||
(when (looking-at "[ \t\n]*(")
|
||||
(down-list 1))
|
||||
(when (looking-at regexp)
|
||||
(cl-pushnew (match-string-no-properties 1) res)))
|
||||
(forward-sexp))
|
||||
(scan-error nil)))
|
||||
((unless functions-p
|
||||
(looking-at company-elisp-var-binding-regexp-1))
|
||||
(down-list 1)
|
||||
(when (looking-at regexp)
|
||||
(cl-pushnew (match-string-no-properties 1) res)))))))))
|
||||
(scan-error nil))
|
||||
res))
|
||||
|
||||
(defun company-elisp-candidates (prefix)
|
||||
(let* ((predicate (company-elisp--candidates-predicate prefix))
|
||||
(locals (company-elisp--locals prefix (eq predicate 'fboundp)))
|
||||
(globals (company-elisp--globals prefix predicate))
|
||||
(locals (cl-loop for local in locals
|
||||
when (not (member local globals))
|
||||
collect local)))
|
||||
(if company-elisp-show-locals-first
|
||||
(append (sort locals 'string<)
|
||||
(sort globals 'string<))
|
||||
(append locals globals))))
|
||||
|
||||
(defun company-elisp--globals (prefix predicate)
|
||||
(all-completions prefix obarray predicate))
|
||||
|
||||
(defun company-elisp--candidates-predicate (prefix)
|
||||
(let* ((completion-ignore-case nil)
|
||||
(beg (- (point) (length prefix)))
|
||||
(before (char-before beg)))
|
||||
(if (and company-elisp-detect-function-context
|
||||
(not (memq before '(?' ?`))))
|
||||
(if (and (eq before ?\()
|
||||
(not
|
||||
(save-excursion
|
||||
(ignore-errors
|
||||
(goto-char (1- beg))
|
||||
(or (company-elisp--before-binding-varlist-p)
|
||||
(progn
|
||||
(up-list -1)
|
||||
(company-elisp--before-binding-varlist-p)))))))
|
||||
'fboundp
|
||||
'boundp)
|
||||
'company-elisp--predicate)))
|
||||
|
||||
(defun company-elisp--before-binding-varlist-p ()
|
||||
(save-excursion
|
||||
(and (prog1 (search-backward "(")
|
||||
(forward-char 1))
|
||||
(looking-at company-elisp-var-binding-regexp))))
|
||||
|
||||
(defun company-elisp--doc (symbol)
|
||||
(let* ((symbol (intern symbol))
|
||||
(doc (if (fboundp symbol)
|
||||
(documentation symbol t)
|
||||
(documentation-property symbol 'variable-documentation t))))
|
||||
(and (stringp doc)
|
||||
(string-match ".*$" doc)
|
||||
(match-string 0 doc))))
|
||||
|
||||
;;;###autoload
|
||||
(defun company-elisp (command &optional arg &rest _ignored)
|
||||
"`company-mode' completion backend for Emacs Lisp."
|
||||
(interactive (list 'interactive))
|
||||
(cl-case command
|
||||
(interactive (company-begin-backend 'company-elisp))
|
||||
(prefix (and (derived-mode-p 'emacs-lisp-mode 'inferior-emacs-lisp-mode)
|
||||
(company-elisp--prefix)))
|
||||
(candidates (company-elisp-candidates arg))
|
||||
(sorted company-elisp-show-locals-first)
|
||||
(meta (company-elisp--doc arg))
|
||||
(doc-buffer (let ((symbol (intern arg)))
|
||||
(save-window-excursion
|
||||
(ignore-errors
|
||||
(cond
|
||||
((fboundp symbol) (describe-function symbol))
|
||||
((boundp symbol) (describe-variable symbol))
|
||||
((featurep symbol) (describe-package symbol))
|
||||
((facep symbol) (describe-face symbol))
|
||||
(t (signal 'user-error nil)))
|
||||
(help-buffer)))))
|
||||
(location (let ((sym (intern arg)))
|
||||
(cond
|
||||
((fboundp sym) (find-definition-noselect sym nil))
|
||||
((boundp sym) (find-definition-noselect sym 'defvar))
|
||||
((featurep sym) (cons (find-file-noselect (find-library-name
|
||||
(symbol-name sym)))
|
||||
0))
|
||||
((facep sym) (find-definition-noselect sym 'defface)))))))
|
||||
|
||||
(provide 'company-elisp)
|
||||
;;; company-elisp.el ends here
|
||||
@@ -1,6 +1,6 @@
|
||||
;;; company-etags.el --- company-mode completion backend for etags
|
||||
;;; company-etags.el --- company-mode completion backend for etags -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2009-2011, 2013-2015, 2018-2019 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2009-2011, 2013-2015, 2018-2019, 2023-2024 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Nikolaj Schumacher
|
||||
|
||||
@@ -54,10 +54,18 @@ Set it to t or to a list of major modes."
|
||||
(symbol :tag "Major mode")))
|
||||
:package-version '(company . "0.9.0"))
|
||||
|
||||
(defcustom company-etags-completion-styles nil
|
||||
"Non-nil to use the completion styles for fuzzy matching."
|
||||
:type '(choice (const :tag "Prefix matching only" nil)
|
||||
(const :tag "Matching according to `completion-styles'" t)
|
||||
(list :tag "Custom list of styles" symbol))
|
||||
:package-version '(company . "1.0.0"))
|
||||
|
||||
(defvar company-etags-modes '(prog-mode c-mode objc-mode c++-mode java-mode
|
||||
jde-mode pascal-mode perl-mode python-mode))
|
||||
|
||||
(defvar-local company-etags-buffer-table 'unknown)
|
||||
(defvar-local company-etags--boundaries nil)
|
||||
|
||||
(defun company-etags-find-table ()
|
||||
(let ((file (expand-file-name
|
||||
@@ -74,34 +82,64 @@ Set it to t or to a list of major modes."
|
||||
(setq company-etags-buffer-table (company-etags-find-table))
|
||||
company-etags-buffer-table)))
|
||||
|
||||
(defun company-etags--candidates (prefix)
|
||||
(defun company-etags--candidates (prefix suffix)
|
||||
(let ((completion-ignore-case company-etags-ignore-case)
|
||||
(completion-styles (if (listp company-etags-completion-styles)
|
||||
company-etags-completion-styles
|
||||
completion-styles))
|
||||
(table (company-etags--table)))
|
||||
(and table
|
||||
(if company-etags-completion-styles
|
||||
(let ((res (company--capf-completions prefix suffix table)))
|
||||
(setq company-etags--boundaries
|
||||
(company--capf-boundaries-markers
|
||||
(assoc-default :boundaries res)
|
||||
company-etags--boundaries))
|
||||
(assoc-default :completions res))
|
||||
(all-completions prefix table)))))
|
||||
|
||||
(defun company-etags--table ()
|
||||
(let ((tags-table-list (company-etags-buffer-table))
|
||||
(tags-file-name tags-file-name)
|
||||
(completion-ignore-case company-etags-ignore-case))
|
||||
(tags-file-name tags-file-name))
|
||||
(and (or tags-file-name tags-table-list)
|
||||
(fboundp 'tags-completion-table)
|
||||
(save-excursion
|
||||
(visit-tags-table-buffer)
|
||||
(all-completions prefix (tags-completion-table))))))
|
||||
(tags-completion-table)))))
|
||||
|
||||
(defun company-etags--expand-common (prefix suffix)
|
||||
(when company-etags-completion-styles
|
||||
(let ((completion-styles (if (listp company-etags-completion-styles)
|
||||
company-etags-completion-styles
|
||||
completion-styles)))
|
||||
(company--capf-expand-common prefix suffix
|
||||
(company-etags--table)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun company-etags (command &optional arg &rest ignored)
|
||||
(defun company-etags (command &optional arg &rest rest)
|
||||
"`company-mode' completion backend for etags."
|
||||
(interactive (list 'interactive))
|
||||
(cl-case command
|
||||
(interactive (company-begin-backend 'company-etags))
|
||||
(prefix (and (apply #'derived-mode-p company-etags-modes)
|
||||
(prefix (and (cl-some #'derived-mode-p company-etags-modes)
|
||||
(or (eq t company-etags-everywhere)
|
||||
(apply #'derived-mode-p company-etags-everywhere)
|
||||
(cl-some #'derived-mode-p company-etags-everywhere)
|
||||
(not (company-in-string-or-comment)))
|
||||
(company-etags-buffer-table)
|
||||
(or (company-grab-symbol) 'stop)))
|
||||
(candidates (company-etags--candidates arg))
|
||||
(company-grab-symbol-parts)))
|
||||
(candidates (company-etags--candidates arg (car rest)))
|
||||
(adjust-boundaries (and company-etags-completion-styles
|
||||
(company--capf-boundaries
|
||||
company-etags--boundaries)))
|
||||
(expand-common (company-etags--expand-common arg (car rest)))
|
||||
(no-cache company-etags-completion-styles)
|
||||
(location (let ((tags-table-list (company-etags-buffer-table)))
|
||||
(when (fboundp 'find-tag-noselect)
|
||||
(save-excursion
|
||||
(let ((buffer (find-tag-noselect arg)))
|
||||
(cons buffer (with-current-buffer buffer (point))))))))
|
||||
(match (when company-etags-completion-styles
|
||||
(company--match-from-capf-face arg)))
|
||||
(ignore-case company-etags-ignore-case)))
|
||||
|
||||
(provide 'company-etags)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
;;; company-files.el --- company-mode completion backend for file names
|
||||
;;; company-files.el --- company-mode completion backend for file names -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2009-2011, 2013-2021 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2009-2011, 2013-2024 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Nikolaj Schumacher
|
||||
|
||||
@@ -38,22 +38,14 @@ The values should use the same format as `completion-ignored-extensions'."
|
||||
:type '(repeat (string :tag "File extension or directory name"))
|
||||
:package-version '(company . "0.9.1"))
|
||||
|
||||
(defcustom company-files-chop-trailing-slash t
|
||||
"Non-nil to remove the trailing slash after inserting directory name.
|
||||
|
||||
This way it's easy to continue completion by typing `/' again.
|
||||
|
||||
Set this to nil to disable that behavior."
|
||||
:type 'boolean)
|
||||
|
||||
(defun company-files--directory-files (dir prefix)
|
||||
;; Don't use directory-files. It produces directories without trailing /.
|
||||
(condition-case err
|
||||
(condition-case _err
|
||||
(let ((comp (sort (file-name-all-completions prefix dir)
|
||||
(lambda (s1 s2) (string-lessp (downcase s1) (downcase s2))))))
|
||||
(when company-files-exclusions
|
||||
(setq comp (company-files--exclusions-filtered comp)))
|
||||
(if (equal prefix "")
|
||||
(if (string-empty-p prefix)
|
||||
(delete "../" (delete "./" comp))
|
||||
comp))
|
||||
(file-error nil)))
|
||||
@@ -105,54 +97,58 @@ Set this to nil to disable that behavior."
|
||||
|
||||
(defvar company-files--completion-cache nil)
|
||||
|
||||
(defun company-files--complete (prefix)
|
||||
(let* ((dir (file-name-directory prefix))
|
||||
(file (file-name-nondirectory prefix))
|
||||
(defun company-files--complete (_prefix)
|
||||
(let* ((full-prefix (company-files--grab-existing-name))
|
||||
(dir (file-name-directory full-prefix))
|
||||
(file (file-name-nondirectory full-prefix))
|
||||
(key (list file
|
||||
(expand-file-name dir)
|
||||
(nth 5 (file-attributes dir))))
|
||||
(completion-ignore-case read-file-name-completion-ignore-case))
|
||||
(unless (company-file--keys-match-p key (car company-files--completion-cache))
|
||||
(let* ((candidates (mapcar (lambda (f) (concat dir f))
|
||||
(company-files--directory-files dir file)))
|
||||
(unless (or (company-file--keys-match-p key (car company-files--completion-cache))
|
||||
(not (company-files--connected-p dir)))
|
||||
(let* ((candidates (company-files--directory-files dir file))
|
||||
(directories (unless (file-remote-p dir)
|
||||
(cl-remove-if-not (lambda (f)
|
||||
(and (company-files--trailing-slash-p f)
|
||||
(not (file-remote-p f))
|
||||
(company-files--connected-p f)))
|
||||
(company-files--trailing-slash-p f))
|
||||
candidates)))
|
||||
(children (and directories
|
||||
(cl-mapcan (lambda (d)
|
||||
(mapcar (lambda (c) (concat d c))
|
||||
(company-files--directory-files d "")))
|
||||
(company-files--directory-files d ""))
|
||||
directories))))
|
||||
(setq company-files--completion-cache
|
||||
(cons key (append candidates children)))))
|
||||
(all-completions prefix
|
||||
(cdr company-files--completion-cache))))
|
||||
(all-completions file (cdr company-files--completion-cache))))
|
||||
|
||||
(defun company-files--prefix ()
|
||||
(let ((existing (company-files--grab-existing-name)))
|
||||
(when existing
|
||||
(list existing (company-grab-suffix "[^ '\"\t\n\r/]*/?")))))
|
||||
|
||||
(defun company-file--keys-match-p (new old)
|
||||
(and (equal (cdr old) (cdr new))
|
||||
(string-prefix-p (car old) (car new))))
|
||||
|
||||
(defun company-files--post-completion (arg)
|
||||
(when (and company-files-chop-trailing-slash
|
||||
(company-files--trailing-slash-p arg))
|
||||
(delete-char -1)))
|
||||
(defun company-files--adjust-boundaries (_file prefix suffix)
|
||||
(cons
|
||||
(file-name-nondirectory prefix)
|
||||
suffix))
|
||||
|
||||
;;;###autoload
|
||||
(defun company-files (command &optional arg &rest ignored)
|
||||
(defun company-files (command &optional arg &rest rest)
|
||||
"`company-mode' completion backend existing file names.
|
||||
Completions works for proper absolute and relative files paths.
|
||||
File paths with spaces are only supported inside strings."
|
||||
(interactive (list 'interactive))
|
||||
(cl-case command
|
||||
(interactive (company-begin-backend 'company-files))
|
||||
(prefix (company-files--grab-existing-name))
|
||||
(candidates (company-files--complete arg))
|
||||
(prefix (company-files--prefix))
|
||||
(candidates
|
||||
(company-files--complete arg))
|
||||
(adjust-boundaries
|
||||
(company-files--adjust-boundaries arg (nth 0 rest) (nth 1 rest)))
|
||||
(location (cons (dired-noselect
|
||||
(file-name-directory (directory-file-name arg))) 1))
|
||||
(post-completion (company-files--post-completion arg))
|
||||
(kind (if (string-suffix-p "/" arg) 'folder 'file))
|
||||
(sorted t)
|
||||
(no-cache t)))
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
;;; company-gtags.el --- company-mode completion backend for GNU Global
|
||||
;;; company-gtags.el --- company-mode completion backend for GNU Global -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2009-2011, 2013-2021 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2009-2011, 2013-2021, 2023 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Nikolaj Schumacher
|
||||
|
||||
@@ -97,7 +97,6 @@ completion."
|
||||
|
||||
(defun company-gtags--fetch-tags (prefix)
|
||||
(with-temp-buffer
|
||||
(let (tags)
|
||||
;; For some reason Global v 6.6.3 is prone to returning exit status 1
|
||||
;; even on successful searches when '-T' is used.
|
||||
(when (/= 3 (process-file (company-gtags--executable) nil
|
||||
@@ -118,7 +117,7 @@ completion."
|
||||
'meta (match-string 4)
|
||||
'location (cons (expand-file-name (match-string 3))
|
||||
(string-to-number (match-string 2)))
|
||||
))))))
|
||||
)))))
|
||||
|
||||
(defun company-gtags--annotation (arg)
|
||||
(let ((meta (get-text-property 0 'meta arg)))
|
||||
@@ -135,14 +134,14 @@ completion."
|
||||
start (point)))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun company-gtags (command &optional arg &rest ignored)
|
||||
(defun company-gtags (command &optional arg &rest _ignored)
|
||||
"`company-mode' completion backend for GNU Global."
|
||||
(interactive (list 'interactive))
|
||||
(cl-case command
|
||||
(interactive (company-begin-backend 'company-gtags))
|
||||
(prefix (and (company-gtags--executable)
|
||||
buffer-file-name
|
||||
(apply #'derived-mode-p company-gtags-modes)
|
||||
(cl-some #'derived-mode-p company-gtags-modes)
|
||||
(not (company-in-string-or-comment))
|
||||
(company-gtags--tags-available-p)
|
||||
(or (company-grab-symbol) 'stop)))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
;;; company-ispell.el --- company-mode completion backend using Ispell
|
||||
;;; company-ispell.el --- company-mode completion backend using Ispell -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2009-2011, 2013-2016, 2018, 2021, 2023 Free Software Foundation, Inc.
|
||||
|
||||
@@ -39,7 +39,8 @@
|
||||
|
||||
(defcustom company-ispell-dictionary nil
|
||||
"Dictionary to use for `company-ispell'.
|
||||
If nil, use `ispell-complete-word-dict'."
|
||||
|
||||
If nil, use `ispell-complete-word-dict' or `ispell-alternate-dictionary'."
|
||||
:type '(choice (const :tag "default (nil)" nil)
|
||||
(file :tag "dictionary" t))
|
||||
:set #'company--set-dictionary)
|
||||
@@ -58,18 +59,23 @@ If nil, use `ispell-complete-word-dict'."
|
||||
company-ispell-available)
|
||||
|
||||
(defun company--ispell-dict ()
|
||||
(or company-ispell-dictionary
|
||||
ispell-complete-word-dict
|
||||
ispell-alternate-dictionary))
|
||||
"Determine which dictionary to use."
|
||||
(let ((dict (or company-ispell-dictionary
|
||||
ispell-complete-word-dict
|
||||
ispell-alternate-dictionary)))
|
||||
(when dict
|
||||
(expand-file-name dict))))
|
||||
|
||||
;;;###autoload
|
||||
(defun company-ispell (command &optional arg &rest ignored)
|
||||
(defun company-ispell (command &optional arg &rest _ignored)
|
||||
"`company-mode' completion backend using Ispell."
|
||||
(interactive (list 'interactive))
|
||||
(cl-case command
|
||||
(interactive (company-begin-backend 'company-ispell))
|
||||
(prefix (when (company-ispell-available)
|
||||
(company-grab-word)))
|
||||
(list
|
||||
(company-grab-word)
|
||||
(company-grab-word-suffix))))
|
||||
(candidates
|
||||
(let* ((dict (company--ispell-dict))
|
||||
(all-words
|
||||
@@ -77,7 +83,7 @@ If nil, use `ispell-complete-word-dict'."
|
||||
(lambda () (ispell-lookup-words "" dict))
|
||||
:check-tag dict))
|
||||
(completion-ignore-case t))
|
||||
(if (string= arg "")
|
||||
(if (string-empty-p arg)
|
||||
;; Small optimization.
|
||||
all-words
|
||||
(company-substitute-prefix
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
;;; company-keywords.el --- A company backend for programming language keywords
|
||||
;;; company-keywords.el --- A company backend for programming language keywords -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2009-2011, 2013-2018, 2020-2022 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2009-2011, 2013-2018, 2020-2023 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Nikolaj Schumacher
|
||||
|
||||
@@ -403,7 +403,21 @@
|
||||
"i16" "i32" "i64" "include" "list" "map" "oneway" "optional" "required"
|
||||
"service" "set" "string" "struct" "throws" "typedef" "void"
|
||||
)
|
||||
(tuareg-mode
|
||||
;; ocaml, from https://v2.ocaml.org/manual/lex.html#sss:keywords
|
||||
"and" "as" "asr" "assert" "begin" "class"
|
||||
"constraint" "do" "done" "downto" "else" "end"
|
||||
"exception" "external" "false" "for" "fun" "function"
|
||||
"functor" "if" "in" "include" "inherit" "initializer"
|
||||
"land" "lazy" "let" "lor" "lsl" "lsr"
|
||||
"lxor" "match" "method" "mod" "module" "mutable"
|
||||
"new" "nonrec" "object" "of" "open" "or"
|
||||
"private" "rec" "sig" "struct" "then" "to"
|
||||
"true" "try" "type" "val" "virtual" "when"
|
||||
"while" "with"
|
||||
)
|
||||
;; aliases
|
||||
(caml-mode . tuareg-mode)
|
||||
(js2-mode . javascript-mode)
|
||||
(js2-jsx-mode . javascript-mode)
|
||||
(espresso-mode . javascript-mode)
|
||||
@@ -413,6 +427,7 @@
|
||||
(cperl-mode . perl-mode)
|
||||
(jde-mode . java-mode)
|
||||
(ess-julia-mode . julia-mode)
|
||||
(php-ts-mode . php-mode)
|
||||
(phps-mode . php-mode)
|
||||
(enh-ruby-mode . ruby-mode))
|
||||
"Alist mapping major-modes to sorted keywords for `company-keywords'.")
|
||||
@@ -439,7 +454,7 @@
|
||||
(makefile-mode . makefile-statements))))
|
||||
|
||||
;;;###autoload
|
||||
(defun company-keywords (command &optional arg &rest ignored)
|
||||
(defun company-keywords (command &optional arg &rest _ignored)
|
||||
"`company-mode' backend for programming language keywords."
|
||||
(interactive (list 'interactive))
|
||||
(cl-case command
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
;;; company-nxml.el --- company-mode completion backend for nxml-mode
|
||||
;;; company-nxml.el --- company-mode completion backend for nxml-mode -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2009-2011, 2013-2015, 2017-2018 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2009-2011, 2013-2015, 2017-2018, 2023 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Nikolaj Schumacher
|
||||
|
||||
@@ -71,12 +71,11 @@
|
||||
|
||||
(defmacro company-nxml-prepared (&rest body)
|
||||
(declare (indent 0) (debug t))
|
||||
`(let ((lt-pos (save-excursion (search-backward "<" nil t)))
|
||||
xmltok-dtd)
|
||||
`(let ((lt-pos (save-excursion (search-backward "<" nil t))))
|
||||
(when (and lt-pos (= (rng-set-state-after lt-pos) lt-pos))
|
||||
,@body)))
|
||||
|
||||
(defun company-nxml-tag (command &optional arg &rest ignored)
|
||||
(defun company-nxml-tag (command &optional arg &rest _ignored)
|
||||
(cl-case command
|
||||
(prefix (and (derived-mode-p 'nxml-mode)
|
||||
rng-validate-mode
|
||||
@@ -86,7 +85,7 @@
|
||||
arg (rng-match-possible-start-tag-names))))
|
||||
(sorted t)))
|
||||
|
||||
(defun company-nxml-attribute (command &optional arg &rest ignored)
|
||||
(defun company-nxml-attribute (command &optional arg &rest _ignored)
|
||||
(cl-case command
|
||||
(prefix (and (derived-mode-p 'nxml-mode)
|
||||
rng-validate-mode
|
||||
@@ -99,7 +98,7 @@
|
||||
arg (rng-match-possible-attribute-names)))))
|
||||
(sorted t)))
|
||||
|
||||
(defun company-nxml-attribute-value (command &optional arg &rest ignored)
|
||||
(defun company-nxml-attribute-value (command &optional arg &rest _ignored)
|
||||
(cl-case command
|
||||
(prefix (and (derived-mode-p 'nxml-mode)
|
||||
rng-validate-mode
|
||||
@@ -121,7 +120,7 @@
|
||||
arg (rng-match-possible-value-strings))))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun company-nxml (command &optional arg &rest ignored)
|
||||
(defun company-nxml (command &optional arg &rest _ignored)
|
||||
"`company-mode' completion backend for `nxml-mode'."
|
||||
(interactive (list 'interactive))
|
||||
(cl-case command
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
;;; company-oddmuse.el --- company-mode completion backend for oddmuse-mode
|
||||
;;; company-oddmuse.el --- company-mode completion backend for oddmuse-mode -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2009-2011, 2013-2016, 2022 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2009-2011, 2013-2016, 2022, 2023 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Nikolaj Schumacher
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
(oddmuse-make-completion-table oddmuse-wiki)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun company-oddmuse (command &optional arg &rest ignored)
|
||||
(defun company-oddmuse (command &optional arg &rest _ignored)
|
||||
"`company-mode' completion backend for `oddmuse-mode'."
|
||||
(interactive (list 'interactive))
|
||||
(cl-case command
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
(define-package "company" "20231023.1033" "Modular text completion framework"
|
||||
'((emacs "25.1"))
|
||||
:commit "66201465a962ac003f320a1df612641b2b276ab5" :maintainers
|
||||
(define-package "company" "20250223.352" "Modular text completion framework"
|
||||
'((emacs "26.1"))
|
||||
:commit "5bb6f6d3d44ed919378e6968a06feed442165545" :maintainers
|
||||
'(("Dmitry Gutov" . "dmitry@gutov.dev"))
|
||||
:maintainer
|
||||
'("Dmitry Gutov" . "dmitry@gutov.dev")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
;;; company-semantic.el --- company-mode completion backend using Semantic
|
||||
;;; company-semantic.el --- company-mode completion backend using Semantic -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2009-2011, 2013-2018 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2009-2011, 2013-2018, 2023 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Nikolaj Schumacher
|
||||
|
||||
@@ -126,11 +126,11 @@ and `c-electric-colon', for automatic completion right after \">\" and
|
||||
|
||||
(defun company-semantic--prefix ()
|
||||
(if company-semantic-begin-after-member-access
|
||||
(company-grab-symbol-cons "\\.\\|->\\|::" 2)
|
||||
(company-grab-symbol)))
|
||||
(company-grab-symbol-parts "\\.\\|->\\|::" 2)
|
||||
(company-grab-symbol-parts)))
|
||||
|
||||
;;;###autoload
|
||||
(defun company-semantic (command &optional arg &rest ignored)
|
||||
(defun company-semantic (command &optional arg &rest _ignored)
|
||||
"`company-mode' completion backend using CEDET Semantic."
|
||||
(interactive (list 'interactive))
|
||||
(cl-case command
|
||||
@@ -140,7 +140,7 @@ and `c-electric-colon', for automatic completion right after \">\" and
|
||||
(memq major-mode company-semantic-modes)
|
||||
(not (company-in-string-or-comment))
|
||||
(or (company-semantic--prefix) 'stop)))
|
||||
(candidates (if (and (equal arg "")
|
||||
(candidates (if (and (string-empty-p arg)
|
||||
(not (looking-back "->\\|\\.\\|::" (- (point) 2))))
|
||||
(company-semantic-completions-raw arg)
|
||||
(company-semantic-completions arg)))
|
||||
@@ -151,7 +151,7 @@ and `c-electric-colon', for automatic completion right after \">\" and
|
||||
(doc-buffer (company-semantic-doc-buffer
|
||||
(assoc arg company-semantic--current-tags)))
|
||||
;; Because "" is an empty context and doesn't return local variables.
|
||||
(no-cache (equal arg ""))
|
||||
(no-cache (string-empty-p arg))
|
||||
(duplicates t)
|
||||
(location (let ((tag (assoc arg company-semantic--current-tags)))
|
||||
(when (buffer-live-p (semantic-tag-buffer tag))
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
;;; company-template.el --- utility library for template expansion
|
||||
;;; company-template.el --- utility library for template expansion -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2009-2010, 2013-2017, 2019 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2009-2010, 2013-2017, 2019, 2023-2024 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Nikolaj Schumacher
|
||||
|
||||
@@ -205,6 +205,7 @@ after deleting a field in `company-template-remove-field'."
|
||||
(let* ((end (point-marker))
|
||||
(beg (- (point) (length call)))
|
||||
(templ (company-template-declare-template beg end))
|
||||
forward-sexp-function
|
||||
paren-open paren-close)
|
||||
(with-syntax-table (make-syntax-table (syntax-table))
|
||||
(modify-syntax-entry ?< "(")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
;;; company-tempo.el --- company-mode completion backend for tempo
|
||||
;;; company-tempo.el --- company-mode completion backend for tempo -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2009-2011, 2013-2016 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2009-2011, 2013-2016, 2023 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Nikolaj Schumacher
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
(car (split-string doc "\n" t)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun company-tempo (command &optional arg &rest ignored)
|
||||
(defun company-tempo (command &optional arg &rest _ignored)
|
||||
"`company-mode' completion backend for tempo."
|
||||
(interactive (list 'interactive))
|
||||
(cl-case command
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
;;; company-tng.el --- company-mode configuration for single-button interaction
|
||||
;;; company-tng.el --- company-mode configuration for single-button interaction -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2017-2021 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2017-2024 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Nikita Leshenko
|
||||
|
||||
@@ -111,7 +111,7 @@ confirm the selection and finish the completion."
|
||||
(let* ((ov company-tng--overlay)
|
||||
(selected (and company-selection
|
||||
(nth company-selection company-candidates)))
|
||||
(prefix (length company-prefix)))
|
||||
(prefix (length (car (company--boundaries)))))
|
||||
(move-overlay ov (- (point) prefix) (point))
|
||||
(overlay-put ov
|
||||
(if (= prefix 0) 'after-string 'display)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
;;; company-yasnippet.el --- company-mode completion backend for Yasnippet
|
||||
;;; company-yasnippet.el --- company-mode completion backend for Yasnippet -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2014-2015, 2020-2022 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2014-2015, 2020-2023 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Dmitry Gutov
|
||||
|
||||
@@ -72,7 +72,7 @@ It has to accept one argument: the snippet's name.")
|
||||
(let ((prefix (buffer-substring-no-properties (point) original)))
|
||||
(unless (equal prefix (car prefixes))
|
||||
(push prefix prefixes))))
|
||||
prefixes)))
|
||||
(nreverse prefixes))))
|
||||
|
||||
(defun company-yasnippet--candidates (prefix)
|
||||
;; Process the prefixes in reverse: unlike Yasnippet, we look for prefix
|
||||
@@ -135,8 +135,24 @@ It has to accept one argument: the snippet's name.")
|
||||
(ignore-errors (font-lock-ensure))))
|
||||
(current-buffer))))
|
||||
|
||||
(defun company-yasnippet--prefix ()
|
||||
;; We can avoid the prefix length manipulations after GH#426 is fixed.
|
||||
(let* ((prefix (company-grab-symbol))
|
||||
(tables (yas--get-snippet-tables))
|
||||
(key-prefixes (company-yasnippet--key-prefixes))
|
||||
key-prefix)
|
||||
(while (and key-prefixes
|
||||
(setq key-prefix (pop key-prefixes)))
|
||||
(when (company-yasnippet--completions-for-prefix
|
||||
prefix key-prefix tables)
|
||||
;; Stop iteration.
|
||||
(setq key-prefixes nil)))
|
||||
(if (equal key-prefix prefix)
|
||||
prefix
|
||||
(cons prefix (length key-prefix)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun company-yasnippet (command &optional arg &rest ignore)
|
||||
(defun company-yasnippet (command &optional arg &rest _ignore)
|
||||
"`company-mode' backend for `yasnippet'.
|
||||
|
||||
This backend should be used with care, because as long as there are
|
||||
@@ -163,10 +179,8 @@ shadow backends that come after it. Recommended usages:
|
||||
(cl-case command
|
||||
(interactive (company-begin-backend 'company-yasnippet))
|
||||
(prefix
|
||||
;; Should probably use `yas--current-key', but that's bound to be slower.
|
||||
;; How many trigger keys start with non-symbol characters anyway?
|
||||
(and (bound-and-true-p yas-minor-mode)
|
||||
(company-grab-symbol)))
|
||||
(company-yasnippet--prefix)))
|
||||
(annotation
|
||||
(funcall company-yasnippet-annotation-fn
|
||||
(get-text-property 0 'yas-annotation arg)))
|
||||
|
||||
+931
-311
File diff suppressed because it is too large
Load Diff
+323
-207
@@ -1,9 +1,10 @@
|
||||
This is company.info, produced by makeinfo version 6.8 from
|
||||
company.texi.
|
||||
|
||||
This user manual is for Company version 0.10.0 (16 April 2023).
|
||||
This user manual is for Company version 1.0.3-snapshot
|
||||
(7 December 2024).
|
||||
|
||||
Copyright © 2021-2023 Free Software Foundation, Inc.
|
||||
Copyright © 2021-2024 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this
|
||||
document under the terms of the GNU Free Documentation License,
|
||||
@@ -26,9 +27,10 @@ The goal of this document is to lay out the foundational knowledge of
|
||||
the package, so that the readers of the manual could competently start
|
||||
adapting Company to their needs and preferences.
|
||||
|
||||
This user manual is for Company version 0.10.0 (16 April 2023).
|
||||
This user manual is for Company version 1.0.3-snapshot
|
||||
(7 December 2024).
|
||||
|
||||
Copyright © 2021-2023 Free Software Foundation, Inc.
|
||||
Copyright © 2021-2024 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this
|
||||
document under the terms of the GNU Free Documentation License,
|
||||
@@ -104,7 +106,7 @@ File: company.info, Node: Terminology, Next: Structure, Up: Overview
|
||||
1.1 Terminology
|
||||
===============
|
||||
|
||||
“Completion” is an act of intelligibly guessing possible variants of
|
||||
“Completion” is an act of intelligently guessing possible variants of
|
||||
words based on already typed characters. To “complete” a word means to
|
||||
insert a correctly guessed variant into the buffer.
|
||||
|
||||
@@ -112,20 +114,19 @@ Consequently, the “candidates” are the aforementioned guessed variants
|
||||
of words. Each of the candidates has the potential to be chosen for
|
||||
successful completion. And each of the candidates contains the
|
||||
initially typed characters: either only at the beginning (so-called
|
||||
“prefix matches”), or also inside (“non-prefix matches”) of a candidate
|
||||
(1).
|
||||
“prefix matches”), or also inside of a candidate (“non-prefix matches”).
|
||||
Which matching method is used, depends on the current _backend_ (*note
|
||||
Structure::). ‘company-capf’ is an example of a backend that supports a
|
||||
number of particular non-prefix matching algorithms which are
|
||||
configurable through the user option ‘completion-styles’, which see.
|
||||
For illustrations on how Company visualizes the matches, *note
|
||||
Frontends::.
|
||||
|
||||
The package’s name “Company” is based on the combination of the two
|
||||
The package’s name ‘Company’ is based on the combination of the two
|
||||
words: ‘Complete’ and ‘Anything’. These words reflect the package’s
|
||||
commitment to handling completion candidates and its extensible nature
|
||||
allowing it to cover a wide range of usage scenarios.
|
||||
|
||||
---------- Footnotes ----------
|
||||
|
||||
(1) A good starting point to learn about types of matches is to play
|
||||
with the Emacs’s user option ‘completion-styles’. For illustrations on
|
||||
how Company visualizes the matches, *note Frontends::.
|
||||
|
||||
|
||||
File: company.info, Node: Structure, Prev: Terminology, Up: Overview
|
||||
|
||||
@@ -137,11 +138,11 @@ are pluggable modules: backends (*note Backends::) and frontends (*note
|
||||
Frontends::).
|
||||
|
||||
The “backends” are responsible for retrieving completion candidates;
|
||||
which are then outputted by the “frontends”. For an easy and quick
|
||||
which are then displayed by the “frontends”. For an easy and quick
|
||||
initial setup, Company is supplied with the preconfigured sets of the
|
||||
backends and frontends. The default behavior of the modules can be
|
||||
adjusted per particular needs, goals, and preferences. It is also
|
||||
typical to utilize backends from a variety of third-party libraries
|
||||
adjusted for particular needs, and preferences. It is also typical to
|
||||
utilize backends from a variety of third-party libraries
|
||||
(https://github.com/company-mode/company-mode/wiki/Third-Party-Packages),
|
||||
developed to be pluggable with Company.
|
||||
|
||||
@@ -149,7 +150,7 @@ But Company consists not only of the backends and frontends.
|
||||
|
||||
A core of the package plays the role of a controller, connecting the
|
||||
modules, making them work together; and exposing configurations and
|
||||
commands for a user to operate with. For more details, *note
|
||||
commands for the user to operate with. For more details, *note
|
||||
Customization:: and *note Commands::.
|
||||
|
||||
Also, Company is bundled with an alternative workflow configuration
|
||||
@@ -202,7 +203,7 @@ indicator ‘company’.
|
||||
|
||||
After _company-mode_ had been enabled, the package auto-starts
|
||||
suggesting completion candidates. The candidates are retrieved and
|
||||
shown according to the typed characters and the default (until a user
|
||||
shown according to the typed characters and the default (until the user
|
||||
specifies otherwise) configurations.
|
||||
|
||||
To have Company always enabled for the following sessions, add the line
|
||||
@@ -216,7 +217,7 @@ File: company.info, Node: Usage Basics, Next: Commands, Prev: Initial Setup,
|
||||
================
|
||||
|
||||
By default — having _company-mode_ enabled (*note Initial Setup::) — a
|
||||
tooltip with completion candidates is shown when a user types in a few
|
||||
tooltip with completion candidates is shown when the user types a few
|
||||
characters.
|
||||
|
||||
To initiate completion manually, use the command ‘M-x company-complete’.
|
||||
@@ -226,8 +227,11 @@ respectively key bindings ‘C-n’ and ‘C-p’, then do one of the following:
|
||||
|
||||
• Hit <RET> to choose a selected candidate for completion.
|
||||
|
||||
• Hit <TAB> to complete with the “common part”: characters present at
|
||||
the beginning of all the candidates.
|
||||
• Hit <TAB> to expand the “common part” of all completions. Exactly
|
||||
what that means, can vary by backend. In the simplest case it’s
|
||||
the longest string that all completion start with, but when a
|
||||
backend returns _non-prefix matches_, it can implement the same
|
||||
kind of expansion logic for the input string.
|
||||
|
||||
• Hit ‘C-g’ to stop activity of Company.
|
||||
|
||||
@@ -253,11 +257,15 @@ commands of the out-of-the-box Company.
|
||||
‘RET’
|
||||
‘<return>’
|
||||
Insert the selected candidate (‘company-complete-selection’).
|
||||
Restart completion if a new field is entered.
|
||||
|
||||
‘TAB’
|
||||
‘<tab>’
|
||||
Insert the common part of all the candidates
|
||||
(‘company-complete-common’).
|
||||
Insert the _common part_ of all completion candidates or — if no
|
||||
_common part_ is present — select the next candidate
|
||||
(‘company-complete-common-or-cycle’). In the latter case,
|
||||
wraparound is implicitly enabled (*note
|
||||
company-selection-wrap-around::).
|
||||
|
||||
‘C-g’
|
||||
‘<ESC ESC ESC>’
|
||||
@@ -285,17 +293,8 @@ illustrate how to assign key bindings to such commands.
|
||||
(global-set-key (kbd "<tab>") #'company-indent-or-complete-common)
|
||||
|
||||
(with-eval-after-load 'company
|
||||
(define-key company-active-map (kbd "M-/") #'company-complete))
|
||||
|
||||
(with-eval-after-load 'company
|
||||
(define-key company-active-map
|
||||
(kbd "TAB")
|
||||
#'company-complete-common-or-cycle)
|
||||
(define-key company-active-map
|
||||
(kbd "<backtab>")
|
||||
(lambda ()
|
||||
(interactive)
|
||||
(company-complete-common-or-cycle -1))))
|
||||
(define-key company-active-map (kbd "M-/") #'company-complete)
|
||||
(define-key company-active-map (kbd "C-M-/") #'company-complete-common))
|
||||
|
||||
In the same manner, an additional key can be assigned to a command or a
|
||||
command can be unbound from a key. For instance:
|
||||
@@ -350,7 +349,7 @@ File: company.info, Node: Configuration File, Prev: Customization Interface,
|
||||
======================
|
||||
|
||||
Company is a customization-rich package. This section lists some of the
|
||||
core settings that influence the overall behavior of the _company-mode_.
|
||||
core settings that influence its overall behavior.
|
||||
|
||||
-- User Option: company-minimum-prefix-length
|
||||
This is one of the values (together with ‘company-idle-delay’),
|
||||
@@ -374,6 +373,10 @@ core settings that influence the overall behavior of the _company-mode_.
|
||||
(setq company-idle-delay
|
||||
(lambda () (if (company-in-string-or-comment) nil 0.3)))
|
||||
|
||||
-- User Option: company-inhibit-inside-symbols
|
||||
You can set this option to ‘t’ to disable the auto-start behavior
|
||||
when in the middle of a symbol.
|
||||
|
||||
-- User Option: company-global-modes
|
||||
This option allows to specify in which major modes _company-mode_
|
||||
can be enabled by ‘(global-company-mode)’. *Note Initial Setup::.
|
||||
@@ -398,8 +401,8 @@ core settings that influence the overall behavior of the _company-mode_.
|
||||
To allow typing in characters that don’t match the candidates, set
|
||||
the value of this option to ‘nil’. For an opposite behavior (that
|
||||
is, to disallow non-matching input), set it to ‘t’. By default,
|
||||
Company is configured to require a matching input only if a user
|
||||
manually enables completion or selects a candidate; by having the
|
||||
Company is configured to require a matching input only if the user
|
||||
invokes completion manually or selects a candidate; by having the
|
||||
option configured to call the function ‘company-explicit-action-p’.
|
||||
|
||||
-- User Option: company-lighter-base
|
||||
@@ -575,12 +578,11 @@ user options.
|
||||
| ||||