Merge branch 'master' of gitlab.com:marcuskammer/emacs.d
This commit is contained in:
commit
1cd64ab707
1400 changed files with 3 additions and 458999 deletions
1
.bashrc
1
.bashrc
|
@ -31,3 +31,4 @@ export EDITOR="emacsclient -t" # $EDITOR opens in terminal
|
|||
|
||||
export TERM="screen-256color"
|
||||
test -s ~/.alias && . ~/.alias || true
|
||||
eval "$(direnv hook bash)"
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
'(package-enable-at-startup t)
|
||||
'(package-selected-packages
|
||||
(quote
|
||||
(dart-mode dart-server projectile python-django ivy elpy olivetti ace-window graphviz-dot-mode dot-mode plantuml-mode elisp-format elisp-lint flymake-racket google-translate org-pomodoro elm-mode dashboard pickle poet-theme flymake-eslint json-mode darkroom dockerfile-mode ein spacemacs-theme flucui-themes leuven-theme htmlize scss-mode berrys-theme web-mode python-docstring sphinx-doc sphinx-frontend sphinx-mode ox-nikola racket-mode slime gherkin-mode powershell typescript-mode ob-http ob-ipython ob-restclient nord-theme restclient request restclient-test yaml-mode magit)))
|
||||
(ob-dart dart-mode dart-server projectile python-django ivy elpy olivetti ace-window graphviz-dot-mode dot-mode plantuml-mode elisp-format elisp-lint flymake-racket google-translate org-pomodoro elm-mode dashboard pickle poet-theme flymake-eslint json-mode darkroom dockerfile-mode ein spacemacs-theme flucui-themes leuven-theme htmlize scss-mode berrys-theme web-mode python-docstring sphinx-doc sphinx-frontend sphinx-mode ox-nikola racket-mode slime gherkin-mode powershell typescript-mode ob-http ob-ipython ob-restclient nord-theme restclient request restclient-test yaml-mode magit)))
|
||||
'(python-shell-interpreter "python3")
|
||||
'(register-preview-delay 2)
|
||||
'(register-separator 43)
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
(display-time-mode -1) ; Display time in the mode line
|
||||
|
||||
(add-to-list 'default-frame-alist '(fullscreen . maximized)) ; Maximize Window
|
||||
(add-to-list 'default-frame-alist '(font . "Iosevka Term-13"))
|
||||
(add-to-list 'default-frame-alist '(font . "Iosevka Term Medium-13"))
|
||||
|
||||
(when (eq system-type 'gnu/linux)
|
||||
(add-to-list 'default-frame-alist '(undecorated . t)))
|
||||
|
|
|
@ -1,81 +0,0 @@
|
|||
;;; ace-window-autoloads.el --- automatically extracted autoloads
|
||||
;;
|
||||
;;; Code:
|
||||
|
||||
(add-to-list 'load-path (directory-file-name
|
||||
(or (file-name-directory #$) (car load-path))))
|
||||
|
||||
|
||||
;;;### (autoloads nil "ace-window" "ace-window.el" (0 0 0 0))
|
||||
;;; Generated autoloads from ace-window.el
|
||||
|
||||
(autoload 'ace-select-window "ace-window" "\
|
||||
Ace select window.
|
||||
|
||||
\(fn)" t nil)
|
||||
|
||||
(autoload 'ace-delete-window "ace-window" "\
|
||||
Ace delete window.
|
||||
|
||||
\(fn)" t nil)
|
||||
|
||||
(autoload 'ace-swap-window "ace-window" "\
|
||||
Ace swap window.
|
||||
|
||||
\(fn)" t nil)
|
||||
|
||||
(autoload 'ace-delete-other-windows "ace-window" "\
|
||||
Ace delete other windows.
|
||||
|
||||
\(fn)" t nil)
|
||||
|
||||
(autoload 'ace-display-buffer "ace-window" "\
|
||||
Make `display-buffer' and `pop-to-buffer' select using `ace-window'.
|
||||
See sample config for `display-buffer-base-action' and `display-buffer-alist':
|
||||
https://github.com/abo-abo/ace-window/wiki/display-buffer.
|
||||
|
||||
\(fn BUFFER ALIST)" nil nil)
|
||||
|
||||
(autoload 'ace-window "ace-window" "\
|
||||
Select a window.
|
||||
Perform an action based on ARG described below.
|
||||
|
||||
By default, behaves like extended `other-window'.
|
||||
See `aw-scope' which extends it to work with frames.
|
||||
|
||||
Prefixed with one \\[universal-argument], does a swap between the
|
||||
selected window and the current window, so that the selected
|
||||
buffer moves to current window (and current buffer moves to
|
||||
selected window).
|
||||
|
||||
Prefixed with two \\[universal-argument]'s, deletes the selected
|
||||
window.
|
||||
|
||||
\(fn ARG)" t nil)
|
||||
|
||||
(defvar ace-window-display-mode nil "\
|
||||
Non-nil if Ace-Window-Display mode is enabled.
|
||||
See the `ace-window-display-mode' command
|
||||
for a description of this minor mode.
|
||||
Setting this variable directly does not take effect;
|
||||
either customize it (see the info node `Easy Customization')
|
||||
or call the function `ace-window-display-mode'.")
|
||||
|
||||
(custom-autoload 'ace-window-display-mode "ace-window" nil)
|
||||
|
||||
(autoload 'ace-window-display-mode "ace-window" "\
|
||||
Minor mode for showing the ace window key in the mode line.
|
||||
|
||||
\(fn &optional ARG)" t nil)
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "ace-window" '("ace-window-mode" "aw-")))
|
||||
|
||||
;;;***
|
||||
|
||||
;; Local Variables:
|
||||
;; version-control: never
|
||||
;; no-byte-compile: t
|
||||
;; no-update-autoloads: t
|
||||
;; coding: utf-8
|
||||
;; End:
|
||||
;;; ace-window-autoloads.el ends here
|
|
@ -1,2 +0,0 @@
|
|||
;;; -*- no-byte-compile: t -*-
|
||||
(define-package "ace-window" "20200311.1025" "Quickly switch windows." '((avy "0.5.0")) :commit "7003c88cd9cad58dc35c7cd13ebc61c355fb5be7" :keywords '("window" "location") :authors '(("Oleh Krehel" . "ohwoeowho@gmail.com")) :maintainer '("Oleh Krehel" . "ohwoeowho@gmail.com") :url "https://github.com/abo-abo/ace-window")
|
|
@ -1,953 +0,0 @@
|
|||
;;; ace-window.el --- Quickly switch windows. -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2015-2020 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Oleh Krehel <ohwoeowho@gmail.com>
|
||||
;; Maintainer: Oleh Krehel <ohwoeowho@gmail.com>
|
||||
;; URL: https://github.com/abo-abo/ace-window
|
||||
;; Package-Version: 20200311.1025
|
||||
;; Version: 0.10.0
|
||||
;; Package-Requires: ((avy "0.5.0"))
|
||||
;; Keywords: window, location
|
||||
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;; This file is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 3, or (at your option)
|
||||
;; any later version.
|
||||
|
||||
;; This 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.
|
||||
|
||||
;; For a full copy of the GNU General Public License
|
||||
;; see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
;;
|
||||
;; The main function, `ace-window' is meant to replace `other-window'
|
||||
;; by assigning each window a short, unique label. When there are only
|
||||
;; two windows present, `other-window' is called (unless
|
||||
;; aw-dispatch-always is set non-nil). If there are more, each
|
||||
;; window will have its first label character highlighted. Once a
|
||||
;; unique label is typed, ace-window will switch to that window.
|
||||
;;
|
||||
;; To setup this package, just add to your .emacs:
|
||||
;;
|
||||
;; (global-set-key (kbd "M-o") 'ace-window)
|
||||
;;
|
||||
;; replacing "M-o" with an appropriate shortcut.
|
||||
;;
|
||||
;; By default, ace-window uses numbers for window labels so the window
|
||||
;; labeling is intuitively ordered. But if you prefer to type keys on
|
||||
;; your home row for quicker access, use this setting:
|
||||
;;
|
||||
;; (setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l))
|
||||
;;
|
||||
;; Whenever ace-window prompts for a window selection, it grays out
|
||||
;; all the window characters, highlighting window labels in red. To
|
||||
;; disable this behavior, set this:
|
||||
;;
|
||||
;; (setq aw-background nil)
|
||||
;;
|
||||
;; If you want to know the selection characters ahead of time, turn on
|
||||
;; `ace-window-display-mode'.
|
||||
;;
|
||||
;; When prefixed with one `universal-argument', instead of switching
|
||||
;; to the selected window, the selected window is swapped with the
|
||||
;; current one.
|
||||
;;
|
||||
;; When prefixed with two `universal-argument', the selected window is
|
||||
;; deleted instead.
|
||||
|
||||
;;; Code:
|
||||
(require 'avy)
|
||||
(require 'ring)
|
||||
(require 'subr-x)
|
||||
|
||||
;;* Customization
|
||||
(defgroup ace-window nil
|
||||
"Quickly switch current window."
|
||||
:group 'convenience
|
||||
:prefix "aw-")
|
||||
|
||||
(defcustom aw-keys '(?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9)
|
||||
"Keys for selecting window."
|
||||
:type '(repeat character))
|
||||
|
||||
(defcustom aw-scope 'global
|
||||
"The scope used by `ace-window'."
|
||||
:type '(choice
|
||||
(const :tag "visible frames" visible)
|
||||
(const :tag "global" global)
|
||||
(const :tag "frame" frame)))
|
||||
|
||||
(defcustom aw-translate-char-function #'identity
|
||||
"Function to translate user input key into another key.
|
||||
For example, to make SPC do the same as ?a, use
|
||||
\(lambda (c) (if (= c 32) ?a c))."
|
||||
:type '(choice
|
||||
(const :tag "Off" #'identity)
|
||||
(const :tag "Ignore Case" #'downcase)
|
||||
(function :tag "Custom")))
|
||||
|
||||
(defcustom aw-minibuffer-flag nil
|
||||
"When non-nil, also display `ace-window-mode' string in the minibuffer when ace-window is active."
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom aw-ignored-buffers '("*Calc Trail*" " *LV*")
|
||||
"List of buffers and major-modes to ignore when choosing a window from the window list.
|
||||
Active only when `aw-ignore-on' is non-nil."
|
||||
:type '(repeat string))
|
||||
|
||||
(defcustom aw-ignore-on t
|
||||
"When t, `ace-window' will ignore buffers and major-modes in `aw-ignored-buffers'.
|
||||
Use M-0 `ace-window' to toggle this value."
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom aw-ignore-current nil
|
||||
"When t, `ace-window' will ignore `selected-window'."
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom aw-background t
|
||||
"When t, `ace-window' will dim out all buffers temporarily when used."
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom aw-leading-char-style 'char
|
||||
"Style of the leading char overlay."
|
||||
:type '(choice
|
||||
(const :tag "single char" 'char)
|
||||
(const :tag "full path" 'path)))
|
||||
|
||||
(defcustom aw-dispatch-always nil
|
||||
"When non-nil, `ace-window' will issue a `read-char' even for one window.
|
||||
This will make `ace-window' act different from `other-window' for
|
||||
one or two windows."
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom aw-dispatch-when-more-than 2
|
||||
"If the number of windows is more than this, activate ace-window-ness."
|
||||
:type 'integer)
|
||||
|
||||
(defcustom aw-reverse-frame-list nil
|
||||
"When non-nil `ace-window' will order frames for selection in
|
||||
the reverse of `frame-list'"
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom aw-frame-offset '(13 . 23)
|
||||
"Increase in pixel offset for new ace-window frames relative to the selected frame.
|
||||
Its value is an (x-offset . y-offset) pair in pixels."
|
||||
:type '(cons integer integer))
|
||||
|
||||
(defcustom aw-frame-size nil
|
||||
"Frame size to make new ace-window frames.
|
||||
Its value is a (width . height) pair in pixels or nil for the default frame size.
|
||||
(0 . 0) is special and means make the frame size the same as the last selected frame size."
|
||||
:type '(cons integer integer))
|
||||
|
||||
(defcustom aw-char-position 'top-left
|
||||
"Window positions of the character overlay.
|
||||
Consider changing this if the overlay tends to overlap with other things."
|
||||
:type '(choice
|
||||
(const :tag "top left corner only" 'top-left)
|
||||
(const :tag "both left corners" 'left)))
|
||||
|
||||
;; Must be defined before `aw-make-frame-char' since its :set function references this.
|
||||
(defvar aw-dispatch-alist
|
||||
'((?x aw-delete-window "Delete Window")
|
||||
(?m aw-swap-window "Swap Windows")
|
||||
(?M aw-move-window "Move Window")
|
||||
(?c aw-copy-window "Copy Window")
|
||||
(?j aw-switch-buffer-in-window "Select Buffer")
|
||||
(?n aw-flip-window)
|
||||
(?u aw-switch-buffer-other-window "Switch Buffer Other Window")
|
||||
(?e aw-execute-command-other-window "Execute Command Other Window")
|
||||
(?F aw-split-window-fair "Split Fair Window")
|
||||
(?v aw-split-window-vert "Split Vert Window")
|
||||
(?b aw-split-window-horz "Split Horz Window")
|
||||
(?o delete-other-windows "Delete Other Windows")
|
||||
(?T aw-transpose-frame "Transpose Frame")
|
||||
;; ?i ?r ?t are used by hyperbole.el
|
||||
(?? aw-show-dispatch-help))
|
||||
"List of actions for `aw-dispatch-default'.
|
||||
Each action is a list of either:
|
||||
(char function description) where function takes a single window argument
|
||||
or
|
||||
(char function) where function takes no argument and the description is omitted.")
|
||||
|
||||
(defun aw-set-make-frame-char (option value)
|
||||
;; Signal an error if `aw-make-frame-char' is ever set to an invalid
|
||||
;; or conflicting value.
|
||||
(when value
|
||||
(cond ((not (characterp value))
|
||||
(user-error "`aw-make-frame-char' must be a character, not `%s'" value))
|
||||
((memq value aw-keys)
|
||||
(user-error "`aw-make-frame-char' is `%c'; this conflicts with the same character in `aw-keys'" value))
|
||||
((assq value aw-dispatch-alist)
|
||||
(user-error "`aw-make-frame-char' is `%c'; this conflicts with the same character in `aw-dispatch-alist'" value))))
|
||||
(set option value))
|
||||
|
||||
(defcustom aw-make-frame-char ?z
|
||||
"Non-existing ace window label character that triggers creation of a new single-window frame for display."
|
||||
:set 'aw-set-make-frame-char
|
||||
:type 'character)
|
||||
|
||||
(defface aw-leading-char-face
|
||||
'((((class color)) (:foreground "red"))
|
||||
(((background dark)) (:foreground "gray100"))
|
||||
(((background light)) (:foreground "gray0"))
|
||||
(t (:foreground "gray100" :underline nil)))
|
||||
"Face for each window's leading char.")
|
||||
|
||||
(defface aw-minibuffer-leading-char-face
|
||||
'((t :inherit aw-leading-char-face))
|
||||
"Face for minibuffer leading char.")
|
||||
|
||||
(defface aw-background-face
|
||||
'((t (:foreground "gray40")))
|
||||
"Face for whole window background during selection.")
|
||||
|
||||
(defface aw-mode-line-face
|
||||
'((t (:inherit mode-line-buffer-id)))
|
||||
"Face used for displaying the ace window key in the mode-line.")
|
||||
|
||||
(defface aw-key-face
|
||||
'((t :inherit font-lock-builtin-face))
|
||||
"Face used by `aw-show-dispatch-help'.")
|
||||
|
||||
;;* Implementation
|
||||
(defun aw-ignored-p (window)
|
||||
"Return t if WINDOW should be ignored when choosing from the window list."
|
||||
(or (and aw-ignore-on
|
||||
;; Ignore major-modes and buffer-names in `aw-ignored-buffers'.
|
||||
(or (memq (buffer-local-value 'major-mode (window-buffer window))
|
||||
aw-ignored-buffers)
|
||||
(member (buffer-name (window-buffer window)) aw-ignored-buffers)))
|
||||
;; ignore child frames
|
||||
(and (fboundp 'frame-parent) (frame-parent (window-frame window)))
|
||||
;; Ignore selected window if `aw-ignore-current' is non-nil.
|
||||
(and aw-ignore-current
|
||||
(equal window (selected-window)))
|
||||
;; When `ignore-window-parameters' is nil, ignore windows whose
|
||||
;; `no-other-window’ or `no-delete-other-windows' parameter is non-nil.
|
||||
(unless ignore-window-parameters
|
||||
(cl-case this-command
|
||||
(ace-select-window (window-parameter window 'no-other-window))
|
||||
(ace-delete-window (window-parameter window 'no-delete-other-windows))
|
||||
(ace-delete-other-windows (window-parameter
|
||||
window 'no-delete-other-windows))))))
|
||||
|
||||
(defun aw-window-list ()
|
||||
"Return the list of interesting windows."
|
||||
(sort
|
||||
(cl-remove-if
|
||||
(lambda (w)
|
||||
(let ((f (window-frame w)))
|
||||
(or (not (and (frame-live-p f)
|
||||
(frame-visible-p f)))
|
||||
(string= "initial_terminal" (terminal-name f))
|
||||
(aw-ignored-p w))))
|
||||
(cl-case aw-scope
|
||||
(visible
|
||||
(cl-mapcan #'window-list (visible-frame-list)))
|
||||
(global
|
||||
(cl-mapcan #'window-list (frame-list)))
|
||||
(frame
|
||||
(window-list))
|
||||
(t
|
||||
(error "Invalid `aw-scope': %S" aw-scope))))
|
||||
'aw-window<))
|
||||
|
||||
(defvar aw-overlays-back nil
|
||||
"Hold overlays for when `aw-background' is t.")
|
||||
|
||||
(defvar ace-window-mode nil
|
||||
"Minor mode during the selection process.")
|
||||
|
||||
;; register minor mode
|
||||
(or (assq 'ace-window-mode minor-mode-alist)
|
||||
(nconc minor-mode-alist
|
||||
(list '(ace-window-mode ace-window-mode))))
|
||||
|
||||
(defvar aw-empty-buffers-list nil
|
||||
"Store the read-only empty buffers which had to be modified.
|
||||
Modify them back eventually.")
|
||||
|
||||
(defvar aw--windows-hscroll nil
|
||||
"List of (window . hscroll-columns) items, each listing a window whose
|
||||
horizontal scroll will be restored upon ace-window action completion.")
|
||||
|
||||
(defvar aw--windows-points nil
|
||||
"List of (window . point) items. The point position had to be
|
||||
moved in order to display the overlay.")
|
||||
|
||||
(defun aw--done ()
|
||||
"Clean up mode line and overlays."
|
||||
;; mode line
|
||||
(aw-set-mode-line nil)
|
||||
;; background
|
||||
(mapc #'delete-overlay aw-overlays-back)
|
||||
(setq aw-overlays-back nil)
|
||||
(avy--remove-leading-chars)
|
||||
(dolist (b aw-empty-buffers-list)
|
||||
(with-current-buffer b
|
||||
(when (string= (buffer-string) " ")
|
||||
(let ((inhibit-read-only t))
|
||||
(delete-region (point-min) (point-max))))))
|
||||
(setq aw-empty-buffers-list nil)
|
||||
(aw--restore-windows-hscroll)
|
||||
(let (c)
|
||||
(while (setq c (pop aw--windows-points))
|
||||
(with-selected-window (car c)
|
||||
(goto-char (cdr c))))))
|
||||
|
||||
(defun aw--restore-windows-hscroll ()
|
||||
"Restore horizontal scroll of windows from `aw--windows-hscroll' list."
|
||||
(let (wnd hscroll)
|
||||
(mapc (lambda (wnd-and-hscroll)
|
||||
(setq wnd (car wnd-and-hscroll)
|
||||
hscroll (cdr wnd-and-hscroll))
|
||||
(when (window-live-p wnd)
|
||||
(set-window-hscroll wnd hscroll)))
|
||||
aw--windows-hscroll))
|
||||
(setq aw--windows-hscroll nil))
|
||||
|
||||
(defun aw--overlay-str (wnd pos path)
|
||||
"Return the replacement text for an overlay in WND at POS,
|
||||
accessible by typing PATH."
|
||||
(let ((old-str (or
|
||||
(ignore-errors
|
||||
(with-selected-window wnd
|
||||
(buffer-substring pos (1+ pos))))
|
||||
"")))
|
||||
(concat
|
||||
(cl-case aw-leading-char-style
|
||||
(char
|
||||
(string (avy--key-to-char (car (last path)))))
|
||||
(path
|
||||
(mapconcat
|
||||
(lambda (x) (string (avy--key-to-char x)))
|
||||
(reverse path)
|
||||
""))
|
||||
(t
|
||||
(error "Bad `aw-leading-char-style': %S"
|
||||
aw-leading-char-style)))
|
||||
(cond ((string-equal old-str "\t")
|
||||
(make-string (1- tab-width) ?\ ))
|
||||
((string-equal old-str "\n")
|
||||
"\n")
|
||||
(t
|
||||
(make-string
|
||||
(max 0 (1- (string-width old-str)))
|
||||
?\ ))))))
|
||||
|
||||
(defun aw--point-visible-p ()
|
||||
"Return non-nil if point is visible in the selected window.
|
||||
Return nil when horizontal scrolling has moved it off screen."
|
||||
(and (>= (- (current-column) (window-hscroll)) 0)
|
||||
(< (- (current-column) (window-hscroll))
|
||||
(window-width))))
|
||||
|
||||
(defun aw--lead-overlay (path leaf)
|
||||
"Create an overlay using PATH at LEAF.
|
||||
LEAF is (PT . WND)."
|
||||
;; Properly adds overlay in visible region of most windows except for any one
|
||||
;; receiving output while this function is executing, since that moves point,
|
||||
;; potentially shifting the added overlay outside the window's visible region.
|
||||
(let ((wnd (cdr leaf))
|
||||
;; Prevent temporary movement of point from scrolling any window.
|
||||
(scroll-margin 0))
|
||||
(with-selected-window wnd
|
||||
(when (= 0 (buffer-size))
|
||||
(push (current-buffer) aw-empty-buffers-list)
|
||||
(let ((inhibit-read-only t))
|
||||
(insert " ")))
|
||||
;; If point is not visible due to horizontal scrolling of the
|
||||
;; window, this next expression temporarily scrolls the window
|
||||
;; right until point is visible, so that the leading-char can be
|
||||
;; seen when it is inserted. When ace-window's action finishes,
|
||||
;; the horizontal scroll is restored by (aw--done).
|
||||
(while (and (not (aw--point-visible-p))
|
||||
(not (zerop (window-hscroll)))
|
||||
(progn (push (cons (selected-window) (window-hscroll)) aw--windows-hscroll) t)
|
||||
(not (zerop (scroll-right)))))
|
||||
(let* ((ws (window-start))
|
||||
(prev nil)
|
||||
(vertical-pos (if (eq aw-char-position 'left) -1 0))
|
||||
(horizontal-pos (if (zerop (window-hscroll)) 0 (1+ (window-hscroll))))
|
||||
(old-pt (point))
|
||||
(pt
|
||||
(progn
|
||||
;; If leading-char is to be displayed at the top-left, move
|
||||
;; to the first visible line in the window, otherwise, move
|
||||
;; to the last visible line.
|
||||
(move-to-window-line vertical-pos)
|
||||
(move-to-column horizontal-pos)
|
||||
;; Find a nearby point that is not at the end-of-line but
|
||||
;; is visible so have space for the overlay.
|
||||
(setq prev (1- (point)))
|
||||
(while (and (>= prev ws) (/= prev (point)) (eolp))
|
||||
(setq prev (point))
|
||||
(unless (bobp)
|
||||
(line-move -1 t)
|
||||
(move-to-column horizontal-pos)))
|
||||
(recenter vertical-pos)
|
||||
(point)))
|
||||
(ol (make-overlay pt (1+ pt) (window-buffer wnd))))
|
||||
(if (= (aw--face-rel-height) 1)
|
||||
(goto-char old-pt)
|
||||
(when (/= pt old-pt)
|
||||
(goto-char (+ pt 1))
|
||||
(push (cons wnd old-pt) aw--windows-points)))
|
||||
(overlay-put ol 'display (aw--overlay-str wnd pt path))
|
||||
(if (window-minibuffer-p wnd)
|
||||
(overlay-put ol 'face 'aw-minibuffer-leading-char-face)
|
||||
(overlay-put ol 'face 'aw-leading-char-face))
|
||||
(overlay-put ol 'window wnd)
|
||||
(push ol avy--overlays-lead)))))
|
||||
|
||||
(defun aw--make-backgrounds (wnd-list)
|
||||
"Create a dim background overlay for each window on WND-LIST."
|
||||
(when aw-background
|
||||
(setq aw-overlays-back
|
||||
(mapcar (lambda (w)
|
||||
(let ((ol (make-overlay
|
||||
(window-start w)
|
||||
(window-end w)
|
||||
(window-buffer w))))
|
||||
(overlay-put ol 'face 'aw-background-face)
|
||||
ol))
|
||||
wnd-list))))
|
||||
|
||||
(defvar aw-dispatch-function 'aw-dispatch-default
|
||||
"Function to call when a character not in `aw-keys' is pressed.")
|
||||
|
||||
(defvar aw-action nil
|
||||
"Function to call at the end of `aw-select'.")
|
||||
|
||||
(defun aw-set-mode-line (str)
|
||||
"Set mode line indicator to STR."
|
||||
(setq ace-window-mode str)
|
||||
(when (and aw-minibuffer-flag ace-window-mode)
|
||||
(message "%s" (string-trim-left str)))
|
||||
(force-mode-line-update))
|
||||
|
||||
(defun aw--dispatch-action (char)
|
||||
"Return item from `aw-dispatch-alist' matching CHAR."
|
||||
(assoc char aw-dispatch-alist))
|
||||
|
||||
(defun aw-make-frame ()
|
||||
"Make a new Emacs frame using the values of `aw-frame-size' and `aw-frame-offset'."
|
||||
(make-frame
|
||||
(delq nil
|
||||
(list
|
||||
;; This first parameter is important because an
|
||||
;; aw-dispatch-alist command may not want to leave this
|
||||
;; frame with input focus. If it is given focus, the
|
||||
;; command may not be able to return focus to a different
|
||||
;; frame since this is done asynchronously by the window
|
||||
;; manager.
|
||||
'(no-focus-on-map . t)
|
||||
(when aw-frame-size
|
||||
(cons 'width
|
||||
(if (zerop (car aw-frame-size))
|
||||
(frame-width)
|
||||
(car aw-frame-size))))
|
||||
(when aw-frame-size
|
||||
(cons 'height
|
||||
(if (zerop (cdr aw-frame-size))
|
||||
(frame-height)
|
||||
(car aw-frame-size))))
|
||||
(cons 'left (+ (car aw-frame-offset)
|
||||
(car (frame-position))))
|
||||
(cons 'top (+ (cdr aw-frame-offset)
|
||||
(cdr (frame-position))))))))
|
||||
|
||||
(defun aw-use-frame (window)
|
||||
"Create a new frame using the contents of WINDOW.
|
||||
|
||||
The new frame is set to the same size as the previous frame, offset by
|
||||
`aw-frame-offset' (x . y) pixels."
|
||||
(aw-switch-to-window window)
|
||||
(aw-make-frame))
|
||||
|
||||
(defun aw-clean-up-avy-current-path ()
|
||||
"Edit `avy-current-path' so only window label characters remain."
|
||||
;; Remove any possible ace-window command char that may
|
||||
;; precede the last specified window label, so
|
||||
;; functions can use `avy-current-path' as the chosen
|
||||
;; window label.
|
||||
(when (and (> (length avy-current-path) 0)
|
||||
(assq (aref avy-current-path 0) aw-dispatch-alist))
|
||||
(setq avy-current-path (substring avy-current-path 1))))
|
||||
|
||||
(defun aw-dispatch-default (char)
|
||||
"Perform an action depending on CHAR."
|
||||
(cond ((and (fboundp 'avy-mouse-event-window)
|
||||
(avy-mouse-event-window char)))
|
||||
((= char (aref (kbd "C-g") 0))
|
||||
(throw 'done 'exit))
|
||||
((and aw-make-frame-char (= char aw-make-frame-char))
|
||||
;; Make a new frame and perform any action on its window.
|
||||
(let ((start-win (selected-window))
|
||||
(end-win (frame-selected-window (aw-make-frame))))
|
||||
(if aw-action
|
||||
;; Action must be called from the start-win. The action
|
||||
;; determines which window to leave selected.
|
||||
(progn (select-frame-set-input-focus (window-frame start-win))
|
||||
(funcall aw-action end-win))
|
||||
;; Select end-win when no action
|
||||
(aw-switch-to-window end-win)))
|
||||
(throw 'done 'exit))
|
||||
(t
|
||||
(let ((action (aw--dispatch-action char)))
|
||||
(if action
|
||||
(cl-destructuring-bind (_key fn &optional description) action
|
||||
(if (and fn description)
|
||||
(prog1 (setq aw-action fn)
|
||||
(aw-set-mode-line (format " Ace - %s" description)))
|
||||
(if (commandp fn)
|
||||
(call-interactively fn)
|
||||
(funcall fn))
|
||||
(throw 'done 'exit)))
|
||||
(aw-clean-up-avy-current-path)
|
||||
;; Prevent any char from triggering an avy dispatch command.
|
||||
(let ((avy-dispatch-alist))
|
||||
(avy-handler-default char)))))))
|
||||
|
||||
(defcustom aw-display-mode-overlay t
|
||||
"When nil, don't display overlays. Rely on the mode line instead."
|
||||
:type 'boolean)
|
||||
|
||||
(defvar ace-window-display-mode)
|
||||
|
||||
(defun aw-select (mode-line &optional action)
|
||||
"Return a selected other window.
|
||||
Amend MODE-LINE to the mode line for the duration of the selection."
|
||||
(setq aw-action action)
|
||||
(let ((start-window (selected-window))
|
||||
(next-window-scope (cl-case aw-scope
|
||||
('visible 'visible)
|
||||
('global 'visible)
|
||||
('frame 'frame)))
|
||||
(wnd-list (aw-window-list))
|
||||
window)
|
||||
(setq window
|
||||
(cond ((<= (length wnd-list) 1)
|
||||
(when aw-dispatch-always
|
||||
(setq aw-action
|
||||
(unwind-protect
|
||||
(catch 'done
|
||||
(funcall aw-dispatch-function (read-char)))
|
||||
(aw--done)))
|
||||
(when (eq aw-action 'exit)
|
||||
(setq aw-action nil)))
|
||||
(or (car wnd-list) start-window))
|
||||
((and (<= (+ (length wnd-list) (if (aw-ignored-p start-window) 1 0))
|
||||
aw-dispatch-when-more-than)
|
||||
(not aw-dispatch-always)
|
||||
(not aw-ignore-current))
|
||||
(let ((wnd (next-window nil nil next-window-scope)))
|
||||
(while (and (or (not (memq wnd wnd-list))
|
||||
(aw-ignored-p wnd))
|
||||
(not (equal wnd start-window)))
|
||||
(setq wnd (next-window wnd nil next-window-scope)))
|
||||
wnd))
|
||||
(t
|
||||
(let ((candidate-list
|
||||
(mapcar (lambda (wnd)
|
||||
(cons (aw-offset wnd) wnd))
|
||||
wnd-list)))
|
||||
(aw--make-backgrounds wnd-list)
|
||||
(aw-set-mode-line mode-line)
|
||||
;; turn off helm transient map
|
||||
(remove-hook 'post-command-hook 'helm--maybe-update-keymap)
|
||||
(unwind-protect
|
||||
(let* ((avy-handler-function aw-dispatch-function)
|
||||
(avy-translate-char-function aw-translate-char-function)
|
||||
(transient-mark-mode nil)
|
||||
(res (avy-read (avy-tree candidate-list aw-keys)
|
||||
(if (and ace-window-display-mode
|
||||
(null aw-display-mode-overlay))
|
||||
(lambda (_path _leaf))
|
||||
#'aw--lead-overlay)
|
||||
#'avy--remove-leading-chars)))
|
||||
(if (eq res 'exit)
|
||||
(setq aw-action nil)
|
||||
(or (cdr res)
|
||||
start-window)))
|
||||
(aw--done))))))
|
||||
(if aw-action
|
||||
(funcall aw-action window)
|
||||
window)))
|
||||
|
||||
;;* Interactive
|
||||
;;;###autoload
|
||||
(defun ace-select-window ()
|
||||
"Ace select window."
|
||||
(interactive)
|
||||
(aw-select " Ace - Window"
|
||||
#'aw-switch-to-window))
|
||||
|
||||
;;;###autoload
|
||||
(defun ace-delete-window ()
|
||||
"Ace delete window."
|
||||
(interactive)
|
||||
(aw-select " Ace - Delete Window"
|
||||
#'aw-delete-window))
|
||||
|
||||
;;;###autoload
|
||||
(defun ace-swap-window ()
|
||||
"Ace swap window."
|
||||
(interactive)
|
||||
(aw-select " Ace - Swap Window"
|
||||
#'aw-swap-window))
|
||||
|
||||
;;;###autoload
|
||||
(defun ace-delete-other-windows ()
|
||||
"Ace delete other windows."
|
||||
(interactive)
|
||||
(aw-select " Ace - Delete Other Windows"
|
||||
#'delete-other-windows))
|
||||
|
||||
;;;###autoload
|
||||
(defun ace-display-buffer (buffer alist)
|
||||
"Make `display-buffer' and `pop-to-buffer' select using `ace-window'.
|
||||
See sample config for `display-buffer-base-action' and `display-buffer-alist':
|
||||
https://github.com/abo-abo/ace-window/wiki/display-buffer."
|
||||
(let* ((aw-ignore-current (cdr (assq 'inhibit-same-window alist)))
|
||||
(rf (cdr (assq 'reusable-frames alist)))
|
||||
(aw-scope (cl-case rf
|
||||
((nil) 'frame)
|
||||
(visible 'visible)
|
||||
((0 t) 'global))))
|
||||
(unless (or (<= (length (aw-window-list)) 1)
|
||||
(not aw-scope))
|
||||
(window--display-buffer
|
||||
buffer (aw-select "Ace - Display Buffer") 'reuse))))
|
||||
|
||||
(declare-function transpose-frame "ext:transpose-frame")
|
||||
(defun aw-transpose-frame (w)
|
||||
"Select any window on frame and `tranpose-frame'."
|
||||
(transpose-frame (window-frame w)))
|
||||
|
||||
;;;###autoload
|
||||
(defun ace-window (arg)
|
||||
"Select a window.
|
||||
Perform an action based on ARG described below.
|
||||
|
||||
By default, behaves like extended `other-window'.
|
||||
See `aw-scope' which extends it to work with frames.
|
||||
|
||||
Prefixed with one \\[universal-argument], does a swap between the
|
||||
selected window and the current window, so that the selected
|
||||
buffer moves to current window (and current buffer moves to
|
||||
selected window).
|
||||
|
||||
Prefixed with two \\[universal-argument]'s, deletes the selected
|
||||
window."
|
||||
(interactive "p")
|
||||
(setq avy-current-path "")
|
||||
(cl-case arg
|
||||
(0
|
||||
(let ((aw-ignore-on (not aw-ignore-on)))
|
||||
(ace-select-window)))
|
||||
(4 (ace-swap-window))
|
||||
(16 (ace-delete-window))
|
||||
(t (ace-select-window))))
|
||||
|
||||
;;* Utility
|
||||
(unless (fboundp 'frame-position)
|
||||
(defun frame-position (&optional frame)
|
||||
(let ((pl (frame-parameter frame 'left))
|
||||
(pt (frame-parameter frame 'top)))
|
||||
(when (consp pl)
|
||||
(setq pl (eval pl)))
|
||||
(when (consp pt)
|
||||
(setq pt (eval pt)))
|
||||
(cons pl pt))))
|
||||
|
||||
(defun aw-window< (wnd1 wnd2)
|
||||
"Return true if WND1 is less than WND2.
|
||||
This is determined by their respective window coordinates.
|
||||
Windows are numbered top down, left to right."
|
||||
(let* ((f1 (window-frame wnd1))
|
||||
(f2 (window-frame wnd2))
|
||||
(e1 (window-edges wnd1))
|
||||
(e2 (window-edges wnd2))
|
||||
(p1 (frame-position f1))
|
||||
(p2 (frame-position f2))
|
||||
(nl (or (null (car p1)) (null (car p2)))))
|
||||
(cond ((and (not nl) (< (car p1) (car p2)))
|
||||
(not aw-reverse-frame-list))
|
||||
((and (not nl) (> (car p1) (car p2)))
|
||||
aw-reverse-frame-list)
|
||||
((< (car e1) (car e2))
|
||||
t)
|
||||
((> (car e1) (car e2))
|
||||
nil)
|
||||
((< (cadr e1) (cadr e2))
|
||||
t))))
|
||||
|
||||
(defvar aw--window-ring (make-ring 10)
|
||||
"Hold the window switching history.")
|
||||
|
||||
(defun aw--push-window (window)
|
||||
"Store WINDOW to `aw--window-ring'."
|
||||
(when (or (zerop (ring-length aw--window-ring))
|
||||
(not (equal
|
||||
(ring-ref aw--window-ring 0)
|
||||
window)))
|
||||
(ring-insert aw--window-ring (selected-window))))
|
||||
|
||||
(defun aw--pop-window ()
|
||||
"Return the removed top of `aw--window-ring'."
|
||||
(let (res)
|
||||
(condition-case nil
|
||||
(while (or (not (window-live-p
|
||||
(setq res (ring-remove aw--window-ring 0))))
|
||||
(equal res (selected-window))))
|
||||
(error
|
||||
(if (= (length (aw-window-list)) 2)
|
||||
(progn
|
||||
(other-window 1)
|
||||
(setq res (selected-window)))
|
||||
(error "No previous windows stored"))))
|
||||
res))
|
||||
|
||||
(defun aw-switch-to-window (window)
|
||||
"Switch to the window WINDOW."
|
||||
(let ((frame (window-frame window)))
|
||||
(aw--push-window (selected-window))
|
||||
(when (and (frame-live-p frame)
|
||||
(not (eq frame (selected-frame))))
|
||||
(select-frame-set-input-focus frame))
|
||||
(if (window-live-p window)
|
||||
(select-window window)
|
||||
(error "Got a dead window %S" window))))
|
||||
|
||||
(defun aw-flip-window ()
|
||||
"Switch to the window you were previously in."
|
||||
(interactive)
|
||||
(aw-switch-to-window (aw--pop-window)))
|
||||
|
||||
(defun aw-show-dispatch-help ()
|
||||
"Display action shortucts in echo area."
|
||||
(interactive)
|
||||
(message "%s" (mapconcat
|
||||
(lambda (action)
|
||||
(cl-destructuring-bind (key fn &optional description) action
|
||||
(format "%s: %s"
|
||||
(propertize
|
||||
(char-to-string key)
|
||||
'face 'aw-key-face)
|
||||
(or description fn))))
|
||||
aw-dispatch-alist
|
||||
"\n"))
|
||||
;; Prevent this from replacing any help display
|
||||
;; in the minibuffer.
|
||||
(let (aw-minibuffer-flag)
|
||||
(mapc #'delete-overlay aw-overlays-back)
|
||||
(call-interactively 'ace-window)))
|
||||
|
||||
(defun aw-delete-window (window &optional kill-buffer)
|
||||
"Delete window WINDOW.
|
||||
When KILL-BUFFER is non-nil, also kill the buffer."
|
||||
(let ((frame (window-frame window)))
|
||||
(when (and (frame-live-p frame)
|
||||
(not (eq frame (selected-frame))))
|
||||
(select-frame-set-input-focus (window-frame window)))
|
||||
(if (= 1 (length (window-list)))
|
||||
(delete-frame frame)
|
||||
(if (window-live-p window)
|
||||
(let ((buffer (window-buffer window)))
|
||||
(delete-window window)
|
||||
(when kill-buffer
|
||||
(kill-buffer buffer)))
|
||||
(error "Got a dead window %S" window)))))
|
||||
|
||||
(defun aw-switch-buffer-in-window (window)
|
||||
"Select buffer in WINDOW."
|
||||
(aw-switch-to-window window)
|
||||
(aw--switch-buffer))
|
||||
|
||||
(declare-function ivy-switch-buffer "ext:ivy")
|
||||
|
||||
(defun aw--switch-buffer ()
|
||||
(cond ((bound-and-true-p ivy-mode)
|
||||
(ivy-switch-buffer))
|
||||
((bound-and-true-p ido-mode)
|
||||
(ido-switch-buffer))
|
||||
(t
|
||||
(call-interactively 'switch-to-buffer))))
|
||||
|
||||
(defcustom aw-swap-invert nil
|
||||
"When non-nil, the other of the two swapped windows gets the point."
|
||||
:type 'boolean)
|
||||
|
||||
(defun aw-swap-window (window)
|
||||
"Swap buffers of current window and WINDOW."
|
||||
(cl-labels ((swap-windows (window1 window2)
|
||||
"Swap the buffers of WINDOW1 and WINDOW2."
|
||||
(let ((buffer1 (window-buffer window1))
|
||||
(buffer2 (window-buffer window2)))
|
||||
(set-window-buffer window1 buffer2)
|
||||
(set-window-buffer window2 buffer1)
|
||||
(select-window window2))))
|
||||
(let ((frame (window-frame window))
|
||||
(this-window (selected-window)))
|
||||
(when (and (frame-live-p frame)
|
||||
(not (eq frame (selected-frame))))
|
||||
(select-frame-set-input-focus (window-frame window)))
|
||||
(when (and (window-live-p window)
|
||||
(not (eq window this-window)))
|
||||
(aw--push-window this-window)
|
||||
(if aw-swap-invert
|
||||
(swap-windows window this-window)
|
||||
(swap-windows this-window window))))))
|
||||
|
||||
(defun aw-move-window (window)
|
||||
"Move the current buffer to WINDOW.
|
||||
Switch the current window to the previous buffer."
|
||||
(let ((buffer (current-buffer)))
|
||||
(switch-to-buffer (other-buffer))
|
||||
(aw-switch-to-window window)
|
||||
(switch-to-buffer buffer)))
|
||||
|
||||
(defun aw-copy-window (window)
|
||||
"Copy the current buffer to WINDOW."
|
||||
(let ((buffer (current-buffer)))
|
||||
(aw-switch-to-window window)
|
||||
(switch-to-buffer buffer)))
|
||||
|
||||
(defun aw-split-window-vert (window)
|
||||
"Split WINDOW vertically."
|
||||
(select-window window)
|
||||
(split-window-vertically))
|
||||
|
||||
(defun aw-split-window-horz (window)
|
||||
"Split WINDOW horizontally."
|
||||
(select-window window)
|
||||
(split-window-horizontally))
|
||||
|
||||
(defcustom aw-fair-aspect-ratio 2
|
||||
"The aspect ratio to aim for when splitting windows.
|
||||
Sizes are based on the number of characters, not pixels.
|
||||
Increase to prefer wider windows, or decrease for taller windows."
|
||||
:type 'number)
|
||||
|
||||
(defun aw-split-window-fair (window)
|
||||
"Split WINDOW vertically or horizontally, based on its current dimensions.
|
||||
Modify `aw-fair-aspect-ratio' to tweak behavior."
|
||||
(let ((w (window-body-width window))
|
||||
(h (window-body-height window)))
|
||||
(if (< (* h aw-fair-aspect-ratio) w)
|
||||
(aw-split-window-horz window)
|
||||
(aw-split-window-vert window))))
|
||||
|
||||
(defun aw-switch-buffer-other-window (window)
|
||||
"Switch buffer in WINDOW."
|
||||
(aw-switch-to-window window)
|
||||
(unwind-protect
|
||||
(aw--switch-buffer)
|
||||
(aw-flip-window)))
|
||||
|
||||
(defun aw-execute-command-other-window (window)
|
||||
"Execute a command in WINDOW."
|
||||
(aw-switch-to-window window)
|
||||
(unwind-protect
|
||||
(funcall
|
||||
(key-binding
|
||||
(read-key-sequence
|
||||
"Enter key sequence: ")))
|
||||
(aw-flip-window)))
|
||||
|
||||
(defun aw--face-rel-height ()
|
||||
(let ((h (face-attribute 'aw-leading-char-face :height)))
|
||||
(cond
|
||||
((eq h 'unspecified)
|
||||
1)
|
||||
((floatp h)
|
||||
(max (floor h) 1))
|
||||
((integerp h)
|
||||
1)
|
||||
(t
|
||||
(error "unexpected: %s" h)))))
|
||||
|
||||
(defun aw-offset (window)
|
||||
"Return point in WINDOW that's closest to top left corner.
|
||||
The point is writable, i.e. it's not part of space after newline."
|
||||
(let ((h (window-hscroll window))
|
||||
(beg (window-start window))
|
||||
(end (window-end window))
|
||||
(inhibit-field-text-motion t))
|
||||
(with-current-buffer (window-buffer window)
|
||||
(save-excursion
|
||||
(goto-char beg)
|
||||
(forward-line (1-
|
||||
(min
|
||||
(count-lines
|
||||
(point)
|
||||
(point-max))
|
||||
(aw--face-rel-height))))
|
||||
(while (and (< (point) end)
|
||||
(< (- (line-end-position)
|
||||
(line-beginning-position))
|
||||
h))
|
||||
(forward-line))
|
||||
(+ (point) h)))))
|
||||
|
||||
(defun aw--after-make-frame (f)
|
||||
(aw-update)
|
||||
(make-frame-visible f))
|
||||
|
||||
;;* Mode line
|
||||
;;;###autoload
|
||||
(define-minor-mode ace-window-display-mode
|
||||
"Minor mode for showing the ace window key in the mode line."
|
||||
:global t
|
||||
(if ace-window-display-mode
|
||||
(progn
|
||||
(aw-update)
|
||||
(set-default
|
||||
'mode-line-format
|
||||
`((ace-window-display-mode
|
||||
(:eval (window-parameter (selected-window) 'ace-window-path)))
|
||||
,@(assq-delete-all
|
||||
'ace-window-display-mode
|
||||
(default-value 'mode-line-format))))
|
||||
(force-mode-line-update t)
|
||||
(add-hook 'window-configuration-change-hook 'aw-update)
|
||||
;; Add at the end so does not precede select-frame call.
|
||||
(add-hook 'after-make-frame-functions #'aw--after-make-frame t))
|
||||
(set-default
|
||||
'mode-line-format
|
||||
(assq-delete-all
|
||||
'ace-window-display-mode
|
||||
(default-value 'mode-line-format)))
|
||||
(remove-hook 'window-configuration-change-hook 'aw-update)
|
||||
(remove-hook 'after-make-frame-functions 'aw--after-make-frame)))
|
||||
|
||||
(defun aw-update ()
|
||||
"Update ace-window-path window parameter for all windows.
|
||||
|
||||
Ensure all windows are labeled so the user can select a specific
|
||||
one, even from the set of windows typically ignored when making a
|
||||
window list."
|
||||
(let ((aw-ignore-on)
|
||||
(aw-ignore-current)
|
||||
(ignore-window-parameters t))
|
||||
(avy-traverse
|
||||
(avy-tree (aw-window-list) aw-keys)
|
||||
(lambda (path leaf)
|
||||
(set-window-parameter
|
||||
leaf 'ace-window-path
|
||||
(propertize
|
||||
(apply #'string (reverse path))
|
||||
'face 'aw-mode-line-face))))))
|
||||
|
||||
(provide 'ace-window)
|
||||
|
||||
;;; ace-window.el ends here
|
Binary file not shown.
|
@ -1,34 +0,0 @@
|
|||
The main function, `ace-window' is meant to replace `other-window'
|
||||
by assigning each window a short, unique label. When there are only
|
||||
two windows present, `other-window' is called (unless
|
||||
aw-dispatch-always is set non-nil). If there are more, each
|
||||
window will have its first label character highlighted. Once a
|
||||
unique label is typed, ace-window will switch to that window.
|
||||
|
||||
To setup this package, just add to your .emacs:
|
||||
|
||||
(global-set-key (kbd "M-o") 'ace-window)
|
||||
|
||||
replacing "M-o" with an appropriate shortcut.
|
||||
|
||||
By default, ace-window uses numbers for window labels so the window
|
||||
labeling is intuitively ordered. But if you prefer to type keys on
|
||||
your home row for quicker access, use this setting:
|
||||
|
||||
(setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l))
|
||||
|
||||
Whenever ace-window prompts for a window selection, it grays out
|
||||
all the window characters, highlighting window labels in red. To
|
||||
disable this behavior, set this:
|
||||
|
||||
(setq aw-background nil)
|
||||
|
||||
If you want to know the selection characters ahead of time, turn on
|
||||
`ace-window-display-mode'.
|
||||
|
||||
When prefixed with one `universal-argument', instead of switching
|
||||
to the selected window, the selected window is swapped with the
|
||||
current one.
|
||||
|
||||
When prefixed with two `universal-argument', the selected window is
|
||||
deleted instead.
|
|
@ -1,100 +0,0 @@
|
|||
;;; alert-autoloads.el --- automatically extracted autoloads
|
||||
;;
|
||||
;;; Code:
|
||||
|
||||
(add-to-list 'load-path (directory-file-name
|
||||
(or (file-name-directory #$) (car load-path))))
|
||||
|
||||
|
||||
;;;### (autoloads nil "alert" "alert.el" (0 0 0 0))
|
||||
;;; Generated autoloads from alert.el
|
||||
|
||||
(autoload 'alert-add-rule "alert" "\
|
||||
Programmatically add an alert configuration rule.
|
||||
|
||||
Normally, users should custoimze `alert-user-configuration'.
|
||||
This facility is for module writers and users that need to do
|
||||
things the Lisp way.
|
||||
|
||||
Here is a rule the author currently uses with ERC, so that the
|
||||
fringe gets colored whenever people chat on BitlBee:
|
||||
|
||||
\(alert-add-rule :status \\='(buried visible idle)
|
||||
:severity \\='(moderate high urgent)
|
||||
:mode \\='erc-mode
|
||||
:predicate
|
||||
#\\='(lambda (info)
|
||||
(string-match (concat \"\\\\`[^&].*@BitlBee\\\\\\='\")
|
||||
(erc-format-target-and/or-network)))
|
||||
:persistent
|
||||
#\\='(lambda (info)
|
||||
;; If the buffer is buried, or the user has been
|
||||
;; idle for `alert-reveal-idle-time' seconds,
|
||||
;; make this alert persistent. Normally, alerts
|
||||
;; become persistent after
|
||||
;; `alert-persist-idle-time' seconds.
|
||||
(memq (plist-get info :status) \\='(buried idle)))
|
||||
:style \\='fringe
|
||||
:continue t)
|
||||
|
||||
\(fn &key SEVERITY STATUS MODE CATEGORY TITLE MESSAGE PREDICATE ICON (STYLE alert-default-style) PERSISTENT CONTINUE NEVER-PERSIST APPEND)" nil nil)
|
||||
|
||||
(autoload 'alert "alert" "\
|
||||
Alert the user that something has happened.
|
||||
MESSAGE is what the user will see. You may also use keyword
|
||||
arguments to specify additional details. Here is a full example:
|
||||
|
||||
\(alert \"This is a message\"
|
||||
:severity \\='high ;; The default severity is `normal'
|
||||
:title \"Title\" ;; An optional title
|
||||
:category \\='example ;; A symbol to identify the message
|
||||
:mode \\='text-mode ;; Normally determined automatically
|
||||
:buffer (current-buffer) ;; This is the default
|
||||
:data nil ;; Unused by alert.el itself
|
||||
:persistent nil ;; Force the alert to be persistent;
|
||||
;; it is best not to use this
|
||||
:never-persist nil ;; Force this alert to never persist
|
||||
:id \\='my-id) ;; Used to replace previous message of
|
||||
;; the same id in styles that support it
|
||||
:style \\='fringe) ;; Force a given style to be used;
|
||||
;; this is only for debugging!
|
||||
|
||||
If no :title is given, the buffer-name of :buffer is used. If
|
||||
:buffer is nil, it is the current buffer at the point of call.
|
||||
|
||||
:data is an opaque value which modules can pass through to their
|
||||
own styles if they wish.
|
||||
|
||||
Here are some more typical examples of usage:
|
||||
|
||||
;; This is the most basic form usage
|
||||
(alert \"This is an alert\")
|
||||
|
||||
;; You can adjust the severity for more important messages
|
||||
(alert \"This is an alert\" :severity \\='high)
|
||||
|
||||
;; Or decrease it for purely informative ones
|
||||
(alert \"This is an alert\" :severity \\='trivial)
|
||||
|
||||
;; Alerts can have optional titles. Otherwise, the title is the
|
||||
;; buffer-name of the (current-buffer) where the alert originated.
|
||||
(alert \"This is an alert\" :title \"My Alert\")
|
||||
|
||||
;; Further, alerts can have categories. This allows users to
|
||||
;; selectively filter on them.
|
||||
(alert \"This is an alert\" :title \"My Alert\"
|
||||
:category \\='some-category-or-other)
|
||||
|
||||
\(fn MESSAGE &key (SEVERITY \\='normal) TITLE ICON CATEGORY BUFFER MODE DATA STYLE PERSISTENT NEVER-PERSIST ID)" nil nil)
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "alert" '("alert-" "x-urgen")))
|
||||
|
||||
;;;***
|
||||
|
||||
;; Local Variables:
|
||||
;; version-control: never
|
||||
;; no-byte-compile: t
|
||||
;; no-update-autoloads: t
|
||||
;; coding: utf-8
|
||||
;; End:
|
||||
;;; alert-autoloads.el ends here
|
|
@ -1,2 +0,0 @@
|
|||
;;; -*- no-byte-compile: t -*-
|
||||
(define-package "alert" "20200303.2118" "Growl-style notification system for Emacs" '((gntp "0.1") (log4e "0.3.0") (cl-lib "0.5")) :commit "7046393272686c7a1a9b3e7f7b1d825d2e5250a6" :keywords '("notification" "emacs" "message") :authors '(("John Wiegley" . "jwiegley@gmail.com")) :maintainer '("John Wiegley" . "jwiegley@gmail.com") :url "https://github.com/jwiegley/alert")
|
File diff suppressed because it is too large
Load diff
Binary file not shown.
|
@ -1,228 +0,0 @@
|
|||
;;; anaphora-autoloads.el --- automatically extracted autoloads
|
||||
;;
|
||||
;;; Code:
|
||||
|
||||
(add-to-list 'load-path (directory-file-name
|
||||
(or (file-name-directory #$) (car load-path))))
|
||||
|
||||
|
||||
;;;### (autoloads nil "anaphora" "anaphora.el" (0 0 0 0))
|
||||
;;; Generated autoloads from anaphora.el
|
||||
|
||||
(let ((loads (get 'anaphora 'custom-loads))) (if (member '"anaphora" loads) nil (put 'anaphora 'custom-loads (cons '"anaphora" loads))))
|
||||
|
||||
(defvar anaphora-use-long-names-only nil "\
|
||||
Use only long names such as `anaphoric-if' instead of traditional `aif'.")
|
||||
|
||||
(custom-autoload 'anaphora-use-long-names-only "anaphora" t)
|
||||
|
||||
(defun anaphora--install-traditional-aliases (&optional arg) "\
|
||||
Install traditional short aliases for anaphoric macros.
|
||||
|
||||
With negative numeric ARG, remove traditional aliases." (let ((syms (quote ((if . t) (prog1 . t) (prog2 . t) (when . when) (while . t) (and . t) (cond . cond) (lambda . lambda) (block . block) (case . case) (ecase . ecase) (typecase . typecase) (etypecase . etypecase) (let . let) (+ . t) (- . t) (* . t) (/ . t))))) (cond ((and (numberp arg) (< arg 0)) (dolist (cell syms) (when (ignore-errors (eq (symbol-function (intern-soft (format "a%s" (car cell)))) (intern-soft (format "anaphoric-%s" (car cell))))) (fmakunbound (intern (format "a%s" (car cell))))))) (t (dolist (cell syms) (let* ((builtin (car cell)) (traditional (intern (format "a%s" builtin))) (long (intern (format "anaphoric-%s" builtin)))) (defalias traditional long) (put traditional (quote lisp-indent-function) (get builtin (quote lisp-indent-function))) (put traditional (quote edebug-form-spec) (cdr cell))))))))
|
||||
|
||||
(unless anaphora-use-long-names-only (anaphora--install-traditional-aliases))
|
||||
|
||||
(autoload 'anaphoric-if "anaphora" "\
|
||||
Like `if', but the result of evaluating COND is bound to `it'.
|
||||
|
||||
The variable `it' is available within THEN and ELSE.
|
||||
|
||||
COND, THEN, and ELSE are otherwise as documented for `if'.
|
||||
|
||||
\(fn COND THEN &rest ELSE)" nil t)
|
||||
|
||||
(function-put 'anaphoric-if 'lisp-indent-function '2)
|
||||
|
||||
(autoload 'anaphoric-prog1 "anaphora" "\
|
||||
Like `prog1', but the result of evaluating FIRST is bound to `it'.
|
||||
|
||||
The variable `it' is available within BODY.
|
||||
|
||||
FIRST and BODY are otherwise as documented for `prog1'.
|
||||
|
||||
\(fn FIRST &rest BODY)" nil t)
|
||||
|
||||
(function-put 'anaphoric-prog1 'lisp-indent-function '1)
|
||||
|
||||
(autoload 'anaphoric-prog2 "anaphora" "\
|
||||
Like `prog2', but the result of evaluating FORM2 is bound to `it'.
|
||||
|
||||
The variable `it' is available within BODY.
|
||||
|
||||
FORM1, FORM2, and BODY are otherwise as documented for `prog2'.
|
||||
|
||||
\(fn FORM1 FORM2 &rest BODY)" nil t)
|
||||
|
||||
(function-put 'anaphoric-prog2 'lisp-indent-function '2)
|
||||
|
||||
(autoload 'anaphoric-when "anaphora" "\
|
||||
Like `when', but the result of evaluating COND is bound to `it'.
|
||||
|
||||
The variable `it' is available within BODY.
|
||||
|
||||
COND and BODY are otherwise as documented for `when'.
|
||||
|
||||
\(fn COND &rest BODY)" nil t)
|
||||
|
||||
(function-put 'anaphoric-when 'lisp-indent-function '1)
|
||||
|
||||
(autoload 'anaphoric-while "anaphora" "\
|
||||
Like `while', but the result of evaluating TEST is bound to `it'.
|
||||
|
||||
The variable `it' is available within BODY.
|
||||
|
||||
TEST and BODY are otherwise as documented for `while'.
|
||||
|
||||
\(fn TEST &rest BODY)" nil t)
|
||||
|
||||
(function-put 'anaphoric-while 'lisp-indent-function '1)
|
||||
|
||||
(autoload 'anaphoric-and "anaphora" "\
|
||||
Like `and', but the result of the previous condition is bound to `it'.
|
||||
|
||||
The variable `it' is available within all CONDITIONS after the
|
||||
initial one.
|
||||
|
||||
CONDITIONS are otherwise as documented for `and'.
|
||||
|
||||
Note that some implementations of this macro bind only the first
|
||||
condition to `it', rather than each successive condition.
|
||||
|
||||
\(fn &rest CONDITIONS)" nil t)
|
||||
|
||||
(autoload 'anaphoric-cond "anaphora" "\
|
||||
Like `cond', but the result of each condition is bound to `it'.
|
||||
|
||||
The variable `it' is available within the remainder of each of CLAUSES.
|
||||
|
||||
CLAUSES are otherwise as documented for `cond'.
|
||||
|
||||
\(fn &rest CLAUSES)" nil t)
|
||||
|
||||
(autoload 'anaphoric-lambda "anaphora" "\
|
||||
Like `lambda', but the function may refer to itself as `self'.
|
||||
|
||||
ARGS and BODY are otherwise as documented for `lambda'.
|
||||
|
||||
\(fn ARGS &rest BODY)" nil t)
|
||||
|
||||
(function-put 'anaphoric-lambda 'lisp-indent-function 'defun)
|
||||
|
||||
(autoload 'anaphoric-block "anaphora" "\
|
||||
Like `block', but the result of the previous expression is bound to `it'.
|
||||
|
||||
The variable `it' is available within all expressions of BODY
|
||||
except the initial one.
|
||||
|
||||
NAME and BODY are otherwise as documented for `block'.
|
||||
|
||||
\(fn NAME &rest BODY)" nil t)
|
||||
|
||||
(function-put 'anaphoric-block 'lisp-indent-function '1)
|
||||
|
||||
(autoload 'anaphoric-case "anaphora" "\
|
||||
Like `case', but the result of evaluating EXPR is bound to `it'.
|
||||
|
||||
The variable `it' is available within CLAUSES.
|
||||
|
||||
EXPR and CLAUSES are otherwise as documented for `case'.
|
||||
|
||||
\(fn EXPR &rest CLAUSES)" nil t)
|
||||
|
||||
(function-put 'anaphoric-case 'lisp-indent-function '1)
|
||||
|
||||
(autoload 'anaphoric-ecase "anaphora" "\
|
||||
Like `ecase', but the result of evaluating EXPR is bound to `it'.
|
||||
|
||||
The variable `it' is available within CLAUSES.
|
||||
|
||||
EXPR and CLAUSES are otherwise as documented for `ecase'.
|
||||
|
||||
\(fn EXPR &rest CLAUSES)" nil t)
|
||||
|
||||
(function-put 'anaphoric-ecase 'lisp-indent-function '1)
|
||||
|
||||
(autoload 'anaphoric-typecase "anaphora" "\
|
||||
Like `typecase', but the result of evaluating EXPR is bound to `it'.
|
||||
|
||||
The variable `it' is available within CLAUSES.
|
||||
|
||||
EXPR and CLAUSES are otherwise as documented for `typecase'.
|
||||
|
||||
\(fn EXPR &rest CLAUSES)" nil t)
|
||||
|
||||
(function-put 'anaphoric-typecase 'lisp-indent-function '1)
|
||||
|
||||
(autoload 'anaphoric-etypecase "anaphora" "\
|
||||
Like `etypecase', but result of evaluating EXPR is bound to `it'.
|
||||
|
||||
The variable `it' is available within CLAUSES.
|
||||
|
||||
EXPR and CLAUSES are otherwise as documented for `etypecase'.
|
||||
|
||||
\(fn EXPR &rest CLAUSES)" nil t)
|
||||
|
||||
(function-put 'anaphoric-etypecase 'lisp-indent-function '1)
|
||||
|
||||
(autoload 'anaphoric-let "anaphora" "\
|
||||
Like `let', but the result of evaluating FORM is bound to `it'.
|
||||
|
||||
FORM and BODY are otherwise as documented for `let'.
|
||||
|
||||
\(fn FORM &rest BODY)" nil t)
|
||||
|
||||
(function-put 'anaphoric-let 'lisp-indent-function '1)
|
||||
|
||||
(autoload 'anaphoric-+ "anaphora" "\
|
||||
Like `+', but the result of evaluating the previous expression is bound to `it'.
|
||||
|
||||
The variable `it' is available within all expressions after the
|
||||
initial one.
|
||||
|
||||
NUMBERS-OR-MARKERS are otherwise as documented for `+'.
|
||||
|
||||
\(fn &rest NUMBERS-OR-MARKERS)" nil t)
|
||||
|
||||
(autoload 'anaphoric-- "anaphora" "\
|
||||
Like `-', but the result of evaluating the previous expression is bound to `it'.
|
||||
|
||||
The variable `it' is available within all expressions after the
|
||||
initial one.
|
||||
|
||||
NUMBER-OR-MARKER and NUMBERS-OR-MARKERS are otherwise as
|
||||
documented for `-'.
|
||||
|
||||
\(fn &optional NUMBER-OR-MARKER &rest NUMBERS-OR-MARKERS)" nil t)
|
||||
|
||||
(autoload 'anaphoric-* "anaphora" "\
|
||||
Like `*', but the result of evaluating the previous expression is bound to `it'.
|
||||
|
||||
The variable `it' is available within all expressions after the
|
||||
initial one.
|
||||
|
||||
NUMBERS-OR-MARKERS are otherwise as documented for `*'.
|
||||
|
||||
\(fn &rest NUMBERS-OR-MARKERS)" nil t)
|
||||
|
||||
(autoload 'anaphoric-/ "anaphora" "\
|
||||
Like `/', but the result of evaluating the previous divisor is bound to `it'.
|
||||
|
||||
The variable `it' is available within all expressions after the
|
||||
first divisor.
|
||||
|
||||
DIVIDEND, DIVISOR, and DIVISORS are otherwise as documented for `/'.
|
||||
|
||||
\(fn DIVIDEND DIVISOR &rest DIVISORS)" nil t)
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "anaphora" '("anaphora-install-font-lock-keywords")))
|
||||
|
||||
;;;***
|
||||
|
||||
;; Local Variables:
|
||||
;; version-control: never
|
||||
;; no-byte-compile: t
|
||||
;; no-update-autoloads: t
|
||||
;; coding: utf-8
|
||||
;; End:
|
||||
;;; anaphora-autoloads.el ends here
|
|
@ -1,2 +0,0 @@
|
|||
;;; -*- no-byte-compile: t -*-
|
||||
(define-package "anaphora" "20180618.2200" "anaphoric macros providing implicit temp variables" 'nil :commit "3b2da3f759b244975852e79721c4a2dbad3905cf" :keywords '("extensions") :authors '(("Roland Walker" . "walker@pobox.com")) :maintainer '("Roland Walker" . "walker@pobox.com") :url "http://github.com/rolandwalker/anaphora")
|
|
@ -1,461 +0,0 @@
|
|||
;;; anaphora.el --- anaphoric macros providing implicit temp variables -*- lexical-binding: t -*-
|
||||
;;
|
||||
;; This code is in the public domain.
|
||||
;;
|
||||
;; Author: Roland Walker <walker@pobox.com>
|
||||
;; Homepage: http://github.com/rolandwalker/anaphora
|
||||
;; URL: http://raw.githubusercontent.com/rolandwalker/anaphora/master/anaphora.el
|
||||
;; Package-Version: 20180618.2200
|
||||
;; Version: 1.0.4
|
||||
;; Last-Updated: 18 Jun 2018
|
||||
;; EmacsWiki: Anaphora
|
||||
;; Keywords: extensions
|
||||
;;
|
||||
;;; Commentary:
|
||||
;;
|
||||
;; Quickstart
|
||||
;;
|
||||
;; (require 'anaphora)
|
||||
;;
|
||||
;; (awhen (big-long-calculation)
|
||||
;; (foo it) ; `it' is provided as
|
||||
;; (bar it)) ; a temporary variable
|
||||
;;
|
||||
;; ;; anonymous function to compute factorial using `self'
|
||||
;; (alambda (x) (if (= x 0) 1 (* x (self (1- x)))))
|
||||
;;
|
||||
;; ;; to fontify `it' and `self'
|
||||
;; (with-eval-after-load "lisp-mode"
|
||||
;; (anaphora-install-font-lock-keywords))
|
||||
;;
|
||||
;; Explanation
|
||||
;;
|
||||
;; Anaphoric expressions implicitly create one or more temporary
|
||||
;; variables which can be referred to during the expression. This
|
||||
;; technique can improve clarity in certain cases. It also enables
|
||||
;; recursion for anonymous functions.
|
||||
;;
|
||||
;; To use anaphora, place the anaphora.el library somewhere
|
||||
;; Emacs can find it, and add the following to your ~/.emacs file:
|
||||
;;
|
||||
;; (require 'anaphora)
|
||||
;;
|
||||
;; The following macros are made available
|
||||
;;
|
||||
;; `aand'
|
||||
;; `ablock'
|
||||
;; `acase'
|
||||
;; `acond'
|
||||
;; `aecase'
|
||||
;; `aetypecase'
|
||||
;; `aif'
|
||||
;; `alambda'
|
||||
;; `alet'
|
||||
;; `aprog1'
|
||||
;; `aprog2'
|
||||
;; `atypecase'
|
||||
;; `awhen'
|
||||
;; `awhile'
|
||||
;; `a+'
|
||||
;; `a-'
|
||||
;; `a*'
|
||||
;; `a/'
|
||||
;;
|
||||
;; See Also
|
||||
;;
|
||||
;; M-x customize-group RET anaphora RET
|
||||
;; http://en.wikipedia.org/wiki/On_Lisp
|
||||
;; http://en.wikipedia.org/wiki/Anaphoric_macro
|
||||
;;
|
||||
;; Notes
|
||||
;;
|
||||
;; Partially based on examples from the book "On Lisp", by Paul
|
||||
;; Graham.
|
||||
;;
|
||||
;; Compatibility and Requirements
|
||||
;;
|
||||
;; GNU Emacs version 26.1 : yes
|
||||
;; GNU Emacs version 25.x : yes
|
||||
;; GNU Emacs version 24.x : yes
|
||||
;; GNU Emacs version 23.x : yes
|
||||
;; GNU Emacs version 22.x : yes
|
||||
;; GNU Emacs version 21.x and lower : unknown
|
||||
;;
|
||||
;; Bugs
|
||||
;;
|
||||
;; TODO
|
||||
;;
|
||||
;; better face for it and self
|
||||
;;
|
||||
;;; License
|
||||
;;
|
||||
;; All code contributed by the author to this library is placed in the
|
||||
;; public domain. It is the author's belief that the portions adapted
|
||||
;; from examples in "On Lisp" are in the public domain.
|
||||
;;
|
||||
;; Regardless of the copyright status of individual functions, all
|
||||
;; code herein is free software, and is provided without any express
|
||||
;; or implied warranties.
|
||||
;;
|
||||
;;; Code:
|
||||
;;
|
||||
|
||||
;;; requirements
|
||||
|
||||
;; for declare, labels, do, block, case, ecase, typecase, etypecase
|
||||
(require 'cl-lib)
|
||||
|
||||
;;; customizable variables
|
||||
|
||||
;;;###autoload
|
||||
(defgroup anaphora nil
|
||||
"Anaphoric macros providing implicit temp variables"
|
||||
:version "1.0.4"
|
||||
:link '(emacs-commentary-link :tag "Commentary" "anaphora")
|
||||
:link '(url-link :tag "GitHub" "http://github.com/rolandwalker/anaphora")
|
||||
:link '(url-link :tag "EmacsWiki" "http://emacswiki.org/emacs/Anaphora")
|
||||
:prefix "anaphora-"
|
||||
:group 'extensions)
|
||||
|
||||
;;;###autoload
|
||||
(defcustom anaphora-use-long-names-only nil
|
||||
"Use only long names such as `anaphoric-if' instead of traditional `aif'."
|
||||
:type 'boolean
|
||||
:group 'anaphora)
|
||||
|
||||
;;; font-lock
|
||||
|
||||
(defun anaphora-install-font-lock-keywords nil
|
||||
"Fontify keywords `it' and `self'."
|
||||
(font-lock-add-keywords 'emacs-lisp-mode `((,(concat "\\<" (regexp-opt '("it" "self") 'paren) "\\>")
|
||||
1 font-lock-variable-name-face)) 'append))
|
||||
|
||||
;;; aliases
|
||||
|
||||
;;;###autoload
|
||||
(progn
|
||||
(defun anaphora--install-traditional-aliases (&optional arg)
|
||||
"Install traditional short aliases for anaphoric macros.
|
||||
|
||||
With negative numeric ARG, remove traditional aliases."
|
||||
(let ((syms '(
|
||||
(if . t)
|
||||
(prog1 . t)
|
||||
(prog2 . t)
|
||||
(when . when)
|
||||
(while . t)
|
||||
(and . t)
|
||||
(cond . cond)
|
||||
(lambda . lambda)
|
||||
(block . block)
|
||||
(case . case)
|
||||
(ecase . ecase)
|
||||
(typecase . typecase)
|
||||
(etypecase . etypecase)
|
||||
(let . let)
|
||||
(+ . t)
|
||||
(- . t)
|
||||
(* . t)
|
||||
(/ . t)
|
||||
)))
|
||||
(cond
|
||||
((and (numberp arg)
|
||||
(< arg 0))
|
||||
(dolist (cell syms)
|
||||
(when (ignore-errors
|
||||
(eq (symbol-function (intern-soft (format "a%s" (car cell))))
|
||||
(intern-soft (format "anaphoric-%s" (car cell)))))
|
||||
(fmakunbound (intern (format "a%s" (car cell)))))))
|
||||
(t
|
||||
(dolist (cell syms)
|
||||
(let* ((builtin (car cell))
|
||||
(traditional (intern (format "a%s" builtin)))
|
||||
(long (intern (format "anaphoric-%s" builtin))))
|
||||
(defalias traditional long)
|
||||
(put traditional 'lisp-indent-function
|
||||
(get builtin 'lisp-indent-function))
|
||||
(put traditional 'edebug-form-spec (cdr cell)))))))))
|
||||
|
||||
;;;###autoload
|
||||
(unless anaphora-use-long-names-only
|
||||
(anaphora--install-traditional-aliases))
|
||||
|
||||
;;; macros
|
||||
|
||||
;;;###autoload
|
||||
(defmacro anaphoric-if (cond then &rest else)
|
||||
"Like `if', but the result of evaluating COND is bound to `it'.
|
||||
|
||||
The variable `it' is available within THEN and ELSE.
|
||||
|
||||
COND, THEN, and ELSE are otherwise as documented for `if'."
|
||||
(declare (debug t)
|
||||
(indent 2))
|
||||
`(let ((it ,cond))
|
||||
(if it ,then ,@else)))
|
||||
|
||||
;;;###autoload
|
||||
(defmacro anaphoric-prog1 (first &rest body)
|
||||
"Like `prog1', but the result of evaluating FIRST is bound to `it'.
|
||||
|
||||
The variable `it' is available within BODY.
|
||||
|
||||
FIRST and BODY are otherwise as documented for `prog1'."
|
||||
(declare (debug t)
|
||||
(indent 1))
|
||||
`(let ((it ,first))
|
||||
(progn ,@body)
|
||||
it))
|
||||
|
||||
;;;###autoload
|
||||
(defmacro anaphoric-prog2 (form1 form2 &rest body)
|
||||
"Like `prog2', but the result of evaluating FORM2 is bound to `it'.
|
||||
|
||||
The variable `it' is available within BODY.
|
||||
|
||||
FORM1, FORM2, and BODY are otherwise as documented for `prog2'."
|
||||
(declare (debug t)
|
||||
(indent 2))
|
||||
`(progn
|
||||
,form1
|
||||
(let ((it ,form2))
|
||||
(progn ,@body)
|
||||
it)))
|
||||
|
||||
;;;###autoload
|
||||
(defmacro anaphoric-when (cond &rest body)
|
||||
"Like `when', but the result of evaluating COND is bound to `it'.
|
||||
|
||||
The variable `it' is available within BODY.
|
||||
|
||||
COND and BODY are otherwise as documented for `when'."
|
||||
(declare (debug when)
|
||||
(indent 1))
|
||||
`(anaphoric-if ,cond
|
||||
(progn ,@body)))
|
||||
|
||||
;;;###autoload
|
||||
(defmacro anaphoric-while (test &rest body)
|
||||
"Like `while', but the result of evaluating TEST is bound to `it'.
|
||||
|
||||
The variable `it' is available within BODY.
|
||||
|
||||
TEST and BODY are otherwise as documented for `while'."
|
||||
(declare (debug t)
|
||||
(indent 1))
|
||||
`(do ((it ,test ,test))
|
||||
((not it))
|
||||
,@body))
|
||||
|
||||
;;;###autoload
|
||||
(defmacro anaphoric-and (&rest conditions)
|
||||
"Like `and', but the result of the previous condition is bound to `it'.
|
||||
|
||||
The variable `it' is available within all CONDITIONS after the
|
||||
initial one.
|
||||
|
||||
CONDITIONS are otherwise as documented for `and'.
|
||||
|
||||
Note that some implementations of this macro bind only the first
|
||||
condition to `it', rather than each successive condition."
|
||||
(declare (debug t))
|
||||
(cond
|
||||
((null conditions)
|
||||
t)
|
||||
((null (cdr conditions))
|
||||
(car conditions))
|
||||
(t
|
||||
`(anaphoric-if ,(car conditions) (anaphoric-and ,@(cdr conditions))))))
|
||||
|
||||
;;;###autoload
|
||||
(defmacro anaphoric-cond (&rest clauses)
|
||||
"Like `cond', but the result of each condition is bound to `it'.
|
||||
|
||||
The variable `it' is available within the remainder of each of CLAUSES.
|
||||
|
||||
CLAUSES are otherwise as documented for `cond'."
|
||||
(declare (debug cond))
|
||||
(if (null clauses)
|
||||
nil
|
||||
(let ((cl1 (car clauses))
|
||||
(sym (gensym)))
|
||||
`(let ((,sym ,(car cl1)))
|
||||
(if ,sym
|
||||
(if (null ',(cdr cl1))
|
||||
,sym
|
||||
(let ((it ,sym)) ,@(cdr cl1)))
|
||||
(anaphoric-cond ,@(cdr clauses)))))))
|
||||
|
||||
;;;###autoload
|
||||
(defmacro anaphoric-lambda (args &rest body)
|
||||
"Like `lambda', but the function may refer to itself as `self'.
|
||||
|
||||
ARGS and BODY are otherwise as documented for `lambda'."
|
||||
(declare (debug lambda)
|
||||
(indent defun))
|
||||
`(cl-labels ((self ,args ,@body))
|
||||
#'self))
|
||||
|
||||
;;;###autoload
|
||||
(defmacro anaphoric-block (name &rest body)
|
||||
"Like `block', but the result of the previous expression is bound to `it'.
|
||||
|
||||
The variable `it' is available within all expressions of BODY
|
||||
except the initial one.
|
||||
|
||||
NAME and BODY are otherwise as documented for `block'."
|
||||
(declare (debug block)
|
||||
(indent 1))
|
||||
`(cl-block ,name
|
||||
,(funcall (anaphoric-lambda (body)
|
||||
(cl-case (length body)
|
||||
(0 nil)
|
||||
(1 (car body))
|
||||
(t `(let ((it ,(car body)))
|
||||
,(self (cdr body))))))
|
||||
body)))
|
||||
|
||||
;;;###autoload
|
||||
(defmacro anaphoric-case (expr &rest clauses)
|
||||
"Like `case', but the result of evaluating EXPR is bound to `it'.
|
||||
|
||||
The variable `it' is available within CLAUSES.
|
||||
|
||||
EXPR and CLAUSES are otherwise as documented for `case'."
|
||||
(declare (debug case)
|
||||
(indent 1))
|
||||
`(let ((it ,expr))
|
||||
(cl-case it ,@clauses)))
|
||||
|
||||
;;;###autoload
|
||||
(defmacro anaphoric-ecase (expr &rest clauses)
|
||||
"Like `ecase', but the result of evaluating EXPR is bound to `it'.
|
||||
|
||||
The variable `it' is available within CLAUSES.
|
||||
|
||||
EXPR and CLAUSES are otherwise as documented for `ecase'."
|
||||
(declare (debug ecase)
|
||||
(indent 1))
|
||||
`(let ((it ,expr))
|
||||
(cl-ecase it ,@clauses)))
|
||||
|
||||
;;;###autoload
|
||||
(defmacro anaphoric-typecase (expr &rest clauses)
|
||||
"Like `typecase', but the result of evaluating EXPR is bound to `it'.
|
||||
|
||||
The variable `it' is available within CLAUSES.
|
||||
|
||||
EXPR and CLAUSES are otherwise as documented for `typecase'."
|
||||
(declare (debug typecase)
|
||||
(indent 1))
|
||||
`(let ((it ,expr))
|
||||
(cl-typecase it ,@clauses)))
|
||||
|
||||
;;;###autoload
|
||||
(defmacro anaphoric-etypecase (expr &rest clauses)
|
||||
"Like `etypecase', but result of evaluating EXPR is bound to `it'.
|
||||
|
||||
The variable `it' is available within CLAUSES.
|
||||
|
||||
EXPR and CLAUSES are otherwise as documented for `etypecase'."
|
||||
(declare (debug etypecase)
|
||||
(indent 1))
|
||||
`(let ((it ,expr))
|
||||
(cl-etypecase it ,@clauses)))
|
||||
|
||||
;;;###autoload
|
||||
(defmacro anaphoric-let (form &rest body)
|
||||
"Like `let', but the result of evaluating FORM is bound to `it'.
|
||||
|
||||
FORM and BODY are otherwise as documented for `let'."
|
||||
(declare (debug let)
|
||||
(indent 1))
|
||||
`(let ((it ,form))
|
||||
(progn ,@body)))
|
||||
|
||||
;;;###autoload
|
||||
(defmacro anaphoric-+ (&rest numbers-or-markers)
|
||||
"Like `+', but the result of evaluating the previous expression is bound to `it'.
|
||||
|
||||
The variable `it' is available within all expressions after the
|
||||
initial one.
|
||||
|
||||
NUMBERS-OR-MARKERS are otherwise as documented for `+'."
|
||||
(declare (debug t))
|
||||
(cond
|
||||
((null numbers-or-markers)
|
||||
0)
|
||||
(t
|
||||
`(let ((it ,(car numbers-or-markers)))
|
||||
(+ it (anaphoric-+ ,@(cdr numbers-or-markers)))))))
|
||||
|
||||
;;;###autoload
|
||||
(defmacro anaphoric-- (&optional number-or-marker &rest numbers-or-markers)
|
||||
"Like `-', but the result of evaluating the previous expression is bound to `it'.
|
||||
|
||||
The variable `it' is available within all expressions after the
|
||||
initial one.
|
||||
|
||||
NUMBER-OR-MARKER and NUMBERS-OR-MARKERS are otherwise as
|
||||
documented for `-'."
|
||||
(declare (debug t))
|
||||
(cond
|
||||
((null number-or-marker)
|
||||
0)
|
||||
((null numbers-or-markers)
|
||||
`(- ,number-or-marker))
|
||||
(t
|
||||
`(let ((it ,(car numbers-or-markers)))
|
||||
(- ,number-or-marker (+ it (anaphoric-+ ,@(cdr numbers-or-markers))))))))
|
||||
|
||||
;;;###autoload
|
||||
(defmacro anaphoric-* (&rest numbers-or-markers)
|
||||
"Like `*', but the result of evaluating the previous expression is bound to `it'.
|
||||
|
||||
The variable `it' is available within all expressions after the
|
||||
initial one.
|
||||
|
||||
NUMBERS-OR-MARKERS are otherwise as documented for `*'."
|
||||
(declare (debug t))
|
||||
(cond
|
||||
((null numbers-or-markers)
|
||||
1)
|
||||
(t
|
||||
`(let ((it ,(car numbers-or-markers)))
|
||||
(* it (anaphoric-* ,@(cdr numbers-or-markers)))))))
|
||||
|
||||
;;;###autoload
|
||||
(defmacro anaphoric-/ (dividend divisor &rest divisors)
|
||||
"Like `/', but the result of evaluating the previous divisor is bound to `it'.
|
||||
|
||||
The variable `it' is available within all expressions after the
|
||||
first divisor.
|
||||
|
||||
DIVIDEND, DIVISOR, and DIVISORS are otherwise as documented for `/'."
|
||||
(declare (debug t))
|
||||
(cond
|
||||
((null divisors)
|
||||
`(/ ,dividend ,divisor))
|
||||
(t
|
||||
`(let ((it ,divisor))
|
||||
(/ ,dividend (* it (anaphoric-* ,@divisors)))))))
|
||||
|
||||
(provide 'anaphora)
|
||||
|
||||
;;
|
||||
;; Emacs
|
||||
;;
|
||||
;; Local Variables:
|
||||
;; indent-tabs-mode: nil
|
||||
;; mangle-whitespace: t
|
||||
;; require-final-newline: t
|
||||
;; coding: utf-8
|
||||
;; byte-compile-warnings: (not cl-functions redefine)
|
||||
;; End:
|
||||
;;
|
||||
;; LocalWords: Anaphora EXPR awhen COND ARGS alambda ecase typecase
|
||||
;; LocalWords: etypecase aprog aand acond ablock acase aecase alet
|
||||
;; LocalWords: atypecase aetypecase
|
||||
;;
|
||||
|
||||
;;; anaphora.el ends here
|
Binary file not shown.
File diff suppressed because it is too large
Load diff
|
@ -1 +0,0 @@
|
|||
Good signature from 066DAFCB81E42C40 GNU ELPA Signing Agent (2019) <elpasign@elpa.gnu.org> (trust undefined) created at 2020-04-13T11:05:02+0200 using RSA
|
|
@ -1,174 +0,0 @@
|
|||
;;; async-autoloads.el --- automatically extracted autoloads
|
||||
;;
|
||||
;;; Code:
|
||||
|
||||
(add-to-list 'load-path (directory-file-name
|
||||
(or (file-name-directory #$) (car load-path))))
|
||||
|
||||
|
||||
;;;### (autoloads nil "async" "async.el" (0 0 0 0))
|
||||
;;; Generated autoloads from async.el
|
||||
|
||||
(autoload 'async-start-process "async" "\
|
||||
Start the executable PROGRAM asynchronously named NAME. See `async-start'.
|
||||
PROGRAM is passed PROGRAM-ARGS, calling FINISH-FUNC with the
|
||||
process object when done. If FINISH-FUNC is nil, the future
|
||||
object will return the process object when the program is
|
||||
finished. Set DEFAULT-DIRECTORY to change PROGRAM's current
|
||||
working directory.
|
||||
|
||||
\(fn NAME PROGRAM FINISH-FUNC &rest PROGRAM-ARGS)" nil nil)
|
||||
|
||||
(autoload 'async-start "async" "\
|
||||
Execute START-FUNC (often a lambda) in a subordinate Emacs process.
|
||||
When done, the return value is passed to FINISH-FUNC. Example:
|
||||
|
||||
(async-start
|
||||
;; What to do in the child process
|
||||
(lambda ()
|
||||
(message \"This is a test\")
|
||||
(sleep-for 3)
|
||||
222)
|
||||
|
||||
;; What to do when it finishes
|
||||
(lambda (result)
|
||||
(message \"Async process done, result should be 222: %s\"
|
||||
result)))
|
||||
|
||||
If FINISH-FUNC is nil or missing, a future is returned that can
|
||||
be inspected using `async-get', blocking until the value is
|
||||
ready. Example:
|
||||
|
||||
(let ((proc (async-start
|
||||
;; What to do in the child process
|
||||
(lambda ()
|
||||
(message \"This is a test\")
|
||||
(sleep-for 3)
|
||||
222))))
|
||||
|
||||
(message \"I'm going to do some work here\") ;; ....
|
||||
|
||||
(message \"Waiting on async process, result should be 222: %s\"
|
||||
(async-get proc)))
|
||||
|
||||
If you don't want to use a callback, and you don't care about any
|
||||
return value from the child process, pass the `ignore' symbol as
|
||||
the second argument (if you don't, and never call `async-get', it
|
||||
will leave *emacs* process buffers hanging around):
|
||||
|
||||
(async-start
|
||||
(lambda ()
|
||||
(delete-file \"a remote file on a slow link\" nil))
|
||||
'ignore)
|
||||
|
||||
Note: Even when FINISH-FUNC is present, a future is still
|
||||
returned except that it yields no value (since the value is
|
||||
passed to FINISH-FUNC). Call `async-get' on such a future always
|
||||
returns nil. It can still be useful, however, as an argument to
|
||||
`async-ready' or `async-wait'.
|
||||
|
||||
\(fn START-FUNC &optional FINISH-FUNC)" nil nil)
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "async" '("async-")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "async-bytecomp" "async-bytecomp.el" (0 0 0
|
||||
;;;;;; 0))
|
||||
;;; Generated autoloads from async-bytecomp.el
|
||||
|
||||
(autoload 'async-byte-recompile-directory "async-bytecomp" "\
|
||||
Compile all *.el files in DIRECTORY asynchronously.
|
||||
All *.elc files are systematically deleted before proceeding.
|
||||
|
||||
\(fn DIRECTORY &optional QUIET)" nil nil)
|
||||
|
||||
(defvar async-bytecomp-package-mode nil "\
|
||||
Non-nil if Async-Bytecomp-Package mode is enabled.
|
||||
See the `async-bytecomp-package-mode' command
|
||||
for a description of this minor mode.
|
||||
Setting this variable directly does not take effect;
|
||||
either customize it (see the info node `Easy Customization')
|
||||
or call the function `async-bytecomp-package-mode'.")
|
||||
|
||||
(custom-autoload 'async-bytecomp-package-mode "async-bytecomp" nil)
|
||||
|
||||
(autoload 'async-bytecomp-package-mode "async-bytecomp" "\
|
||||
Byte compile asynchronously packages installed with package.el.
|
||||
Async compilation of packages can be controlled by
|
||||
`async-bytecomp-allowed-packages'.
|
||||
|
||||
\(fn &optional ARG)" t nil)
|
||||
|
||||
(autoload 'async-byte-compile-file "async-bytecomp" "\
|
||||
Byte compile Lisp code FILE asynchronously.
|
||||
|
||||
Same as `byte-compile-file' but asynchronous.
|
||||
|
||||
\(fn FILE)" t nil)
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "async-bytecomp" '("async-byte")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "dired-async" "dired-async.el" (0 0 0 0))
|
||||
;;; Generated autoloads from dired-async.el
|
||||
|
||||
(defvar dired-async-mode nil "\
|
||||
Non-nil if Dired-Async mode is enabled.
|
||||
See the `dired-async-mode' command
|
||||
for a description of this minor mode.
|
||||
Setting this variable directly does not take effect;
|
||||
either customize it (see the info node `Easy Customization')
|
||||
or call the function `dired-async-mode'.")
|
||||
|
||||
(custom-autoload 'dired-async-mode "dired-async" nil)
|
||||
|
||||
(autoload 'dired-async-mode "dired-async" "\
|
||||
Do dired actions asynchronously.
|
||||
|
||||
\(fn &optional ARG)" t nil)
|
||||
|
||||
(autoload 'dired-async-do-copy "dired-async" "\
|
||||
Run ‘dired-do-copy’ asynchronously.
|
||||
|
||||
\(fn &optional ARG)" t nil)
|
||||
|
||||
(autoload 'dired-async-do-symlink "dired-async" "\
|
||||
Run ‘dired-do-symlink’ asynchronously.
|
||||
|
||||
\(fn &optional ARG)" t nil)
|
||||
|
||||
(autoload 'dired-async-do-hardlink "dired-async" "\
|
||||
Run ‘dired-do-hardlink’ asynchronously.
|
||||
|
||||
\(fn &optional ARG)" t nil)
|
||||
|
||||
(autoload 'dired-async-do-rename "dired-async" "\
|
||||
Run ‘dired-do-rename’ asynchronously.
|
||||
|
||||
\(fn &optional ARG)" t nil)
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "dired-async" '("dired-async-")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "smtpmail-async" "smtpmail-async.el" (0 0 0
|
||||
;;;;;; 0))
|
||||
;;; Generated autoloads from smtpmail-async.el
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "smtpmail-async" '("async-smtpmail-")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil nil ("async-pkg.el") (0 0 0 0))
|
||||
|
||||
;;;***
|
||||
|
||||
;; Local Variables:
|
||||
;; version-control: never
|
||||
;; no-byte-compile: t
|
||||
;; no-update-autoloads: t
|
||||
;; coding: utf-8
|
||||
;; End:
|
||||
;;; async-autoloads.el ends here
|
|
@ -1,210 +0,0 @@
|
|||
;;; async-bytecomp.el --- Compile elisp files asynchronously -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2014-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Authors: John Wiegley <jwiegley@gmail.com>
|
||||
;; Thierry Volpiatto <thierry.volpiatto@gmail.com>
|
||||
|
||||
;; Keywords: dired async byte-compile
|
||||
;; X-URL: https://github.com/jwiegley/dired-async
|
||||
|
||||
;; This program is free software; you can redistribute it and/or
|
||||
;; modify it under the terms of the GNU General Public License as
|
||||
;; published by the Free Software Foundation; either version 2, or (at
|
||||
;; your option) any later version.
|
||||
|
||||
;; This program is distributed in the hope that it will be useful, but
|
||||
;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
;; General Public License for more details.
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
;; Boston, MA 02111-1307, USA.
|
||||
|
||||
;;; Commentary:
|
||||
;;
|
||||
;; This package provide the `async-byte-recompile-directory' function
|
||||
;; which allows, as the name says to recompile a directory outside of
|
||||
;; your running emacs.
|
||||
;; The benefit is your files will be compiled in a clean environment without
|
||||
;; the old *.el files loaded.
|
||||
;; Among other things, this fix a bug in package.el which recompile
|
||||
;; the new files in the current environment with the old files loaded, creating
|
||||
;; errors in most packages after upgrades.
|
||||
;;
|
||||
;; NB: This package is advicing the function `package--compile'.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'cl-lib)
|
||||
(require 'async)
|
||||
|
||||
(defcustom async-bytecomp-allowed-packages
|
||||
;; FIXME: Arguably the default should be `all', but currently
|
||||
;; this minor mode is silently/forcefully enabled by Helm and Magit to ensure
|
||||
;; they get compiled asynchronously, so this conservative default value is
|
||||
;; here to make sure that the mode can be enabled without the user's
|
||||
;; explicit consent.
|
||||
'(async forge helm helm-core helm-ls-git helm-ls-hg magit)
|
||||
"Packages in this list will be compiled asynchronously by `package--compile'.
|
||||
All the dependencies of these packages will be compiled async too,
|
||||
so no need to add dependencies to this list.
|
||||
The value of this variable can also be the symbol `all', in this case
|
||||
all packages are always compiled asynchronously."
|
||||
:group 'async
|
||||
:type '(choice
|
||||
(const :tag "All packages" all)
|
||||
(repeat symbol)))
|
||||
|
||||
(defvar async-byte-compile-log-file
|
||||
(concat user-emacs-directory "async-bytecomp.log"))
|
||||
|
||||
;;;###autoload
|
||||
(defun async-byte-recompile-directory (directory &optional quiet)
|
||||
"Compile all *.el files in DIRECTORY asynchronously.
|
||||
All *.elc files are systematically deleted before proceeding."
|
||||
(cl-loop with dir = (directory-files directory t "\\.elc\\'")
|
||||
unless dir return nil
|
||||
for f in dir
|
||||
when (file-exists-p f) do (delete-file f))
|
||||
;; Ensure async is reloaded when async.elc is deleted.
|
||||
;; This happen when recompiling its own directory.
|
||||
(load "async")
|
||||
(let ((call-back
|
||||
(lambda (&optional _ignore)
|
||||
(if (file-exists-p async-byte-compile-log-file)
|
||||
(let ((buf (get-buffer-create byte-compile-log-buffer))
|
||||
(n 0))
|
||||
(with-current-buffer buf
|
||||
(goto-char (point-max))
|
||||
(let ((inhibit-read-only t))
|
||||
(insert-file-contents async-byte-compile-log-file)
|
||||
(compilation-mode))
|
||||
(display-buffer buf)
|
||||
(delete-file async-byte-compile-log-file)
|
||||
(unless quiet
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "^.*:Error:" nil t)
|
||||
(cl-incf n)))
|
||||
(if (> n 0)
|
||||
(message "Failed to compile %d files in directory `%s'" n directory)
|
||||
(message "Directory `%s' compiled asynchronously with warnings" directory)))))
|
||||
(unless quiet
|
||||
(message "Directory `%s' compiled asynchronously with success" directory))))))
|
||||
(async-start
|
||||
`(lambda ()
|
||||
(require 'bytecomp)
|
||||
,(async-inject-variables "\\`\\(load-path\\)\\|byte\\'")
|
||||
(let ((default-directory (file-name-as-directory ,directory))
|
||||
error-data)
|
||||
(add-to-list 'load-path default-directory)
|
||||
(byte-recompile-directory ,directory 0 t)
|
||||
(when (get-buffer byte-compile-log-buffer)
|
||||
(setq error-data (with-current-buffer byte-compile-log-buffer
|
||||
(buffer-substring-no-properties (point-min) (point-max))))
|
||||
(unless (string= error-data "")
|
||||
(with-temp-file ,async-byte-compile-log-file
|
||||
(erase-buffer)
|
||||
(insert error-data))))))
|
||||
call-back)
|
||||
(unless quiet (message "Started compiling asynchronously directory %s" directory))))
|
||||
|
||||
(defvar package-archive-contents)
|
||||
(defvar package-alist)
|
||||
(declare-function package-desc-reqs "package.el" (cl-x))
|
||||
|
||||
(defun async-bytecomp--get-package-deps (pkgs)
|
||||
;; Same as `package--get-deps' but parse instead `package-archive-contents'
|
||||
;; because PKG is not already installed and not present in `package-alist'.
|
||||
;; However fallback to `package-alist' in case PKG no more present
|
||||
;; in `package-archive-contents' due to modification to `package-archives'.
|
||||
;; See issue #58.
|
||||
(let ((seen '()))
|
||||
(while pkgs
|
||||
(let ((pkg (pop pkgs)))
|
||||
(unless (memq pkg seen)
|
||||
(let ((pkg-desc (cadr (or (assq pkg package-archive-contents)
|
||||
(assq pkg package-alist)))))
|
||||
(when pkg-desc
|
||||
(push pkg seen)
|
||||
(setq pkgs (append (mapcar #'car (package-desc-reqs pkg-desc))
|
||||
pkgs)))))))
|
||||
seen))
|
||||
|
||||
(defadvice package--compile (around byte-compile-async)
|
||||
(let ((cur-package (package-desc-name pkg-desc))
|
||||
(pkg-dir (package-desc-dir pkg-desc)))
|
||||
(if (or (member async-bytecomp-allowed-packages '(t all (all)))
|
||||
(memq cur-package (async-bytecomp--get-package-deps
|
||||
async-bytecomp-allowed-packages)))
|
||||
(progn
|
||||
(when (eq cur-package 'async)
|
||||
(fmakunbound 'async-byte-recompile-directory))
|
||||
;; Add to `load-path' the latest version of async and
|
||||
;; reload it when reinstalling async.
|
||||
(when (string= cur-package "async")
|
||||
(cl-pushnew pkg-dir load-path)
|
||||
(load "async-bytecomp"))
|
||||
;; `async-byte-recompile-directory' will add directory
|
||||
;; as needed to `load-path'.
|
||||
(async-byte-recompile-directory (package-desc-dir pkg-desc) t))
|
||||
ad-do-it)))
|
||||
|
||||
;;;###autoload
|
||||
(define-minor-mode async-bytecomp-package-mode
|
||||
"Byte compile asynchronously packages installed with package.el.
|
||||
Async compilation of packages can be controlled by
|
||||
`async-bytecomp-allowed-packages'."
|
||||
:group 'async
|
||||
:global t
|
||||
(if async-bytecomp-package-mode
|
||||
(ad-activate 'package--compile)
|
||||
(ad-deactivate 'package--compile)))
|
||||
|
||||
;;;###autoload
|
||||
(defun async-byte-compile-file (file)
|
||||
"Byte compile Lisp code FILE asynchronously.
|
||||
|
||||
Same as `byte-compile-file' but asynchronous."
|
||||
(interactive "fFile: ")
|
||||
(let ((call-back
|
||||
(lambda (&optional _ignore)
|
||||
(let ((bn (file-name-nondirectory file)))
|
||||
(if (file-exists-p async-byte-compile-log-file)
|
||||
(let ((buf (get-buffer-create byte-compile-log-buffer))
|
||||
start)
|
||||
(with-current-buffer buf
|
||||
(goto-char (setq start (point-max)))
|
||||
(let ((inhibit-read-only t))
|
||||
(insert-file-contents async-byte-compile-log-file)
|
||||
(compilation-mode))
|
||||
(display-buffer buf)
|
||||
(delete-file async-byte-compile-log-file)
|
||||
(save-excursion
|
||||
(goto-char start)
|
||||
(if (re-search-forward "^.*:Error:" nil t)
|
||||
(message "Failed to compile `%s'" bn)
|
||||
(message "`%s' compiled asynchronously with warnings" bn)))))
|
||||
(message "`%s' compiled asynchronously with success" bn))))))
|
||||
(async-start
|
||||
`(lambda ()
|
||||
(require 'bytecomp)
|
||||
,(async-inject-variables "\\`load-path\\'")
|
||||
(let ((default-directory ,(file-name-directory file)))
|
||||
(add-to-list 'load-path default-directory)
|
||||
(byte-compile-file ,file)
|
||||
(when (get-buffer byte-compile-log-buffer)
|
||||
(setq error-data (with-current-buffer byte-compile-log-buffer
|
||||
(buffer-substring-no-properties (point-min) (point-max))))
|
||||
(unless (string= error-data "")
|
||||
(with-temp-file ,async-byte-compile-log-file
|
||||
(erase-buffer)
|
||||
(insert error-data))))))
|
||||
call-back)))
|
||||
|
||||
(provide 'async-bytecomp)
|
||||
|
||||
;;; async-bytecomp.el ends here
|
Binary file not shown.
|
@ -1,8 +0,0 @@
|
|||
(define-package "async" "20200113.1745" "Asynchronous processing in Emacs"
|
||||
'((emacs "24.3"))
|
||||
:keywords
|
||||
'("async")
|
||||
:url "https://github.com/jwiegley/emacs-async")
|
||||
;; Local Variables:
|
||||
;; no-byte-compile: t
|
||||
;; End:
|
|
@ -1,408 +0,0 @@
|
|||
;;; async.el --- Asynchronous processing -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2012-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: John Wiegley <jwiegley@gmail.com>
|
||||
;; Created: 18 Jun 2012
|
||||
;; Version: 1.9.4
|
||||
;; Package-Requires: ((emacs "24.3"))
|
||||
;; Keywords: convenience async
|
||||
;; URL: https://github.com/jwiegley/emacs-async
|
||||
|
||||
;; This program is free software; you can redistribute it and/or
|
||||
;; modify it under the terms of the GNU General Public License as
|
||||
;; published by the Free Software Foundation; either version 2, or (at
|
||||
;; your option) any later version.
|
||||
|
||||
;; This program is distributed in the hope that it will be useful, but
|
||||
;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
;; General Public License for more details.
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
;; Boston, MA 02111-1307, USA.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Adds the ability to call asynchronous functions and process with ease. See
|
||||
;; the documentation for `async-start' and `async-start-process'.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(eval-when-compile (require 'cl-lib))
|
||||
|
||||
(defgroup async nil
|
||||
"Simple asynchronous processing in Emacs"
|
||||
:group 'emacs)
|
||||
|
||||
(defcustom async-variables-noprops-function #'async--purecopy
|
||||
"Default function to remove text properties in variables."
|
||||
:group 'async
|
||||
:type 'function)
|
||||
|
||||
(defvar async-debug nil)
|
||||
(defvar async-send-over-pipe t)
|
||||
(defvar async-in-child-emacs nil)
|
||||
(defvar async-callback nil)
|
||||
(defvar async-callback-for-process nil)
|
||||
(defvar async-callback-value nil)
|
||||
(defvar async-callback-value-set nil)
|
||||
(defvar async-current-process nil)
|
||||
(defvar async--procvar nil)
|
||||
|
||||
(defun async--purecopy (object)
|
||||
"Remove text properties in OBJECT.
|
||||
|
||||
Argument OBJECT may be a list or a string, if anything else it
|
||||
is returned unmodified."
|
||||
(cond ((stringp object)
|
||||
(substring-no-properties object))
|
||||
((consp object)
|
||||
(cl-loop for elm in object
|
||||
;; A string.
|
||||
if (stringp elm)
|
||||
collect (substring-no-properties elm)
|
||||
else
|
||||
;; Proper lists.
|
||||
if (and (consp elm) (null (cdr (last elm))))
|
||||
collect (async--purecopy elm)
|
||||
else
|
||||
;; Dotted lists.
|
||||
;; We handle here only dotted list where car and cdr
|
||||
;; are atoms i.e. (x . y) and not (x . (x . y)) or
|
||||
;; (x . (x y)) which should fit most cases.
|
||||
if (and (consp elm) (cdr (last elm)))
|
||||
collect (let ((key (car elm))
|
||||
(val (cdr elm)))
|
||||
(cons (if (stringp key)
|
||||
(substring-no-properties key)
|
||||
key)
|
||||
(if (stringp val)
|
||||
(substring-no-properties val)
|
||||
val)))
|
||||
else
|
||||
collect elm))
|
||||
(t object)))
|
||||
|
||||
(defun async-inject-variables
|
||||
(include-regexp &optional predicate exclude-regexp noprops)
|
||||
"Return a `setq' form that replicates part of the calling environment.
|
||||
|
||||
It sets the value for every variable matching INCLUDE-REGEXP and
|
||||
also PREDICATE. It will not perform injection for any variable
|
||||
matching EXCLUDE-REGEXP (if present) or representing a `syntax-table'
|
||||
i.e. ending by \"-syntax-table\".
|
||||
When NOPROPS is non nil it tries to strip out text properties of each
|
||||
variable's value with `async-variables-noprops-function'.
|
||||
|
||||
It is intended to be used as follows:
|
||||
|
||||
(async-start
|
||||
`(lambda ()
|
||||
(require 'smtpmail)
|
||||
(with-temp-buffer
|
||||
(insert ,(buffer-substring-no-properties (point-min) (point-max)))
|
||||
;; Pass in the variable environment for smtpmail
|
||||
,(async-inject-variables \"\\`\\(smtpmail\\|\\(user-\\)?mail\\)-\")
|
||||
(smtpmail-send-it)))
|
||||
'ignore)"
|
||||
`(setq
|
||||
,@(let (bindings)
|
||||
(mapatoms
|
||||
(lambda (sym)
|
||||
(let* ((sname (and (boundp sym) (symbol-name sym)))
|
||||
(value (and sname (symbol-value sym))))
|
||||
(when (and sname
|
||||
(or (null include-regexp)
|
||||
(string-match include-regexp sname))
|
||||
(or (null exclude-regexp)
|
||||
(not (string-match exclude-regexp sname)))
|
||||
(not (string-match "-syntax-table\\'" sname)))
|
||||
(unless (or (stringp value)
|
||||
(memq value '(nil t))
|
||||
(numberp value)
|
||||
(vectorp value))
|
||||
(setq value `(quote ,value)))
|
||||
(when noprops
|
||||
(setq value (funcall async-variables-noprops-function
|
||||
value)))
|
||||
(when (or (null predicate)
|
||||
(funcall predicate sym))
|
||||
(setq bindings (cons value bindings)
|
||||
bindings (cons sym bindings)))))))
|
||||
bindings)))
|
||||
|
||||
(defalias 'async-inject-environment 'async-inject-variables)
|
||||
|
||||
(defun async-handle-result (func result buf)
|
||||
(if (null func)
|
||||
(progn
|
||||
(set (make-local-variable 'async-callback-value) result)
|
||||
(set (make-local-variable 'async-callback-value-set) t))
|
||||
(unwind-protect
|
||||
(if (and (listp result)
|
||||
(eq 'async-signal (nth 0 result)))
|
||||
(signal (car (nth 1 result))
|
||||
(cdr (nth 1 result)))
|
||||
(funcall func result))
|
||||
(unless async-debug
|
||||
(kill-buffer buf)))))
|
||||
|
||||
(defun async-when-done (proc &optional _change)
|
||||
"Process sentinel used to retrieve the value from the child process."
|
||||
(when (eq 'exit (process-status proc))
|
||||
(with-current-buffer (process-buffer proc)
|
||||
(let ((async-current-process proc))
|
||||
(if (= 0 (process-exit-status proc))
|
||||
(if async-callback-for-process
|
||||
(if async-callback
|
||||
(prog1
|
||||
(funcall async-callback proc)
|
||||
(unless async-debug
|
||||
(kill-buffer (current-buffer))))
|
||||
(set (make-local-variable 'async-callback-value) proc)
|
||||
(set (make-local-variable 'async-callback-value-set) t))
|
||||
(goto-char (point-max))
|
||||
(backward-sexp)
|
||||
(async-handle-result async-callback (read (current-buffer))
|
||||
(current-buffer)))
|
||||
(set (make-local-variable 'async-callback-value)
|
||||
(list 'error
|
||||
(format "Async process '%s' failed with exit code %d"
|
||||
(process-name proc) (process-exit-status proc))))
|
||||
(set (make-local-variable 'async-callback-value-set) t))))))
|
||||
|
||||
(defun async--receive-sexp (&optional stream)
|
||||
(let ((sexp (decode-coding-string (base64-decode-string
|
||||
(read stream)) 'utf-8-auto))
|
||||
;; Parent expects UTF-8 encoded text.
|
||||
(coding-system-for-write 'utf-8-auto))
|
||||
(if async-debug
|
||||
(message "Received sexp {{{%s}}}" (pp-to-string sexp)))
|
||||
(setq sexp (read sexp))
|
||||
(if async-debug
|
||||
(message "Read sexp {{{%s}}}" (pp-to-string sexp)))
|
||||
(eval sexp)))
|
||||
|
||||
(defun async--insert-sexp (sexp)
|
||||
(let (print-level
|
||||
print-length
|
||||
(print-escape-nonascii t)
|
||||
(print-circle t))
|
||||
(prin1 sexp (current-buffer))
|
||||
;; Just in case the string we're sending might contain EOF
|
||||
(encode-coding-region (point-min) (point-max) 'utf-8-auto)
|
||||
(base64-encode-region (point-min) (point-max) t)
|
||||
(goto-char (point-min)) (insert ?\")
|
||||
(goto-char (point-max)) (insert ?\" ?\n)))
|
||||
|
||||
(defun async--transmit-sexp (process sexp)
|
||||
(with-temp-buffer
|
||||
(if async-debug
|
||||
(message "Transmitting sexp {{{%s}}}" (pp-to-string sexp)))
|
||||
(async--insert-sexp sexp)
|
||||
(process-send-region process (point-min) (point-max))))
|
||||
|
||||
(defun async-batch-invoke ()
|
||||
"Called from the child Emacs process' command line."
|
||||
;; Make sure 'message' and 'prin1' encode stuff in UTF-8, as parent
|
||||
;; process expects.
|
||||
(let ((coding-system-for-write 'utf-8-auto))
|
||||
(setq async-in-child-emacs t
|
||||
debug-on-error async-debug)
|
||||
(if debug-on-error
|
||||
(prin1 (funcall
|
||||
(async--receive-sexp (unless async-send-over-pipe
|
||||
command-line-args-left))))
|
||||
(condition-case err
|
||||
(prin1 (funcall
|
||||
(async--receive-sexp (unless async-send-over-pipe
|
||||
command-line-args-left))))
|
||||
(error
|
||||
(prin1 (list 'async-signal err)))))))
|
||||
|
||||
(defun async-ready (future)
|
||||
"Query a FUTURE to see if it is ready.
|
||||
|
||||
I.e., if no blocking
|
||||
would result from a call to `async-get' on that FUTURE."
|
||||
(and (memq (process-status future) '(exit signal))
|
||||
(let ((buf (process-buffer future)))
|
||||
(if (buffer-live-p buf)
|
||||
(with-current-buffer buf
|
||||
async-callback-value-set)
|
||||
t))))
|
||||
|
||||
(defun async-wait (future)
|
||||
"Wait for FUTURE to become ready."
|
||||
(while (not (async-ready future))
|
||||
(sleep-for 0.05)))
|
||||
|
||||
(defun async-get (future)
|
||||
"Get the value from process FUTURE when it is ready.
|
||||
FUTURE is returned by `async-start' or `async-start-process' when
|
||||
its FINISH-FUNC is nil."
|
||||
(and future (async-wait future))
|
||||
(let ((buf (process-buffer future)))
|
||||
(when (buffer-live-p buf)
|
||||
(with-current-buffer buf
|
||||
(async-handle-result
|
||||
#'identity async-callback-value (current-buffer))))))
|
||||
|
||||
(defun async-message-p (value)
|
||||
"Return non-nil of VALUE is an async.el message packet."
|
||||
(and (listp value)
|
||||
(plist-get value :async-message)))
|
||||
|
||||
(defun async-send (&rest args)
|
||||
"Send the given messages to the asychronous Emacs PROCESS."
|
||||
(let ((args (append args '(:async-message t))))
|
||||
(if async-in-child-emacs
|
||||
(if async-callback
|
||||
(funcall async-callback args))
|
||||
(async--transmit-sexp (car args) (list 'quote (cdr args))))))
|
||||
|
||||
(defun async-receive ()
|
||||
"Send the given messages to the asychronous Emacs PROCESS."
|
||||
(async--receive-sexp))
|
||||
|
||||
;;;###autoload
|
||||
(defun async-start-process (name program finish-func &rest program-args)
|
||||
"Start the executable PROGRAM asynchronously named NAME. See `async-start'.
|
||||
PROGRAM is passed PROGRAM-ARGS, calling FINISH-FUNC with the
|
||||
process object when done. If FINISH-FUNC is nil, the future
|
||||
object will return the process object when the program is
|
||||
finished. Set DEFAULT-DIRECTORY to change PROGRAM's current
|
||||
working directory."
|
||||
(let* ((buf (generate-new-buffer (concat "*" name "*")))
|
||||
(proc (let ((process-connection-type nil))
|
||||
(apply #'start-process name buf program program-args))))
|
||||
(with-current-buffer buf
|
||||
(set (make-local-variable 'async-callback) finish-func)
|
||||
(set-process-sentinel proc #'async-when-done)
|
||||
(unless (string= name "emacs")
|
||||
(set (make-local-variable 'async-callback-for-process) t))
|
||||
proc)))
|
||||
|
||||
(defvar async-quiet-switch "-Q"
|
||||
"The Emacs parameter to use to call emacs without config.
|
||||
Can be one of \"-Q\" or \"-q\".
|
||||
Default is \"-Q\" but it is sometimes useful to use \"-q\" to have a
|
||||
enhanced config or some more variables loaded.")
|
||||
|
||||
;;;###autoload
|
||||
(defun async-start (start-func &optional finish-func)
|
||||
"Execute START-FUNC (often a lambda) in a subordinate Emacs process.
|
||||
When done, the return value is passed to FINISH-FUNC. Example:
|
||||
|
||||
(async-start
|
||||
;; What to do in the child process
|
||||
(lambda ()
|
||||
(message \"This is a test\")
|
||||
(sleep-for 3)
|
||||
222)
|
||||
|
||||
;; What to do when it finishes
|
||||
(lambda (result)
|
||||
(message \"Async process done, result should be 222: %s\"
|
||||
result)))
|
||||
|
||||
If FINISH-FUNC is nil or missing, a future is returned that can
|
||||
be inspected using `async-get', blocking until the value is
|
||||
ready. Example:
|
||||
|
||||
(let ((proc (async-start
|
||||
;; What to do in the child process
|
||||
(lambda ()
|
||||
(message \"This is a test\")
|
||||
(sleep-for 3)
|
||||
222))))
|
||||
|
||||
(message \"I'm going to do some work here\") ;; ....
|
||||
|
||||
(message \"Waiting on async process, result should be 222: %s\"
|
||||
(async-get proc)))
|
||||
|
||||
If you don't want to use a callback, and you don't care about any
|
||||
return value from the child process, pass the `ignore' symbol as
|
||||
the second argument (if you don't, and never call `async-get', it
|
||||
will leave *emacs* process buffers hanging around):
|
||||
|
||||
(async-start
|
||||
(lambda ()
|
||||
(delete-file \"a remote file on a slow link\" nil))
|
||||
'ignore)
|
||||
|
||||
Note: Even when FINISH-FUNC is present, a future is still
|
||||
returned except that it yields no value (since the value is
|
||||
passed to FINISH-FUNC). Call `async-get' on such a future always
|
||||
returns nil. It can still be useful, however, as an argument to
|
||||
`async-ready' or `async-wait'."
|
||||
(let ((sexp start-func)
|
||||
;; Subordinate Emacs will send text encoded in UTF-8.
|
||||
(coding-system-for-read 'utf-8-auto))
|
||||
(setq async--procvar
|
||||
(async-start-process
|
||||
"emacs" (file-truename
|
||||
(expand-file-name invocation-name
|
||||
invocation-directory))
|
||||
finish-func
|
||||
async-quiet-switch "-l"
|
||||
;; Using `locate-library' ensure we use the right file
|
||||
;; when the .elc have been deleted.
|
||||
(locate-library "async")
|
||||
"-batch" "-f" "async-batch-invoke"
|
||||
(if async-send-over-pipe
|
||||
"<none>"
|
||||
(with-temp-buffer
|
||||
(async--insert-sexp (list 'quote sexp))
|
||||
(buffer-string)))))
|
||||
(if async-send-over-pipe
|
||||
(async--transmit-sexp async--procvar (list 'quote sexp)))
|
||||
async--procvar))
|
||||
|
||||
(defmacro async-sandbox(func)
|
||||
"Evaluate FUNC in a separate Emacs process, synchronously."
|
||||
`(async-get (async-start ,func)))
|
||||
|
||||
(defun async--fold-left (fn forms bindings)
|
||||
(let ((res forms))
|
||||
(dolist (binding bindings)
|
||||
(setq res (funcall fn res
|
||||
(if (listp binding)
|
||||
binding
|
||||
(list binding)))))
|
||||
res))
|
||||
|
||||
(defmacro async-let (bindings &rest forms)
|
||||
"Implements `let', but each binding is established asynchronously.
|
||||
For example:
|
||||
|
||||
(async-let ((x (foo))
|
||||
(y (bar)))
|
||||
(message \"%s %s\" x y))
|
||||
|
||||
expands to ==>
|
||||
|
||||
(async-start (foo)
|
||||
(lambda (x)
|
||||
(async-start (bar)
|
||||
(lambda (y)
|
||||
(message \"%s %s\" x y)))))"
|
||||
(declare (indent 1))
|
||||
(async--fold-left
|
||||
(lambda (acc binding)
|
||||
(let ((fun (pcase (cadr binding)
|
||||
((and (pred functionp) f) f)
|
||||
(f `(lambda () ,f)))))
|
||||
`(async-start ,fun
|
||||
(lambda (,(car binding))
|
||||
,acc))))
|
||||
`(progn ,@forms)
|
||||
(reverse bindings)))
|
||||
|
||||
(provide 'async)
|
||||
|
||||
;;; async.el ends here
|
Binary file not shown.
|
@ -1,408 +0,0 @@
|
|||
;;; dired-async.el --- Asynchronous dired actions -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2012-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Authors: John Wiegley <jwiegley@gmail.com>
|
||||
;; Thierry Volpiatto <thierry.volpiatto@gmail.com>
|
||||
|
||||
;; Keywords: dired async network
|
||||
;; X-URL: https://github.com/jwiegley/dired-async
|
||||
|
||||
;; This program is free software; you can redistribute it and/or
|
||||
;; modify it under the terms of the GNU General Public License as
|
||||
;; published by the Free Software Foundation; either version 2, or (at
|
||||
;; your option) any later version.
|
||||
|
||||
;; This program is distributed in the hope that it will be useful, but
|
||||
;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
;; General Public License for more details.
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
;; Boston, MA 02111-1307, USA.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; This file provide a redefinition of `dired-create-file' function,
|
||||
;; performs copies, moves and all what is handled by `dired-create-file'
|
||||
;; in the background using a slave Emacs process,
|
||||
;; by means of the async.el module.
|
||||
;; To use it, put this in your .emacs:
|
||||
|
||||
;; (dired-async-mode 1)
|
||||
|
||||
;; This will enable async copy/rename etc...
|
||||
;; in dired and helm.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'cl-lib)
|
||||
(require 'dired-aux)
|
||||
(require 'async)
|
||||
|
||||
(eval-when-compile
|
||||
(defvar async-callback))
|
||||
|
||||
(defgroup dired-async nil
|
||||
"Copy rename files asynchronously from dired."
|
||||
:group 'dired)
|
||||
|
||||
(defcustom dired-async-env-variables-regexp
|
||||
"\\`\\(tramp-\\(default\\|connection\\|remote\\)\\|ange-ftp\\)-.*"
|
||||
"Variables matching this regexp will be loaded on Child Emacs."
|
||||
:type 'regexp
|
||||
:group 'dired-async)
|
||||
|
||||
(defcustom dired-async-message-function 'dired-async-mode-line-message
|
||||
"Function to use to notify result when operation finish.
|
||||
Should take same args as `message'."
|
||||
:group 'dired-async
|
||||
:type 'function)
|
||||
|
||||
(defcustom dired-async-log-file "/tmp/dired-async.log"
|
||||
"File use to communicate errors from Child Emacs to host Emacs."
|
||||
:group 'dired-async
|
||||
:type 'string)
|
||||
|
||||
(defcustom dired-async-mode-lighter '(:eval
|
||||
(when (eq major-mode 'dired-mode)
|
||||
" Async"))
|
||||
"Mode line lighter used for `dired-async-mode'."
|
||||
:group 'dired-async
|
||||
:risky t
|
||||
:type 'sexp)
|
||||
|
||||
(defface dired-async-message
|
||||
'((t (:foreground "yellow")))
|
||||
"Face used for mode-line message."
|
||||
:group 'dired-async)
|
||||
|
||||
(defface dired-async-failures
|
||||
'((t (:foreground "red")))
|
||||
"Face used for mode-line message."
|
||||
:group 'dired-async)
|
||||
|
||||
(defface dired-async-mode-message
|
||||
'((t (:foreground "Gold")))
|
||||
"Face used for `dired-async--modeline-mode' lighter."
|
||||
:group 'dired-async)
|
||||
|
||||
(define-minor-mode dired-async--modeline-mode
|
||||
"Notify mode-line that an async process run."
|
||||
:group 'dired-async
|
||||
:global t
|
||||
:lighter (:eval (propertize (format " [%s Async job(s) running]"
|
||||
(length (dired-async-processes)))
|
||||
'face 'dired-async-mode-message))
|
||||
(unless dired-async--modeline-mode
|
||||
(let ((visible-bell t)) (ding))))
|
||||
|
||||
(defun dired-async-mode-line-message (text face &rest args)
|
||||
"Notify end of operation in `mode-line'."
|
||||
(message nil)
|
||||
(let ((mode-line-format (concat
|
||||
" " (propertize
|
||||
(if args
|
||||
(apply #'format text args)
|
||||
text)
|
||||
'face face))))
|
||||
(force-mode-line-update)
|
||||
(sit-for 3)
|
||||
(force-mode-line-update)))
|
||||
|
||||
(defun dired-async-processes ()
|
||||
(cl-loop for p in (process-list)
|
||||
when (cl-loop for c in (process-command p) thereis
|
||||
(string= "async-batch-invoke" c))
|
||||
collect p))
|
||||
|
||||
(defun dired-async-kill-process ()
|
||||
(interactive)
|
||||
(let* ((processes (dired-async-processes))
|
||||
(proc (car (last processes))))
|
||||
(and proc (delete-process proc))
|
||||
(unless (> (length processes) 1)
|
||||
(dired-async--modeline-mode -1))))
|
||||
|
||||
(defun dired-async-after-file-create (total operation failures skipped)
|
||||
"Callback function used for operation handled by `dired-create-file'."
|
||||
(unless (dired-async-processes)
|
||||
;; Turn off mode-line notification
|
||||
;; only when last process end.
|
||||
(dired-async--modeline-mode -1))
|
||||
(when operation
|
||||
(if (file-exists-p dired-async-log-file)
|
||||
(progn
|
||||
(pop-to-buffer (get-buffer-create dired-log-buffer))
|
||||
(goto-char (point-max))
|
||||
(setq inhibit-read-only t)
|
||||
(insert "Error: ")
|
||||
(insert-file-contents dired-async-log-file)
|
||||
(special-mode)
|
||||
(shrink-window-if-larger-than-buffer)
|
||||
(delete-file dired-async-log-file))
|
||||
(run-with-timer
|
||||
0.1 nil
|
||||
(lambda ()
|
||||
;; First send error messages.
|
||||
(cond (failures
|
||||
(funcall dired-async-message-function
|
||||
"%s failed for %d of %d file%s -- See *Dired log* buffer"
|
||||
'dired-async-failures
|
||||
(car operation) (length failures)
|
||||
total (dired-plural-s total)))
|
||||
(skipped
|
||||
(funcall dired-async-message-function
|
||||
"%s: %d of %d file%s skipped -- See *Dired log* buffer"
|
||||
'dired-async-failures
|
||||
(car operation) (length skipped) total
|
||||
(dired-plural-s total))))
|
||||
(when dired-buffers
|
||||
(cl-loop for (_f . b) in dired-buffers
|
||||
when (buffer-live-p b)
|
||||
do (with-current-buffer b
|
||||
(when (and (not (file-remote-p default-directory nil t))
|
||||
(file-exists-p default-directory))
|
||||
(revert-buffer nil t)))))
|
||||
;; Finally send the success message.
|
||||
(funcall dired-async-message-function
|
||||
"Asynchronous %s of %s on %s file%s done"
|
||||
'dired-async-message
|
||||
(car operation) (cadr operation)
|
||||
total (dired-plural-s total)))))))
|
||||
|
||||
(defun dired-async-maybe-kill-ftp ()
|
||||
"Return a form to kill ftp process in child emacs."
|
||||
(quote
|
||||
(progn
|
||||
(require 'cl-lib)
|
||||
(let ((buf (cl-loop for b in (buffer-list)
|
||||
thereis (and (string-match
|
||||
"\\`\\*ftp.*"
|
||||
(buffer-name b)) b))))
|
||||
(when buf (kill-buffer buf))))))
|
||||
|
||||
(defvar overwrite-query)
|
||||
(defun dired-async-create-files (file-creator operation fn-list name-constructor
|
||||
&optional _marker-char)
|
||||
"Same as `dired-create-files' but asynchronous.
|
||||
|
||||
See `dired-create-files' for the behavior of arguments."
|
||||
(setq overwrite-query nil)
|
||||
(let ((total (length fn-list))
|
||||
failures async-fn-list skipped callback
|
||||
async-quiet-switch)
|
||||
(let (to)
|
||||
(dolist (from fn-list)
|
||||
(setq to (funcall name-constructor from))
|
||||
(if (and (equal to from)
|
||||
(null (eq file-creator 'backup-file)))
|
||||
(progn
|
||||
(setq to nil)
|
||||
(dired-log "Cannot %s to same file: %s\n"
|
||||
(downcase operation) from)))
|
||||
(if (not to)
|
||||
(setq skipped (cons (dired-make-relative from) skipped))
|
||||
(let* ((overwrite (and (null (eq file-creator 'backup-file))
|
||||
(file-exists-p to)))
|
||||
(dired-overwrite-confirmed ; for dired-handle-overwrite
|
||||
(and overwrite
|
||||
(let ((help-form `(format "\
|
||||
Type SPC or `y' to overwrite file `%s',
|
||||
DEL or `n' to skip to next,
|
||||
ESC or `q' to not overwrite any of the remaining files,
|
||||
`!' to overwrite all remaining files with no more questions." ,to)))
|
||||
(dired-query 'overwrite-query "Overwrite `%s'?" to)))))
|
||||
;; Handle the `dired-copy-file' file-creator specially
|
||||
;; When copying a directory to another directory or
|
||||
;; possibly to itself or one of its subdirectories.
|
||||
;; e.g "~/foo/" => "~/test/"
|
||||
;; or "~/foo/" =>"~/foo/"
|
||||
;; or "~/foo/ => ~/foo/bar/")
|
||||
;; In this case the 'name-constructor' have set the destination
|
||||
;; TO to "~/test/foo" because the old emacs23 behavior
|
||||
;; of `copy-directory' was to not create the subdirectory
|
||||
;; and instead copy the contents.
|
||||
;; With the new behavior of `copy-directory'
|
||||
;; (similar to the `cp' shell command) we don't
|
||||
;; need such a construction of the target directory,
|
||||
;; so modify the destination TO to "~/test/" instead of "~/test/foo/".
|
||||
(let ((destname (file-name-directory to)))
|
||||
(when (and (file-directory-p from)
|
||||
(file-directory-p to)
|
||||
(eq file-creator 'dired-copy-file))
|
||||
(setq to destname))
|
||||
;; If DESTNAME is a subdirectory of FROM, not a symlink,
|
||||
;; and the method in use is copying, signal an error.
|
||||
(and (eq t (car (file-attributes destname)))
|
||||
(eq file-creator 'dired-copy-file)
|
||||
(file-in-directory-p destname from)
|
||||
(error "Cannot copy `%s' into its subdirectory `%s'"
|
||||
from to)))
|
||||
(if overwrite
|
||||
(or (and dired-overwrite-confirmed
|
||||
(push (cons from to) async-fn-list))
|
||||
(progn
|
||||
(push (dired-make-relative from) failures)
|
||||
(dired-log "%s `%s' to `%s' failed\n"
|
||||
operation from to)))
|
||||
(push (cons from to) async-fn-list)))))
|
||||
;; Fix tramp issue #80 with emacs-26, use "-q" only when needed.
|
||||
(setq async-quiet-switch
|
||||
(if (and (boundp 'tramp-cache-read-persistent-data)
|
||||
async-fn-list
|
||||
(cl-loop for (_from . to) in async-fn-list
|
||||
thereis (file-remote-p to)))
|
||||
"-q" "-Q"))
|
||||
;; When failures have been printed to dired log add the date at bob.
|
||||
(when (or failures skipped) (dired-log t))
|
||||
;; When async-fn-list is empty that's mean only one file
|
||||
;; had to be copied and user finally answer NO.
|
||||
;; In this case async process will never start and callback
|
||||
;; will have no chance to run, so notify failures here.
|
||||
(unless async-fn-list
|
||||
(cond (failures
|
||||
(funcall dired-async-message-function
|
||||
"%s failed for %d of %d file%s -- See *Dired log* buffer"
|
||||
'dired-async-failures
|
||||
operation (length failures)
|
||||
total (dired-plural-s total)))
|
||||
(skipped
|
||||
(funcall dired-async-message-function
|
||||
"%s: %d of %d file%s skipped -- See *Dired log* buffer"
|
||||
'dired-async-failures
|
||||
operation (length skipped) total
|
||||
(dired-plural-s total)))))
|
||||
;; Setup callback.
|
||||
(setq callback
|
||||
(lambda (&optional _ignore)
|
||||
(dired-async-after-file-create
|
||||
total (list operation (length async-fn-list)) failures skipped)
|
||||
(when (string= (downcase operation) "rename")
|
||||
(cl-loop for (file . to) in async-fn-list
|
||||
for bf = (get-file-buffer file)
|
||||
for destp = (file-exists-p to)
|
||||
do (and bf destp
|
||||
(with-current-buffer bf
|
||||
(set-visited-file-name to t t))))))))
|
||||
;; Start async process.
|
||||
(when async-fn-list
|
||||
(async-start `(lambda ()
|
||||
(require 'cl-lib) (require 'dired-aux) (require 'dired-x)
|
||||
,(async-inject-variables dired-async-env-variables-regexp)
|
||||
(let ((dired-recursive-copies (quote always))
|
||||
(dired-copy-preserve-time
|
||||
,dired-copy-preserve-time))
|
||||
(setq overwrite-backup-query nil)
|
||||
;; Inline `backup-file' as long as it is not
|
||||
;; available in emacs.
|
||||
(defalias 'backup-file
|
||||
;; Same feature as "cp -f --backup=numbered from to"
|
||||
;; Symlinks are copied as file from source unlike
|
||||
;; `dired-copy-file' which is same as cp -d.
|
||||
;; Directories are omitted.
|
||||
(lambda (from to ok)
|
||||
(cond ((file-directory-p from) (ignore))
|
||||
(t (let ((count 0))
|
||||
(while (let ((attrs (file-attributes to)))
|
||||
(and attrs (null (nth 0 attrs))))
|
||||
(cl-incf count)
|
||||
(setq to (concat (file-name-sans-versions to)
|
||||
(format ".~%s~" count)))))
|
||||
(condition-case err
|
||||
(copy-file from to ok dired-copy-preserve-time)
|
||||
(file-date-error
|
||||
(dired-log "Can't set date on %s:\n%s\n" from err)))))))
|
||||
;; Now run the FILE-CREATOR function on files.
|
||||
(cl-loop with fn = (quote ,file-creator)
|
||||
for (from . dest) in (quote ,async-fn-list)
|
||||
do (condition-case err
|
||||
(funcall fn from dest t)
|
||||
(file-error
|
||||
(dired-log "%s: %s\n" (car err) (cdr err)))
|
||||
nil))
|
||||
(when (get-buffer dired-log-buffer)
|
||||
(dired-log t)
|
||||
(with-current-buffer dired-log-buffer
|
||||
(write-region (point-min) (point-max)
|
||||
,dired-async-log-file))))
|
||||
,(dired-async-maybe-kill-ftp))
|
||||
callback)
|
||||
;; Run mode-line notifications while process running.
|
||||
(dired-async--modeline-mode 1)
|
||||
(message "%s proceeding asynchronously..." operation))))
|
||||
|
||||
(defvar wdired-use-interactive-rename)
|
||||
(defun dired-async-wdired-do-renames (old-fn &rest args)
|
||||
;; Perhaps a better fix would be to ask for renaming BEFORE starting
|
||||
;; OLD-FN when `wdired-use-interactive-rename' is non-nil. For now
|
||||
;; just bind it to nil to ensure no questions will be asked between
|
||||
;; each rename.
|
||||
(let (wdired-use-interactive-rename)
|
||||
(apply old-fn args)))
|
||||
|
||||
(defadvice wdired-do-renames (around wdired-async)
|
||||
(let (wdired-use-interactive-rename)
|
||||
ad-do-it))
|
||||
|
||||
(defadvice dired-create-files (around dired-async)
|
||||
(dired-async-create-files file-creator operation fn-list
|
||||
name-constructor marker-char))
|
||||
|
||||
;;;###autoload
|
||||
(define-minor-mode dired-async-mode
|
||||
"Do dired actions asynchronously."
|
||||
:group 'dired-async
|
||||
:lighter dired-async-mode-lighter
|
||||
:global t
|
||||
(if dired-async-mode
|
||||
(if (fboundp 'advice-add)
|
||||
(progn (advice-add 'dired-create-files :override #'dired-async-create-files)
|
||||
(advice-add 'wdired-do-renames :around #'dired-async-wdired-do-renames))
|
||||
(ad-activate 'dired-create-files)
|
||||
(ad-activate 'wdired-do-renames))
|
||||
(if (fboundp 'advice-remove)
|
||||
(progn (advice-remove 'dired-create-files #'dired-async-create-files)
|
||||
(advice-remove 'wdired-do-renames #'dired-async-wdired-do-renames))
|
||||
(ad-deactivate 'dired-create-files)
|
||||
(ad-deactivate 'wdired-do-renames))))
|
||||
|
||||
(defmacro dired-async--with-async-create-files (&rest body)
|
||||
"Evaluate BODY with ‘dired-create-files’ set to ‘dired-async-create-files’."
|
||||
(declare (indent 0))
|
||||
`(cl-letf (((symbol-function 'dired-create-files) #'dired-async-create-files))
|
||||
,@body))
|
||||
|
||||
;;;###autoload
|
||||
(defun dired-async-do-copy (&optional arg)
|
||||
"Run ‘dired-do-copy’ asynchronously."
|
||||
(interactive "P")
|
||||
(dired-async--with-async-create-files
|
||||
(dired-do-copy arg)))
|
||||
|
||||
;;;###autoload
|
||||
(defun dired-async-do-symlink (&optional arg)
|
||||
"Run ‘dired-do-symlink’ asynchronously."
|
||||
(interactive "P")
|
||||
(dired-async--with-async-create-files
|
||||
(dired-do-symlink arg)))
|
||||
|
||||
;;;###autoload
|
||||
(defun dired-async-do-hardlink (&optional arg)
|
||||
"Run ‘dired-do-hardlink’ asynchronously."
|
||||
(interactive "P")
|
||||
(dired-async--with-async-create-files
|
||||
(dired-do-hardlink arg)))
|
||||
|
||||
;;;###autoload
|
||||
(defun dired-async-do-rename (&optional arg)
|
||||
"Run ‘dired-do-rename’ asynchronously."
|
||||
(interactive "P")
|
||||
(dired-async--with-async-create-files
|
||||
(dired-do-rename arg)))
|
||||
|
||||
(provide 'dired-async)
|
||||
|
||||
;;; dired-async.el ends here
|
Binary file not shown.
|
@ -1,73 +0,0 @@
|
|||
;;; smtpmail-async.el --- Send e-mail with smtpmail.el asynchronously -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2012-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: John Wiegley <jwiegley@gmail.com>
|
||||
;; Created: 18 Jun 2012
|
||||
|
||||
;; Keywords: email async
|
||||
;; X-URL: https://github.com/jwiegley/emacs-async
|
||||
|
||||
;; This program is free software; you can redistribute it and/or
|
||||
;; modify it under the terms of the GNU General Public License as
|
||||
;; published by the Free Software Foundation; either version 2, or (at
|
||||
;; your option) any later version.
|
||||
|
||||
;; This program is distributed in the hope that it will be useful, but
|
||||
;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
;; General Public License for more details.
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
;; Boston, MA 02111-1307, USA.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Send e-mail with smtpmail.el asynchronously. To use:
|
||||
;;
|
||||
;; (require 'smtpmail-async)
|
||||
;;
|
||||
;; (setq send-mail-function 'async-smtpmail-send-it
|
||||
;; message-send-mail-function 'async-smtpmail-send-it)
|
||||
;;
|
||||
;; This assumes you already have smtpmail.el working.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(defgroup smtpmail-async nil
|
||||
"Send e-mail with smtpmail.el asynchronously"
|
||||
:group 'smptmail)
|
||||
|
||||
(require 'async)
|
||||
(require 'smtpmail)
|
||||
(require 'message)
|
||||
|
||||
(defvar async-smtpmail-before-send-hook nil
|
||||
"Hook running in the child emacs in `async-smtpmail-send-it'.
|
||||
It is called just before calling `smtpmail-send-it'.")
|
||||
|
||||
(defun async-smtpmail-send-it ()
|
||||
(let ((to (message-field-value "To"))
|
||||
(buf-content (buffer-substring-no-properties
|
||||
(point-min) (point-max))))
|
||||
(message "Delivering message to %s..." to)
|
||||
(async-start
|
||||
`(lambda ()
|
||||
(require 'smtpmail)
|
||||
(with-temp-buffer
|
||||
(insert ,buf-content)
|
||||
(set-buffer-multibyte nil)
|
||||
;; Pass in the variable environment for smtpmail
|
||||
,(async-inject-variables
|
||||
"\\`\\(smtpmail\\|async-smtpmail\\|\\(user-\\)?mail\\)-\\|auth-sources\\|epg\\|nsm"
|
||||
nil "\\`\\(mail-header-format-function\\|smtpmail-address-buffer\\|mail-mode-abbrev-table\\)")
|
||||
(run-hooks 'async-smtpmail-before-send-hook)
|
||||
(smtpmail-send-it)))
|
||||
(lambda (&optional _ignore)
|
||||
(message "Delivering message to %s...done" to)))))
|
||||
|
||||
(provide 'smtpmail-async)
|
||||
|
||||
;;; smtpmail-async.el ends here
|
Binary file not shown.
|
@ -1 +0,0 @@
|
|||
An Emacs port of the Atom One Dark theme from Atom.io.
|
|
@ -1,272 +0,0 @@
|
|||
;;; avy-autoloads.el --- automatically extracted autoloads
|
||||
;;
|
||||
;;; Code:
|
||||
|
||||
(add-to-list 'load-path (directory-file-name
|
||||
(or (file-name-directory #$) (car load-path))))
|
||||
|
||||
|
||||
;;;### (autoloads nil "avy" "avy.el" (0 0 0 0))
|
||||
;;; Generated autoloads from avy.el
|
||||
|
||||
(autoload 'avy-goto-char "avy" "\
|
||||
Jump to the currently visible CHAR.
|
||||
The window scope is determined by `avy-all-windows' (ARG negates it).
|
||||
|
||||
\(fn CHAR &optional ARG)" t nil)
|
||||
|
||||
(autoload 'avy-goto-char-in-line "avy" "\
|
||||
Jump to the currently visible CHAR in the current line.
|
||||
|
||||
\(fn CHAR)" t nil)
|
||||
|
||||
(autoload 'avy-goto-char-2 "avy" "\
|
||||
Jump to the currently visible CHAR1 followed by CHAR2.
|
||||
The window scope is determined by `avy-all-windows'.
|
||||
When ARG is non-nil, do the opposite of `avy-all-windows'.
|
||||
BEG and END narrow the scope where candidates are searched.
|
||||
|
||||
\(fn CHAR1 CHAR2 &optional ARG BEG END)" t nil)
|
||||
|
||||
(autoload 'avy-goto-char-2-above "avy" "\
|
||||
Jump to the currently visible CHAR1 followed by CHAR2.
|
||||
This is a scoped version of `avy-goto-char-2', where the scope is
|
||||
the visible part of the current buffer up to point.
|
||||
The window scope is determined by `avy-all-windows'.
|
||||
When ARG is non-nil, do the opposite of `avy-all-windows'.
|
||||
|
||||
\(fn CHAR1 CHAR2 &optional ARG)" t nil)
|
||||
|
||||
(autoload 'avy-goto-char-2-below "avy" "\
|
||||
Jump to the currently visible CHAR1 followed by CHAR2.
|
||||
This is a scoped version of `avy-goto-char-2', where the scope is
|
||||
the visible part of the current buffer following point.
|
||||
The window scope is determined by `avy-all-windows'.
|
||||
When ARG is non-nil, do the opposite of `avy-all-windows'.
|
||||
|
||||
\(fn CHAR1 CHAR2 &optional ARG)" t nil)
|
||||
|
||||
(autoload 'avy-isearch "avy" "\
|
||||
Jump to one of the current isearch candidates.
|
||||
|
||||
\(fn)" t nil)
|
||||
|
||||
(autoload 'avy-goto-word-0 "avy" "\
|
||||
Jump to a word start.
|
||||
The window scope is determined by `avy-all-windows'.
|
||||
When ARG is non-nil, do the opposite of `avy-all-windows'.
|
||||
BEG and END narrow the scope where candidates are searched.
|
||||
|
||||
\(fn ARG &optional BEG END)" t nil)
|
||||
|
||||
(autoload 'avy-goto-whitespace-end "avy" "\
|
||||
Jump to the end of a whitespace sequence.
|
||||
The window scope is determined by `avy-all-windows'.
|
||||
When ARG is non-nil, do the opposite of `avy-all-windows'.
|
||||
BEG and END narrow the scope where candidates are searched.
|
||||
|
||||
\(fn ARG &optional BEG END)" t nil)
|
||||
|
||||
(autoload 'avy-goto-word-1 "avy" "\
|
||||
Jump to the currently visible CHAR at a word start.
|
||||
The window scope is determined by `avy-all-windows'.
|
||||
When ARG is non-nil, do the opposite of `avy-all-windows'.
|
||||
BEG and END narrow the scope where candidates are searched.
|
||||
When SYMBOL is non-nil, jump to symbol start instead of word start.
|
||||
|
||||
\(fn CHAR &optional ARG BEG END SYMBOL)" t nil)
|
||||
|
||||
(autoload 'avy-goto-word-1-above "avy" "\
|
||||
Jump to the currently visible CHAR at a word start.
|
||||
This is a scoped version of `avy-goto-word-1', where the scope is
|
||||
the visible part of the current buffer up to point.
|
||||
The window scope is determined by `avy-all-windows'.
|
||||
When ARG is non-nil, do the opposite of `avy-all-windows'.
|
||||
|
||||
\(fn CHAR &optional ARG)" t nil)
|
||||
|
||||
(autoload 'avy-goto-word-1-below "avy" "\
|
||||
Jump to the currently visible CHAR at a word start.
|
||||
This is a scoped version of `avy-goto-word-1', where the scope is
|
||||
the visible part of the current buffer following point.
|
||||
The window scope is determined by `avy-all-windows'.
|
||||
When ARG is non-nil, do the opposite of `avy-all-windows'.
|
||||
|
||||
\(fn CHAR &optional ARG)" t nil)
|
||||
|
||||
(autoload 'avy-goto-symbol-1 "avy" "\
|
||||
Jump to the currently visible CHAR at a symbol start.
|
||||
The window scope is determined by `avy-all-windows'.
|
||||
When ARG is non-nil, do the opposite of `avy-all-windows'.
|
||||
|
||||
\(fn CHAR &optional ARG)" t nil)
|
||||
|
||||
(autoload 'avy-goto-symbol-1-above "avy" "\
|
||||
Jump to the currently visible CHAR at a symbol start.
|
||||
This is a scoped version of `avy-goto-symbol-1', where the scope is
|
||||
the visible part of the current buffer up to point.
|
||||
The window scope is determined by `avy-all-windows'.
|
||||
When ARG is non-nil, do the opposite of `avy-all-windows'.
|
||||
|
||||
\(fn CHAR &optional ARG)" t nil)
|
||||
|
||||
(autoload 'avy-goto-symbol-1-below "avy" "\
|
||||
Jump to the currently visible CHAR at a symbol start.
|
||||
This is a scoped version of `avy-goto-symbol-1', where the scope is
|
||||
the visible part of the current buffer following point.
|
||||
The window scope is determined by `avy-all-windows'.
|
||||
When ARG is non-nil, do the opposite of `avy-all-windows'.
|
||||
|
||||
\(fn CHAR &optional ARG)" t nil)
|
||||
|
||||
(autoload 'avy-goto-subword-0 "avy" "\
|
||||
Jump to a word or subword start.
|
||||
The window scope is determined by `avy-all-windows' (ARG negates it).
|
||||
|
||||
When PREDICATE is non-nil it's a function of zero parameters that
|
||||
should return true.
|
||||
|
||||
BEG and END narrow the scope where candidates are searched.
|
||||
|
||||
\(fn &optional ARG PREDICATE BEG END)" t nil)
|
||||
|
||||
(autoload 'avy-goto-subword-1 "avy" "\
|
||||
Jump to the currently visible CHAR at a subword start.
|
||||
The window scope is determined by `avy-all-windows' (ARG negates it).
|
||||
The case of CHAR is ignored.
|
||||
|
||||
\(fn CHAR &optional ARG)" t nil)
|
||||
|
||||
(autoload 'avy-goto-word-or-subword-1 "avy" "\
|
||||
Forward to `avy-goto-subword-1' or `avy-goto-word-1'.
|
||||
Which one depends on variable `subword-mode'.
|
||||
|
||||
\(fn)" t nil)
|
||||
|
||||
(autoload 'avy-goto-line "avy" "\
|
||||
Jump to a line start in current buffer.
|
||||
|
||||
When ARG is 1, jump to lines currently visible, with the option
|
||||
to cancel to `goto-line' by entering a number.
|
||||
|
||||
When ARG is 4, negate the window scope determined by
|
||||
`avy-all-windows'.
|
||||
|
||||
Otherwise, forward to `goto-line' with ARG.
|
||||
|
||||
\(fn &optional ARG)" t nil)
|
||||
|
||||
(autoload 'avy-goto-line-above "avy" "\
|
||||
Goto visible line above the cursor.
|
||||
OFFSET changes the distance between the closest key to the cursor and
|
||||
the cursor
|
||||
When BOTTOM-UP is non-nil, display avy candidates from top to bottom
|
||||
|
||||
\(fn &optional OFFSET BOTTOM-UP)" t nil)
|
||||
|
||||
(autoload 'avy-goto-line-below "avy" "\
|
||||
Goto visible line below the cursor.
|
||||
OFFSET changes the distance between the closest key to the cursor and
|
||||
the cursor
|
||||
When BOTTOM-UP is non-nil, display avy candidates from top to bottom
|
||||
|
||||
\(fn &optional OFFSET BOTTOM-UP)" t nil)
|
||||
|
||||
(autoload 'avy-goto-end-of-line "avy" "\
|
||||
Call `avy-goto-line' and move to the end of the line.
|
||||
|
||||
\(fn &optional ARG)" t nil)
|
||||
|
||||
(autoload 'avy-copy-line "avy" "\
|
||||
Copy a selected line above the current line.
|
||||
ARG lines can be used.
|
||||
|
||||
\(fn ARG)" t nil)
|
||||
|
||||
(autoload 'avy-move-line "avy" "\
|
||||
Move a selected line above the current line.
|
||||
ARG lines can be used.
|
||||
|
||||
\(fn ARG)" t nil)
|
||||
|
||||
(autoload 'avy-copy-region "avy" "\
|
||||
Select two lines and copy the text between them to point.
|
||||
|
||||
The window scope is determined by `avy-all-windows' or
|
||||
`avy-all-windows-alt' when ARG is non-nil.
|
||||
|
||||
\(fn ARG)" t nil)
|
||||
|
||||
(autoload 'avy-move-region "avy" "\
|
||||
Select two lines and move the text between them above the current line.
|
||||
|
||||
\(fn)" t nil)
|
||||
|
||||
(autoload 'avy-kill-region "avy" "\
|
||||
Select two lines and kill the region between them.
|
||||
|
||||
The window scope is determined by `avy-all-windows' or
|
||||
`avy-all-windows-alt' when ARG is non-nil.
|
||||
|
||||
\(fn ARG)" t nil)
|
||||
|
||||
(autoload 'avy-kill-ring-save-region "avy" "\
|
||||
Select two lines and save the region between them to the kill ring.
|
||||
The window scope is determined by `avy-all-windows'.
|
||||
When ARG is non-nil, do the opposite of `avy-all-windows'.
|
||||
|
||||
\(fn ARG)" t nil)
|
||||
|
||||
(autoload 'avy-kill-whole-line "avy" "\
|
||||
Select line and kill the whole selected line.
|
||||
|
||||
With a numerical prefix ARG, kill ARG line(s) starting from the
|
||||
selected line. If ARG is negative, kill backward.
|
||||
|
||||
If ARG is zero, kill the selected line but exclude the trailing
|
||||
newline.
|
||||
|
||||
\\[universal-argument] 3 \\[avy-kil-whole-line] kill three lines
|
||||
starting from the selected line. \\[universal-argument] -3
|
||||
|
||||
\\[avy-kill-whole-line] kill three lines backward including the
|
||||
selected line.
|
||||
|
||||
\(fn ARG)" t nil)
|
||||
|
||||
(autoload 'avy-kill-ring-save-whole-line "avy" "\
|
||||
Select line and save the whole selected line as if killed, but don’t kill it.
|
||||
|
||||
This command is similar to `avy-kill-whole-line', except that it
|
||||
saves the line(s) as if killed, but does not kill it(them).
|
||||
|
||||
With a numerical prefix ARG, kill ARG line(s) starting from the
|
||||
selected line. If ARG is negative, kill backward.
|
||||
|
||||
If ARG is zero, kill the selected line but exclude the trailing
|
||||
newline.
|
||||
|
||||
\(fn ARG)" t nil)
|
||||
|
||||
(autoload 'avy-setup-default "avy" "\
|
||||
Setup the default shortcuts.
|
||||
|
||||
\(fn)" nil nil)
|
||||
|
||||
(autoload 'avy-goto-char-timer "avy" "\
|
||||
Read one or many consecutive chars and jump to the first one.
|
||||
The window scope is determined by `avy-all-windows' (ARG negates it).
|
||||
|
||||
\(fn &optional ARG)" t nil)
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "avy" '("avy-")))
|
||||
|
||||
;;;***
|
||||
|
||||
;; Local Variables:
|
||||
;; version-control: never
|
||||
;; no-byte-compile: t
|
||||
;; no-update-autoloads: t
|
||||
;; coding: utf-8
|
||||
;; End:
|
||||
;;; avy-autoloads.el ends here
|
|
@ -1,2 +0,0 @@
|
|||
;;; -*- no-byte-compile: t -*-
|
||||
(define-package "avy" "20200311.1106" "Jump to arbitrary positions in visible text and select text quickly." '((emacs "24.1") (cl-lib "0.5")) :commit "3bf83140fad4c28f2dc4c7107b9d8fef84d17cb9" :keywords '("point" "location") :authors '(("Oleh Krehel" . "ohwoeowho@gmail.com")) :maintainer '("Oleh Krehel" . "ohwoeowho@gmail.com") :url "https://github.com/abo-abo/avy")
|
File diff suppressed because it is too large
Load diff
Binary file not shown.
|
@ -1,24 +0,0 @@
|
|||
;;; berrys-theme-autoloads.el --- automatically extracted autoloads
|
||||
;;
|
||||
;;; Code:
|
||||
|
||||
(add-to-list 'load-path (directory-file-name
|
||||
(or (file-name-directory #$) (car load-path))))
|
||||
|
||||
|
||||
;;;### (autoloads nil "berrys-theme" "berrys-theme.el" (0 0 0 0))
|
||||
;;; Generated autoloads from berrys-theme.el
|
||||
|
||||
(when (and (boundp 'custom-theme-load-path) load-file-name) (add-to-list 'custom-theme-load-path (file-name-as-directory (file-name-directory load-file-name))))
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "berrys-theme" '("berrys")))
|
||||
|
||||
;;;***
|
||||
|
||||
;; Local Variables:
|
||||
;; version-control: never
|
||||
;; no-byte-compile: t
|
||||
;; no-update-autoloads: t
|
||||
;; coding: utf-8
|
||||
;; End:
|
||||
;;; berrys-theme-autoloads.el ends here
|
|
@ -1,2 +0,0 @@
|
|||
;;; -*- no-byte-compile: t -*-
|
||||
(define-package "berrys-theme" "20191201.1609" "A light, clean and elegant theme" '((emacs "24.1")) :commit "888a14206b2fb3dc45b5273aeb05075f3e0b5f60" :authors '(("Slava Buzin" . "v8v.buzin@gmail.com")) :maintainer '("Slava Buzin" . "v8v.buzin@gmail.com") :url "https://github.com/vbuzin/berrys-theme")
|
|
@ -1,399 +0,0 @@
|
|||
;;; berrys-theme.el --- A light, clean and elegant theme -*- lexical-binding: t; -*-
|
||||
|
||||
;; Copyright © 2019-present Slava Buzin
|
||||
|
||||
;; Title: Berrys Theme
|
||||
;; Project: berrys-theme
|
||||
;; Version: 0.1.0
|
||||
;; Package-Version: 20191201.1609
|
||||
;; URL: https://github.com/vbuzin/berrys-theme
|
||||
;; Author: Slava Buzin <v8v.buzin@gmail.com>
|
||||
;; Package-Requires: ((emacs "24.1"))
|
||||
;; License: MIT
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Berrys is a 9 colorspace theme build to run in GUI mode
|
||||
;; with support for some third-party syntax- and UI packages.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(deftheme berrys "A light, clean and elegant theme")
|
||||
|
||||
;;;; Colors
|
||||
(let* ((class '((class color) (min-colors 89)))
|
||||
(berrys00 nil)
|
||||
|
||||
(berrys01 "#FAFAFA")
|
||||
(berrys02 "#2C302E")
|
||||
(berrys03 "#646881")
|
||||
(berrys04 "#E2E3E8")
|
||||
|
||||
(berrys05 "#1098F7")
|
||||
(berrys06 "#B2EAFF")
|
||||
|
||||
(berrys07 nil)
|
||||
|
||||
(berrys08 "#00AC00")
|
||||
|
||||
(berrys09 "#D89800")
|
||||
|
||||
(berrys10 "#B80C09")
|
||||
|
||||
(berrys-cursor berrys05)
|
||||
(berrys-comment berrys03)
|
||||
(berrys-string berrys03)
|
||||
|
||||
(berrys-warning berrys09)
|
||||
(berrys-error berrys10))
|
||||
|
||||
(custom-theme-set-faces
|
||||
'berrys
|
||||
|
||||
;;; Core
|
||||
;; =============================================================================
|
||||
;; => Base
|
||||
`(bold ((,class (:weight bold))))
|
||||
`(bold-italic ((,class (:weight bold :slant italic))))
|
||||
`(default ((,class (:foreground ,berrys02 :background ,berrys01))))
|
||||
`(error ((,class (:foreground ,berrys-error))))
|
||||
`(fixed-pitch-serif ((,class (:family unspecified))))
|
||||
`(font-lock-builtin-face ((,class (:foreground ,berrys02 :weight bold))))
|
||||
`(font-lock-comment-face ((,class (:foreground ,berrys-comment :slant italic))))
|
||||
`(font-lock-comment-delimiter-face ((,class (:foreground ,berrys-comment :slant italic))))
|
||||
`(font-lock-constant-face ((,class (:foreground ,berrys02 :weight bold))))
|
||||
`(font-lock-doc-face ((,class (:inherit (font-lock-comment-face)))))
|
||||
`(font-lock-function-name-face ((,class (:foreground ,berrys02 :weight bold))))
|
||||
`(font-lock-keyword-face ((,class (:foreground ,berrys02 :weight bold))))
|
||||
`(font-lock-string-face ((,class (:foreground ,berrys-string))))
|
||||
`(font-lock-type-face ((,class (:foreground ,berrys02 :slant italic))))
|
||||
`(font-lock-variable-name-face ((,class (:foreground ,berrys02))))
|
||||
`(font-lock-warning-face ((,class (:inherit warning))))
|
||||
`(shadow ((,class (:foreground ,berrys03))))
|
||||
`(warning ((,class (:foreground ,berrys-warning))))
|
||||
|
||||
;; => Core UI
|
||||
`(cursor ((,class (:background ,berrys-cursor :inverse-video t))))
|
||||
`(custom-button ((,class (:background ,berrys05 :foreground ,berrys01))))
|
||||
`(custom-variable-tag ((,class (:foreground ,berrys02 :weight bold))))
|
||||
`(custom-visibility ((,class (:inherit link))))
|
||||
`(diff-added ((,class (:foreground ,berrys08))))
|
||||
`(diff-context ((,class (:foreground ,berrys-string))))
|
||||
`(diff-file-header ((,class (:inherit diff-header))))
|
||||
`(diff-header ((,class (:foreground ,berrys03))))
|
||||
`(diff-hunk-header ((,class (:inherit diff-header))))
|
||||
`(diff-indicator-added ((,class (:foreground ,berrys08))))
|
||||
`(diff-refine-added ((,class (:foreground ,berrys08))))
|
||||
`(diff-refine-changed ((,class (:foreground ,berrys09))))
|
||||
`(diff-refine-removed ((,class (:foreground ,berrys10))))
|
||||
`(diff-removed ((,class (:foreground ,berrys10))))
|
||||
`(dired-directory ((,class :foreground ,berrys02 :weight bold)))
|
||||
`(header-line ((,class :foreground ,berrys02 :weight bold)))
|
||||
`(highlight ((,class (:background ,berrys04))))
|
||||
`(hl-line ((,class (:background ,berrys04))))
|
||||
`(info-node ((,class (:foreground ,berrys05 :weight bold))))
|
||||
`(info-menu-header ((,class (:foreground ,berrys02 :weight bold))))
|
||||
`(info-menu-star ((,class (:foreground ,berrys05))))
|
||||
`(info-title-4 ((,class (:foreground ,berrys02 :weight bold))))
|
||||
`(isearch ((,class (:foreground ,berrys05 :weight bold))))
|
||||
`(isearch-fail ((,class (:foreground ,berrys01 :background ,berrys-error))))
|
||||
`(lazy-highlight ((,class (:inherit isearch))))
|
||||
`(link ((,class (:underline t))))
|
||||
`(link-visited ((,class (:underline t))))
|
||||
`(match ((,class (:inherit isearch))))
|
||||
|
||||
`(message-cited-text ((,class (:inherit font-lock-comment-face))))
|
||||
`(message-header-cc ((,class (:foreground ,berrys-string))))
|
||||
`(message-header-name ((,class (:foreground ,berrys-string))))
|
||||
`(message-header-newsgroups ((,class (:foreground ,berrys-string :slant italic :weight bold))))
|
||||
`(message-header-other ((,class (:foreground ,berrys-string))))
|
||||
`(message-header-subject ((,class (:foreground ,berrys-string))))
|
||||
`(message-header-to ((,class (:foreground ,berrys-string))))
|
||||
`(message-header-xheader ((,class (:foreground ,berrys-string))))
|
||||
`(message-mml ((,class (:foreground ,berrys-string))))
|
||||
`(message-separator ((,class (:inherit font-lock-comment-face))))
|
||||
|
||||
`(minibuffer-prompt ((,class (:foreground ,berrys02 :weight bold))))
|
||||
`(mode-line ((,class (:foreground ,berrys02 :background ,berrys04))))
|
||||
`(mode-line-buffer-id ((,class (:weight bold))))
|
||||
`(mode-line-highlight ((,class (:inherit highlight))))
|
||||
`(mode-line-inactive ((,class (:foreground ,berrys02 :background ,berrys01 :box (:color ,berrys04)))))
|
||||
`(outline-1 ((,class (:foreground ,berrys02 :weight bold))))
|
||||
`(outline-2 ((,class (:inherit outline-1))))
|
||||
`(outline-3 ((,class (:inherit outline-1))))
|
||||
`(outline-4 ((,class (:inherit outline-1))))
|
||||
`(outline-5 ((,class (:inherit outline-1))))
|
||||
`(outline-6 ((,class (:inherit outline-1))))
|
||||
`(outline-7 ((,class (:inherit outline-1))))
|
||||
`(outline-8 ((,class (:inherit outline-1))))
|
||||
`(region ((,class (:background ,berrys06))))
|
||||
`(secondary-selection ((,class (:background ,berrys04 :foreground ,berrys02))))
|
||||
`(show-paren-match ((,class (:weight bold))))
|
||||
`(show-paren-mismatch ((,class (:foreground ,berrys-error :weight bold))))
|
||||
`(success ((,class (:foreground ,berrys08))))
|
||||
`(whitespace-big-indent ((,class (:foreground ,berrys01 :background ,berrys10))))
|
||||
`(whitespace-line ((,class (:background ,berrys01))))
|
||||
`(whitespace-trailing ((,class (:foreground ,berrys01 :background ,berrys10))))
|
||||
|
||||
;;; Packages
|
||||
;; =============================================================================
|
||||
;; => Ace jump
|
||||
`(ace-jump-face-foreground ((,class (:foreground ,berrys05 :weight bold))))
|
||||
|
||||
;; => Anzu
|
||||
`(anzu-match-1 ((,class (:foreground ,berrys05 :weight bold :box (:color ,berrys05)))))
|
||||
`(anzu-match-2 ((,class (:foreground ,berrys01 :background ,berrys05 :weight bold :box (:color ,berrys05)))))
|
||||
`(anzu-match-3 ((,class (:foreground ,berrys01 :background ,berrys03 :weight bold :box (:color ,berrys03)))))
|
||||
`(anzu-mode-line ((,class (:foreground ,berrys02 :weight bold))))
|
||||
`(anzu-mode-line-no-match ((,class (:foreground ,berrys10 :weight bold))))
|
||||
`(anzu-replace-to ((,class (:foreground ,berrys-string :weight bold))))
|
||||
|
||||
;; => Company
|
||||
`(company-echo-common ((,class (:foreground ,berrys01 :background ,berrys10))))
|
||||
`(company-scrollbar-bg ((,class (:foreground ,berrys04 :background ,berrys04))))
|
||||
`(company-scrollbar-fg ((,class (:foreground ,berrys02 :background ,berrys02))))
|
||||
`(company-template-field ((,class (:inherit region))))
|
||||
`(company-tooltip ((,class (:foreground ,berrys02 :background ,berrys04))))
|
||||
`(company-tooltip-annotation ((,class (:foreground ,berrys-string))))
|
||||
`(company-tooltip-common ((,class (:inherit company-tooltip))))
|
||||
`(company-tooltip-common-selection ((,class (:inherit company-tooltip-selection))))
|
||||
`(company-tooltip-mouse ((,class (:inherit highlight))))
|
||||
`(company-tooltip-search ((,class (:inherit isearch))))
|
||||
`(company-tooltip-search-selection ((,class (:inherit company-tooltip-search))))
|
||||
`(company-tooltip-selection ((,class (:background ,berrys06))))
|
||||
|
||||
;; => bm
|
||||
`(bm-face ((,class (:foreground ,berrys05 :background ,berrys01))))
|
||||
`(bm-fringe-face ((,class (:inherit bm-face))))
|
||||
`(bm-persistent-face ((,class (:foreground ,berrys01 :background ,berrys05))))
|
||||
`(bm-fringe-persistent-face ((,class (:inherit bm-persistent-face))))
|
||||
|
||||
;; => Flx
|
||||
`(flx-highlight-face ((,class (:foreground ,berrys05 :weight bold))))
|
||||
|
||||
;; => Flycheck
|
||||
`(flycheck-error ((,class (:underline (:style wave :color ,berrys-error)))))
|
||||
`(flycheck-fringe-error ((,class (:foreground ,berrys-error :weight bold))))
|
||||
`(flycheck-fringe-info ((,class (:foreground ,berrys02 :weight bold))))
|
||||
`(flycheck-fringe-warning ((,class (:foreground ,berrys-warning :weight bold))))
|
||||
`(flycheck-info ((,class (:underline (:style wave :color ,berrys05)))))
|
||||
`(flycheck-warning ((,class (:underline (:style wave :color ,berrys-warning)))))
|
||||
|
||||
;; => Gnus
|
||||
`(gnus-header-content ((,class (:foreground ,berrys-string :italic t))))
|
||||
`(gnus-header-from ((,class (:foreground ,berrys-string))))
|
||||
`(gnus-header-name ((,class (:foreground ,berrys-string :weight bold))))
|
||||
`(gnus-header-subject ((,class (:foreground ,berrys-string))))
|
||||
|
||||
;; => Haskell-mode
|
||||
`(haskell-error-face ((,class (:underline (:style wave :color ,berrys-error)))))
|
||||
`(haskell-hole-face ((,class (:underline (:style wave :color ,berrys05)))))
|
||||
`(haskell-warning-face ((,class (:underline (:style wave :color ,berrys-warning)))))
|
||||
|
||||
;; => Helm
|
||||
`(helm-M-x-key ((,class (:foreground ,berrys03 :underline t))))
|
||||
`(helm-buffer-directory ((,class (:inherit helm-buffer-file))))
|
||||
`(helm-buffer-not-saved ((,class (:foreground ,berrys03 :slant italic))))
|
||||
`(helm-buffer-process ((,class (:foreground ,berrys03))))
|
||||
`(helm-candidate-number ((,class (:weight bold))))
|
||||
`(helm-candidate-number-suspended ((,class (:foreground ,berrys03 :weight bold))))
|
||||
`(helm-ff-directory ((,class (:foreground ,berrys02 :weight bold))))
|
||||
`(helm-ff-dirs ((,class (:inherit helm-ff-file))))
|
||||
`(helm-ff-dotted-directory ((,class (:inherit helm-ff-directory))))
|
||||
`(helm-ff-dotted-symlink-directory ((,class (:inherit helm-ff-dotted-directory))))
|
||||
`(helm-ff-file ((,class (:foreground ,berrys02))))
|
||||
`(helm-ff-executable ((,class (:foreground ,berrys08))))
|
||||
`(helm-ff-invalid-symlink ((,class (:foreground ,berrys01 :background ,berrys10))))
|
||||
`(helm-ff-pipe ((,class (:foreground ,berrys09 :background ,berrys02))))
|
||||
`(helm-ff-prefix ((,class (:foreground ,berrys02 :background ,berrys06))))
|
||||
`(helm-ff-socket ((,class (:foreground ,berrys10 :box (:color ,berrys10)))))
|
||||
`(helm-grep-file ((,class (:foreground ,berrys02 :weight bold))))
|
||||
`(helm-grep-finish ((,class (:foreground ,berrys08 :weight bold))))
|
||||
`(helm-grep-lineno ((,class (:foreground ,berrys03))))
|
||||
`(helm-grep-match ((,class (:inherit isearch))))
|
||||
`(helm-header ((,class (:inherit helm-source-header :background ,berrys01))))
|
||||
`(helm-header-line-left-margin ((,class (:foreground ,berrys01 :background ,berrys09))))
|
||||
`(helm-helper ((,class (:foreground ,berrys02))))
|
||||
`(helm-history-deleted ((,class (:foreground ,berrys01 :background ,berrys10))))
|
||||
`(helm-history-remote ((,class (:foreground ,berrys10))))
|
||||
`(helm-lisp-completion-info ((,class (:foreground ,berrys04 :weight bold))))
|
||||
`(helm-lisp-show-completion ((,class (:inherit isearch))))
|
||||
`(helm-locate-finish ((,class (:foreground ,berrys08))))
|
||||
`(helm-match ((,class (:foreground ,berrys05 :weight bold))))
|
||||
`(helm-match-item ((,class (:inherit isearch))))
|
||||
`(helm-moccur-buffer ((,class (:foreground ,berrys02))))
|
||||
`(helm-mode-prefix ((,class (:foreground ,berrys01 :background ,berrys06))))
|
||||
`(helm-resume-need-update ((,class (:foreground ,berrys01 :background ,berrys10))))
|
||||
`(helm-selection ((,class (:inherit highlight))))
|
||||
`(helm-selection-line ((,class (:inherit highlight))))
|
||||
`(helm-source-header ((,class (:foreground ,berrys02 :weight bold :height 1.2))))
|
||||
`(helm-separator ((,class (:foreground ,berrys02))))
|
||||
`(helm-visible-mark ((,class (:background ,berrys06))))
|
||||
`(helm-yas-key ((,class (:inherit helm-M-x-key))))
|
||||
|
||||
;; => Ido
|
||||
`(ido-indicator ((,class (:foreground ,berrys01 :background ,berrys10))))
|
||||
`(ido-only-match ((,class (:foreground ,berrys05 :weight bold))))
|
||||
`(ido-subdir ((,class (:foreground ,berrys02 :weight bold))))
|
||||
`(ido-virtual ((,class (:foreground ,berrys-string :weight bold))))
|
||||
|
||||
;; => Indent guide
|
||||
`(indent-guide-face ((,class (:foreground ,berrys-comment))))
|
||||
|
||||
;; => Ivy
|
||||
`(ivy-confirm-face ((,class (:foreground ,berrys08 :weight bold))))
|
||||
`(ivy-current-match ((,class (:inherit hl-line))))
|
||||
`(ivy-cursor ((,class (:foreground ,berrys01 :background ,berrys02))))
|
||||
`(ivy-match-required-face ((,class (:foreground ,berrys10 :weight bold))))
|
||||
`(ivy-remote ((,class (:foreground ,berrys02 :underline t))))
|
||||
`(ivy-minibuffer-match-face-2 ((,class (:foreground ,berrys05 :weight bold))))
|
||||
`(ivy-minibuffer-match-face-3 ((,class (:inherit ivy-minibuffer-match-face-2 :underline t))))
|
||||
`(ivy-minibuffer-match-face-4 ((,class (:inherit ivy-minibuffer-match-face-2 :box (:color ,berrys05)))))
|
||||
|
||||
;; => Markdown
|
||||
`(markdown-code-face ((,class (:family unspecified))))
|
||||
`(markdown-header-face ((,class (:foreground ,berrys02 :weight bold))))
|
||||
`(markdown-header-face-1 ((,class (:inherit markdown-header-face :height 1.4))))
|
||||
`(markdown-header-face-2 ((,class (:inherit markdown-header-face :height 1.3))))
|
||||
`(markdown-header-face-3 ((,class (:inherit markdown-header-face :height 1.2))))
|
||||
`(markdown-header-face-4 ((,class (:inherit markdown-header-face :height 1.1))))
|
||||
`(markdown-inline-code-face ((,class (:inherit markdown-code-face))))
|
||||
`(markdown-italic-face ((,class (:inherit italic))))
|
||||
|
||||
;; => Magit
|
||||
`(magit-bisect-bad ((,class (:foreground ,berrys-error))))
|
||||
`(magit-bisect-good ((,class (:foreground ,berrys08))))
|
||||
`(magit-bisect-skip ((,class (:foreground ,berrys09))))
|
||||
`(magit-blame-highlight ((,class (:foreground ,berrys03 :background ,berrys04))))
|
||||
`(magit-branch-local ((,class (:foreground ,berrys05))))
|
||||
`(magit-branch-remote ((,class (:foreground ,berrys08))))
|
||||
`(magit-reflog-checkout ((,class (:foreground ,berrys05))))
|
||||
`(magit-diff-base ((,class (:foreground ,berrys09))))
|
||||
`(magit-diff-base-highlight ((,class (:inherit magit-diff-base))))
|
||||
`(magit-diff-context ((,class (:foreground ,berrys-string))))
|
||||
`(magit-diff-context-highlight ((,class (:inherit magit-diff-context))))
|
||||
`(magit-diff-added ((,class (:foreground ,berrys08))))
|
||||
`(magit-diff-added-highlight ((,class (:inherit magit-diff-added))))
|
||||
`(magit-diff-file-heading ((,class (:foreground ,berrys-string))))
|
||||
`(magit-diff-file-heading-selection ((,class (:inherit magit-diff-file-heading))))
|
||||
`(magit-diff-hunk-heading ((,class (:foreground ,berrys03))))
|
||||
`(magit-diff-hunk-heading-highlight ((,class (:inherit magit-diff-hunk-heading))))
|
||||
`(magit-diff-hunk-heading-selection ((,class (:inherit magit-diff-hunk-heading))))
|
||||
`(magit-diff-lines-boundary((,class (:inherit unspecified))))
|
||||
`(magit-diff-lines-heading ((,class (:inherit unspecified))))
|
||||
`(magit-diff-our-highlight ((,class (:inherit magit-diff-removed))))
|
||||
`(magit-diff-removed ((,class (:foreground ,berrys10))))
|
||||
`(magit-diff-removed-highlight ((,class (:inherit magit-diff-removed))))
|
||||
`(magit-diffstat-added ((,class (:foreground ,berrys08))))
|
||||
`(magit-diffstat-removed ((,class (:foreground ,berrys10))))
|
||||
`(magit-diff-their-highlight ((,class (:inherit magit-diff-added))))
|
||||
`(magit-diff-whitespace-warning ((,class (:foreground ,berrys01 :background ,berrys10))))
|
||||
`(magit-log-author ((,class (:foreground ,berrys02))))
|
||||
`(magit-log-date ((,class (:foreground ,berrys-comment))))
|
||||
`(magit-log-graph ((,class (:foreground ,berrys-comment))))
|
||||
`(magit-hash ((,class (:foreground ,berrys-comment))))
|
||||
`(magit-header-line ((,class (:foreground ,berrys-string))))
|
||||
`(magit-header-line-log-select ((,class (:foreground ,berrys02))))
|
||||
`(magit-process-ok ((,class (:foreground ,berrys08))))
|
||||
`(magit-reflog-cherry-pick ((,class (:foreground ,berrys08))))
|
||||
`(magit-reflog-commit ((,class (:foreground ,berrys08))))
|
||||
`(magit-reflog-merge ((,class (:foreground ,berrys08))))
|
||||
`(magit-reflog-reset ((,class (:foreground ,berrys10))))
|
||||
`(magit-refname ((,class (:foreground ,berrys-comment))))
|
||||
`(magit-section-heading ((,class (:foreground ,berrys02))))
|
||||
`(magit-section-heading-selection ((,class (:inherit magit-section-heading))))
|
||||
`(magit-section-highlight ((,class (:inherit unspecified))))
|
||||
`(magit-section-secondary-heading ((,class (:foreground ,berrys02))))
|
||||
`(magit-signature-bad ((,class (:foreground ,berrys-error))))
|
||||
`(magit-signature-error ((,class (:foreground ,berrys-error))))
|
||||
`(magit-signature-expired ((,class (:foreground ,berrys-warning))))
|
||||
`(magit-signature-expired-key ((,class (:inherit magit-signature-expired))))
|
||||
`(magit-signature-good ((,class (:foreground ,berrys08))))
|
||||
`(magit-signature-revoked ((,class (:foreground ,berrys10))))
|
||||
`(magit-signature-untrusted ((,class (:foreground ,berrys10))))
|
||||
`(magit-tag ((,class (:foreground ,berrys05))))
|
||||
|
||||
;; => Mu4e
|
||||
`(mu4e-attach-number-face ((,class (:foreground ,berrys05))))
|
||||
`(mu4e-contact-face ((,class (:foreground ,berrys-string :slant italic))))
|
||||
`(mu4e-context-face ((,class (:foreground ,berrys-string))))
|
||||
`(mu4e-flagged-face ((,class (:foreground ,berrys09))))
|
||||
`(mu4e-header-face ((,class (:foreground ,berrys02))))
|
||||
`(mu4e-header-highlight-face ((,class (:inherit highlight))))
|
||||
`(mu4e-header-key-face ((,class (:foreground ,berrys-string :weight bold))))
|
||||
`(mu4e-header-marks-face ((,class (:foreground ,berrys05 :weight bold))))
|
||||
`(mu4e-header-value-face ((,class (:foreground ,berrys-string :slant italic))))
|
||||
`(mu4e-highlight-face ((,class (:foreground ,berrys05))))
|
||||
`(mu4e-special-header-value-face ((,class (:foreground ,berrys-string :slant italic))))
|
||||
`(mu4e-region-code ((,class (:box (:color ,berrys05)))))
|
||||
`(mu4e-replied-face ((,class :slant italic)))
|
||||
`(mu4e-url-number-face ((,class (:foreground ,berrys05))))
|
||||
|
||||
;; => Org mode
|
||||
`(org-agenda-date ((,class (:foreground ,berrys02))))
|
||||
`(org-agenda-diary ((,class (:foreground ,berrys-string :slant italic))))
|
||||
`(org-agenda-dimmed-todo-face ((,class (:foreground ,berrys-comment :slant italic))))
|
||||
`(org-agenda-done ((,class (:foreground ,berrys-string :slant italic :strike-through t))))
|
||||
`(org-agenda-restriction-lock ((,class (:background ,berrys04))))
|
||||
`(org-agenda-structure ((,class (:foreground ,berrys02 :weight bold :height 1.2))))
|
||||
`(org-block ((,class (:inherit berrys02))))
|
||||
`(org-clock-overlay ((,class (:inherit secondary-selection))))
|
||||
`(org-column ((,class (:foreground ,berrys-string :slant normal))))
|
||||
`(org-column-title ((,class (:foreground ,berrys02 :weight bold))))
|
||||
`(org-date ((,class (:foreground ,berrys02 :slant italic))))
|
||||
`(org-date-selected ((,class (:foreground ,berrys05 :weight bold))))
|
||||
`(org-document-info ((,class (:foreground ,berrys03))))
|
||||
`(org-document-title ((,class (:foreground ,berrys03 :weight bold))))
|
||||
`(org-done ((,class(:inherit org-level-1 :foreground ,berrys08))))
|
||||
`(org-ellipsis ((,class (:inherit unspecified))))
|
||||
`(org-footnote ((,class (:foreground ,berrys02 :underline t))))
|
||||
`(org-formula ((,class (:foreground ,berrys-string))))
|
||||
`(org-headline-done ((,class (:inherit org-level-1 :strike-through t))))
|
||||
`(org-latex-and-related ((,class (:foreground ,berrys-string))))
|
||||
`(org-level-1 ((,class (:foreground ,berrys02 :weight bold))))
|
||||
`(org-level-2 ((,class (:inherit org-level-1))))
|
||||
`(org-level-3 ((,class (:inherit org-level-1))))
|
||||
`(org-level-4 ((,class (:inherit org-level-1))))
|
||||
`(org-level-5 ((,class (:inherit org-level-1))))
|
||||
`(org-level-6 ((,class (:inherit org-level-1))))
|
||||
`(org-level-7 ((,class (:inherit org-level-1))))
|
||||
`(org-level-8 ((,class (:inherit org-level-1))))
|
||||
`(org-link ((,class (:inherit unspecified :underline t))))
|
||||
`(org-mode-line-clock ((,class (:inherit mode-line))))
|
||||
`(org-mode-line-clock-overrun ((,class (:foreground ,berrys09))))
|
||||
`(org-priority ((,class(:inherit org-level-1 :foreground ,berrys05))))
|
||||
`(org-scheduled ((,class (:foreground ,berrys02 :slant italic))))
|
||||
`(org-scheduled-previously ((,class (:foreground ,berrys10 :slant italic))))
|
||||
`(org-scheduled-today ((,class (:inherit org-scheduled))))
|
||||
`(org-sexp-date ((,class (:foreground ,berrys-string :slant italic))))
|
||||
`(org-special-keyword ((,class (:foreground ,berrys-string))))
|
||||
`(org-table ((,class (:foreground ,berrys02))))
|
||||
`(org-tag ((,class(:inherit org-level-1 :foreground ,berrys05))))
|
||||
`(org-time-grid ((,class (:foreground ,berrys-string :slant italic))))
|
||||
`(org-todo ((,class (:inherit org-level-1 :foreground ,berrys05))))
|
||||
`(org-upcoming-deadline ((,class (:foreground ,berrys09 :slant italic))))
|
||||
`(org-warning ((,class (:foreground ,berrys09 :slant italic))))
|
||||
`(org-verbatim ((,class (:inherit default))))
|
||||
|
||||
;; Org Pomodoro
|
||||
`(org-pomodoro-mode-line ((,class (:foreground ,berrys05 :weight bold))))
|
||||
`(org-pomodoro-mode-line-break ((,class (:foreground ,berrys08 :weight bold))))
|
||||
`(org-pomodoro-mode-line-overtime ((,class (:foreground ,berrys-error :weight bold))))
|
||||
|
||||
;; => Which key
|
||||
`(which-key-key-face ((,class (:foreground ,berrys05 :weight bold))))))
|
||||
|
||||
;;;###autoload
|
||||
(when (and (boundp 'custom-theme-load-path) load-file-name)
|
||||
(add-to-list 'custom-theme-load-path
|
||||
(file-name-as-directory (file-name-directory load-file-name))))
|
||||
|
||||
(provide-theme 'berrys)
|
||||
(provide 'berrys-theme)
|
||||
|
||||
;; Local Variables:
|
||||
;; no-byte-compile: t
|
||||
;; indent-tabs-mode: nil
|
||||
;; End:
|
||||
|
||||
;;; berrys-theme.el ends here
|
|
@ -1,50 +0,0 @@
|
|||
;;; company-abbrev.el --- company-mode completion backend for abbrev
|
||||
|
||||
;; Copyright (C) 2009-2011, 2015 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
;;; Commentary:
|
||||
;;
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'company)
|
||||
(require 'cl-lib)
|
||||
(require 'abbrev)
|
||||
|
||||
(defun company-abbrev-insert (match)
|
||||
"Replace MATCH with the expanded abbrev."
|
||||
(expand-abbrev))
|
||||
|
||||
;;;###autoload
|
||||
(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))))
|
||||
(meta (abbrev-expansion arg))))
|
||||
|
||||
(provide 'company-abbrev)
|
||||
;;; company-abbrev.el ends here
|
Binary file not shown.
|
@ -1,383 +0,0 @@
|
|||
;;; company-autoloads.el --- automatically extracted autoloads
|
||||
;;
|
||||
;;; Code:
|
||||
|
||||
(add-to-list 'load-path (directory-file-name
|
||||
(or (file-name-directory #$) (car load-path))))
|
||||
|
||||
|
||||
;;;### (autoloads nil "company" "company.el" (0 0 0 0))
|
||||
;;; Generated autoloads from company.el
|
||||
|
||||
(autoload 'company-mode "company" "\
|
||||
\"complete anything\"; is an in-buffer completion framework.
|
||||
Completion starts automatically, depending on the values
|
||||
`company-idle-delay' and `company-minimum-prefix-length'.
|
||||
|
||||
Completion can be controlled with the commands:
|
||||
`company-complete-common', `company-complete-selection', `company-complete',
|
||||
`company-select-next', `company-select-previous'. If these commands are
|
||||
called before `company-idle-delay', completion will also start.
|
||||
|
||||
Completions can be searched with `company-search-candidates' or
|
||||
`company-filter-candidates'. These can be used while completion is
|
||||
inactive, as well.
|
||||
|
||||
The completion data is retrieved using `company-backends' and displayed
|
||||
using `company-frontends'. If you want to start a specific backend, call
|
||||
it interactively or use `company-begin-backend'.
|
||||
|
||||
By default, the completions list is sorted alphabetically, unless the
|
||||
backend chooses otherwise, or `company-transformers' changes it later.
|
||||
|
||||
regular keymap (`company-mode-map'):
|
||||
|
||||
\\{company-mode-map}
|
||||
keymap during active completions (`company-active-map'):
|
||||
|
||||
\\{company-active-map}
|
||||
|
||||
\(fn &optional ARG)" t nil)
|
||||
|
||||
(defvar global-company-mode nil "\
|
||||
Non-nil if Global Company mode is enabled.
|
||||
See the `global-company-mode' command
|
||||
for a description of this minor mode.
|
||||
Setting this variable directly does not take effect;
|
||||
either customize it (see the info node `Easy Customization')
|
||||
or call the function `global-company-mode'.")
|
||||
|
||||
(custom-autoload 'global-company-mode "company" nil)
|
||||
|
||||
(autoload 'global-company-mode "company" "\
|
||||
Toggle Company mode in all buffers.
|
||||
With prefix ARG, enable Global Company mode if ARG is positive;
|
||||
otherwise, disable it. If called from Lisp, enable the mode if
|
||||
ARG is omitted or nil.
|
||||
|
||||
Company mode is enabled in all buffers where
|
||||
`company-mode-on' would do it.
|
||||
See `company-mode' for more information on Company mode.
|
||||
|
||||
\(fn &optional ARG)" t nil)
|
||||
|
||||
(autoload 'company-manual-begin "company" "\
|
||||
|
||||
|
||||
\(fn)" t nil)
|
||||
|
||||
(autoload 'company-complete "company" "\
|
||||
Insert the common part of all candidates or the current selection.
|
||||
The first time this is called, the common part is inserted, the second
|
||||
time, or when the selection has been changed, the selected candidate is
|
||||
inserted.
|
||||
|
||||
\(fn)" t nil)
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "company" '("company-")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "company-abbrev" "company-abbrev.el" (0 0 0
|
||||
;;;;;; 0))
|
||||
;;; Generated autoloads from company-abbrev.el
|
||||
|
||||
(autoload 'company-abbrev "company-abbrev" "\
|
||||
`company-mode' completion backend for abbrev.
|
||||
|
||||
\(fn COMMAND &optional ARG &rest IGNORED)" t nil)
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "company-abbrev" '("company-abbrev-insert")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "company-bbdb" "company-bbdb.el" (0 0 0 0))
|
||||
;;; Generated autoloads from company-bbdb.el
|
||||
|
||||
(autoload 'company-bbdb "company-bbdb" "\
|
||||
`company-mode' completion backend for BBDB.
|
||||
|
||||
\(fn COMMAND &optional ARG &rest IGNORE)" t nil)
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "company-bbdb" '("company-bbdb-")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "company-capf" "company-capf.el" (0 0 0 0))
|
||||
;;; Generated autoloads from company-capf.el
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "company-capf" '("company-")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "company-clang" "company-clang.el" (0 0 0 0))
|
||||
;;; Generated autoloads from company-clang.el
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "company-clang" '("company-clang")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "company-cmake" "company-cmake.el" (0 0 0 0))
|
||||
;;; Generated autoloads from company-cmake.el
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "company-cmake" '("company-cmake")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "company-css" "company-css.el" (0 0 0 0))
|
||||
;;; Generated autoloads from company-css.el
|
||||
|
||||
(autoload 'company-css "company-css" "\
|
||||
`company-mode' completion backend for `css-mode'.
|
||||
|
||||
\(fn COMMAND &optional ARG &rest IGNORED)" t nil)
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "company-css" '("company-css-")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "company-dabbrev" "company-dabbrev.el" (0 0
|
||||
;;;;;; 0 0))
|
||||
;;; Generated autoloads from company-dabbrev.el
|
||||
|
||||
(autoload 'company-dabbrev "company-dabbrev" "\
|
||||
dabbrev-like `company-mode' completion backend.
|
||||
|
||||
\(fn COMMAND &optional ARG &rest IGNORED)" t nil)
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "company-dabbrev" '("company-dabbrev-")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "company-dabbrev-code" "company-dabbrev-code.el"
|
||||
;;;;;; (0 0 0 0))
|
||||
;;; Generated autoloads from company-dabbrev-code.el
|
||||
|
||||
(autoload 'company-dabbrev-code "company-dabbrev-code" "\
|
||||
dabbrev-like `company-mode' backend for code.
|
||||
The backend looks for all symbols in the current buffer that aren't in
|
||||
comments or strings.
|
||||
|
||||
\(fn COMMAND &optional ARG &rest IGNORED)" t nil)
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "company-dabbrev-code" '("company-dabbrev-code-")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "company-eclim" "company-eclim.el" (0 0 0 0))
|
||||
;;; Generated autoloads from company-eclim.el
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "company-eclim" '("company-eclim")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "company-elisp" "company-elisp.el" (0 0 0 0))
|
||||
;;; Generated autoloads from company-elisp.el
|
||||
|
||||
(autoload 'company-elisp "company-elisp" "\
|
||||
`company-mode' completion backend for Emacs Lisp.
|
||||
|
||||
\(fn COMMAND &optional ARG &rest IGNORED)" t nil)
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "company-elisp" '("company-elisp-")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "company-etags" "company-etags.el" (0 0 0 0))
|
||||
;;; Generated autoloads from company-etags.el
|
||||
|
||||
(autoload 'company-etags "company-etags" "\
|
||||
`company-mode' completion backend for etags.
|
||||
|
||||
\(fn COMMAND &optional ARG &rest IGNORED)" t nil)
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "company-etags" '("company-etags-")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "company-files" "company-files.el" (0 0 0 0))
|
||||
;;; Generated autoloads from company-files.el
|
||||
|
||||
(autoload 'company-files "company-files" "\
|
||||
`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.
|
||||
|
||||
\(fn COMMAND &optional ARG &rest IGNORED)" t nil)
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "company-files" '("company-file")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "company-gtags" "company-gtags.el" (0 0 0 0))
|
||||
;;; Generated autoloads from company-gtags.el
|
||||
|
||||
(autoload 'company-gtags "company-gtags" "\
|
||||
`company-mode' completion backend for GNU Global.
|
||||
|
||||
\(fn COMMAND &optional ARG &rest IGNORED)" t nil)
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "company-gtags" '("company-gtags-")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "company-ispell" "company-ispell.el" (0 0 0
|
||||
;;;;;; 0))
|
||||
;;; Generated autoloads from company-ispell.el
|
||||
|
||||
(autoload 'company-ispell "company-ispell" "\
|
||||
`company-mode' completion backend using Ispell.
|
||||
|
||||
\(fn COMMAND &optional ARG &rest IGNORED)" t nil)
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "company-ispell" '("company-ispell-")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "company-keywords" "company-keywords.el" (0
|
||||
;;;;;; 0 0 0))
|
||||
;;; Generated autoloads from company-keywords.el
|
||||
|
||||
(autoload 'company-keywords "company-keywords" "\
|
||||
`company-mode' backend for programming language keywords.
|
||||
|
||||
\(fn COMMAND &optional ARG &rest IGNORED)" t nil)
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "company-keywords" '("company-keywords-")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "company-nxml" "company-nxml.el" (0 0 0 0))
|
||||
;;; Generated autoloads from company-nxml.el
|
||||
|
||||
(autoload 'company-nxml "company-nxml" "\
|
||||
`company-mode' completion backend for `nxml-mode'.
|
||||
|
||||
\(fn COMMAND &optional ARG &rest IGNORED)" t nil)
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "company-nxml" '("company-nxml-")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "company-oddmuse" "company-oddmuse.el" (0 0
|
||||
;;;;;; 0 0))
|
||||
;;; Generated autoloads from company-oddmuse.el
|
||||
|
||||
(autoload 'company-oddmuse "company-oddmuse" "\
|
||||
`company-mode' completion backend for `oddmuse-mode'.
|
||||
|
||||
\(fn COMMAND &optional ARG &rest IGNORED)" t nil)
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "company-oddmuse" '("company-oddmuse-")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "company-semantic" "company-semantic.el" (0
|
||||
;;;;;; 0 0 0))
|
||||
;;; Generated autoloads from company-semantic.el
|
||||
|
||||
(autoload 'company-semantic "company-semantic" "\
|
||||
`company-mode' completion backend using CEDET Semantic.
|
||||
|
||||
\(fn COMMAND &optional ARG &rest IGNORED)" t nil)
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "company-semantic" '("company-semantic-")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "company-template" "company-template.el" (0
|
||||
;;;;;; 0 0 0))
|
||||
;;; Generated autoloads from company-template.el
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "company-template" '("company-template-")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "company-tempo" "company-tempo.el" (0 0 0 0))
|
||||
;;; Generated autoloads from company-tempo.el
|
||||
|
||||
(autoload 'company-tempo "company-tempo" "\
|
||||
`company-mode' completion backend for tempo.
|
||||
|
||||
\(fn COMMAND &optional ARG &rest IGNORED)" t nil)
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "company-tempo" '("company-tempo-")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "company-tng" "company-tng.el" (0 0 0 0))
|
||||
;;; Generated autoloads from company-tng.el
|
||||
|
||||
(autoload 'company-tng-frontend "company-tng" "\
|
||||
When the user changes the selection at least once, this
|
||||
frontend will display the candidate in the buffer as if it's
|
||||
already there and any key outside of `company-active-map' will
|
||||
confirm the selection and finish the completion.
|
||||
|
||||
\(fn COMMAND)" nil nil)
|
||||
|
||||
(autoload 'company-tng-configure-default "company-tng" "\
|
||||
Applies the default configuration to enable company-tng.
|
||||
|
||||
\(fn)" nil nil)
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "company-tng" '("company-tng--")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "company-xcode" "company-xcode.el" (0 0 0 0))
|
||||
;;; Generated autoloads from company-xcode.el
|
||||
|
||||
(autoload 'company-xcode "company-xcode" "\
|
||||
`company-mode' completion backend for Xcode projects.
|
||||
|
||||
\(fn COMMAND &optional ARG &rest IGNORED)" t nil)
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "company-xcode" '("company-xcode-")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "company-yasnippet" "company-yasnippet.el"
|
||||
;;;;;; (0 0 0 0))
|
||||
;;; Generated autoloads from company-yasnippet.el
|
||||
|
||||
(autoload 'company-yasnippet "company-yasnippet" "\
|
||||
`company-mode' backend for `yasnippet'.
|
||||
|
||||
This backend should be used with care, because as long as there are
|
||||
snippets defined for the current major mode, this backend will always
|
||||
shadow backends that come after it. Recommended usages:
|
||||
|
||||
* In a buffer-local value of `company-backends', grouped with a backend or
|
||||
several that provide actual text completions.
|
||||
|
||||
(add-hook 'js-mode-hook
|
||||
(lambda ()
|
||||
(set (make-local-variable 'company-backends)
|
||||
'((company-dabbrev-code company-yasnippet)))))
|
||||
|
||||
* After keyword `:with', grouped with other backends.
|
||||
|
||||
(push '(company-semantic :with company-yasnippet) company-backends)
|
||||
|
||||
* Not in `company-backends', just bound to a key.
|
||||
|
||||
(global-set-key (kbd \"C-c y\") 'company-yasnippet)
|
||||
|
||||
\(fn COMMAND &optional ARG &rest IGNORE)" t nil)
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "company-yasnippet" '("company-yasnippet-")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil nil ("company-pkg.el") (0 0 0 0))
|
||||
|
||||
;;;***
|
||||
|
||||
;; Local Variables:
|
||||
;; version-control: never
|
||||
;; no-byte-compile: t
|
||||
;; no-update-autoloads: t
|
||||
;; coding: utf-8
|
||||
;; End:
|
||||
;;; company-autoloads.el ends here
|
|
@ -1,63 +0,0 @@
|
|||
;;; company-bbdb.el --- company-mode completion backend for BBDB in message-mode
|
||||
|
||||
;; Copyright (C) 2013-2014, 2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Jan Tatarik <jan.tatarik@gmail.com>
|
||||
|
||||
;; 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
(require 'company)
|
||||
(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."
|
||||
:group 'company)
|
||||
|
||||
(defcustom company-bbdb-modes '(message-mode)
|
||||
"Major modes in which `company-bbdb' may complete."
|
||||
:type '(repeat (symbol :tag "Major mode"))
|
||||
:package-version '(company . "0.8.8"))
|
||||
|
||||
(defun company-bbdb--candidates (arg)
|
||||
(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))))
|
||||
|
||||
;;;###autoload
|
||||
(defun company-bbdb (command &optional arg &rest ignore)
|
||||
"`company-mode' completion backend for BBDB."
|
||||
(interactive (list 'interactive))
|
||||
(cl-case command
|
||||
(interactive (company-begin-backend 'company-bbdb))
|
||||
(prefix (and (memq major-mode company-bbdb-modes)
|
||||
(featurep 'bbdb-com)
|
||||
(let ((case-fold-search t))
|
||||
(looking-back
|
||||
"^\\([^ :]*-\\)?\\(To\\|B?Cc\\|From\\):.*? *\\([^,;]*\\)"
|
||||
(line-beginning-position)))
|
||||
(match-string-no-properties 3)))
|
||||
(candidates (company-bbdb--candidates arg))
|
||||
(sorted t)
|
||||
(no-cache t)))
|
||||
|
||||
(provide 'company-bbdb)
|
||||
;;; company-bbdb.el ends here
|
Binary file not shown.
|
@ -1,208 +0,0 @@
|
|||
;;; company-capf.el --- company-mode completion-at-point-functions backend -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
|
||||
|
||||
;; 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
;;; Commentary:
|
||||
;;
|
||||
;; The CAPF back-end provides a bridge to the standard
|
||||
;; completion-at-point-functions facility, and thus can support any major mode
|
||||
;; that defines a proper completion function, including emacs-lisp-mode,
|
||||
;; css-mode and nxml-mode.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'company)
|
||||
(require 'cl-lib)
|
||||
|
||||
;; 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'.
|
||||
For most properties/actions, this is just what we need: the exact values
|
||||
that accompanied the completion table that's currently is use.
|
||||
|
||||
`company-capf', however, could be called at some different positions during
|
||||
a completion session (most importantly, by `company-sort-by-occurrence'),
|
||||
so we can't just use the preceding variable instead.")
|
||||
|
||||
(defun company--capf-data ()
|
||||
(let ((cache company--capf-cache))
|
||||
(if (and (equal (current-buffer) (car cache))
|
||||
(equal (point) (car (setq cache (cdr cache))))
|
||||
(equal (buffer-chars-modified-tick) (car (setq cache (cdr cache)))))
|
||||
(cadr cache)
|
||||
(let ((data (company--capf-data-real)))
|
||||
(setq company--capf-cache
|
||||
(list (current-buffer) (point) (buffer-chars-modified-tick) data))
|
||||
data))))
|
||||
|
||||
(defun company--capf-data-real ()
|
||||
(cl-letf* (((default-value 'completion-at-point-functions)
|
||||
;; 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)))
|
||||
(completion-at-point-functions (company--capf-workaround))
|
||||
(data (run-hook-wrapped 'completion-at-point-functions
|
||||
;; Ignore misbehaving functions.
|
||||
#'completion--capf-wrapper 'optimist)))
|
||||
(when (and (consp (cdr data)) (integer-or-marker-p (nth 1 data))) data)))
|
||||
|
||||
(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)
|
||||
(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))
|
||||
|
||||
(defvar-local company-capf--sorted nil)
|
||||
|
||||
(defun company-capf (command &optional arg &rest _args)
|
||||
"`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))))))
|
||||
(`candidates
|
||||
(company-capf--candidates arg))
|
||||
(`sorted
|
||||
company-capf--sorted)
|
||||
(`match
|
||||
;; Ask the for the `:company-match' function. If that doesn't help,
|
||||
;; fallback to sniffing for face changes to get a suitable value.
|
||||
(let ((f (plist-get (nthcdr 4 company-capf--current-completion-data)
|
||||
:company-match)))
|
||||
(if f (funcall f arg)
|
||||
(let* ((match-start nil) (pos -1)
|
||||
(prop-value nil) (faces nil)
|
||||
(has-face-p nil) chunks
|
||||
(limit (length arg)))
|
||||
(while (< pos limit)
|
||||
(setq pos
|
||||
(if (< pos 0) 0 (next-property-change pos arg limit)))
|
||||
(setq prop-value (or
|
||||
(get-text-property pos 'face arg)
|
||||
(get-text-property pos 'font-lock-face arg))
|
||||
faces (if (listp prop-value) prop-value (list prop-value))
|
||||
has-face-p (memq 'completions-common-part faces))
|
||||
(cond ((and (not match-start) has-face-p)
|
||||
(setq match-start pos))
|
||||
((and match-start (not has-face-p))
|
||||
(push (cons match-start pos) chunks)
|
||||
(setq match-start nil))))
|
||||
(nreverse chunks)))))
|
||||
(`duplicates t)
|
||||
(`no-cache t) ;Not much can be done here, as long as we handle
|
||||
;non-prefix matches.
|
||||
(`meta
|
||||
(let ((f (plist-get (nthcdr 4 company-capf--current-completion-data)
|
||||
:company-docsig)))
|
||||
(when f (funcall f arg))))
|
||||
(`doc-buffer
|
||||
(let ((f (plist-get (nthcdr 4 company-capf--current-completion-data)
|
||||
:company-doc-buffer)))
|
||||
(when f (funcall f arg))))
|
||||
(`location
|
||||
(let ((f (plist-get (nthcdr 4 company-capf--current-completion-data)
|
||||
:company-location)))
|
||||
(when f (funcall f arg))))
|
||||
(`annotation
|
||||
(let ((f (plist-get (nthcdr 4 company-capf--current-completion-data)
|
||||
:annotation-function)))
|
||||
(when f (funcall f arg))))
|
||||
(`require-match
|
||||
(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))
|
||||
))
|
||||
|
||||
(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))
|
||||
(sortfun (cdr (assq 'display-sort-function meta)))
|
||||
(last (last candidates))
|
||||
(base-size (and (numberp (cdr last)) (cdr last))))
|
||||
(when base-size
|
||||
(setcdr last nil))
|
||||
(setq company-capf--sorted (functionp sortfun))
|
||||
(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)))))
|
||||
|
||||
(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'.
|
||||
(funcall exit-function arg
|
||||
;; FIXME: Should probably use an additional heuristic:
|
||||
;; completion-at-point doesn't know when the user picked a
|
||||
;; particular candidate explicitly (it only checks whether
|
||||
;; further completions exist). Whereas company user can press
|
||||
;; RET (or use implicit completion with company-tng).
|
||||
(if (= (car (completion-boundaries arg table nil ""))
|
||||
(length arg))
|
||||
'sole
|
||||
'finished)))))
|
||||
|
||||
(provide 'company-capf)
|
||||
|
||||
;;; company-capf.el ends here
|
Binary file not shown.
|
@ -1,385 +0,0 @@
|
|||
;;; company-clang.el --- company-mode completion backend for Clang -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2009, 2011, 2013-2019 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
;;; Commentary:
|
||||
;;
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'company)
|
||||
(require 'company-template)
|
||||
(require 'cl-lib)
|
||||
|
||||
(defgroup company-clang nil
|
||||
"Completion backend for Clang."
|
||||
:group 'company)
|
||||
|
||||
(defcustom company-clang-executable
|
||||
(executable-find "clang")
|
||||
"Location of clang executable."
|
||||
:type 'file)
|
||||
|
||||
(defcustom company-clang-begin-after-member-access t
|
||||
"When non-nil, automatic completion will start whenever the current
|
||||
symbol is preceded by \".\", \"->\" or \"::\", ignoring
|
||||
`company-minimum-prefix-length'.
|
||||
|
||||
If `company-begin-commands' is a list, it should include `c-electric-lt-gt'
|
||||
and `c-electric-colon', for automatic completion right after \">\" and
|
||||
\":\"."
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom company-clang-use-compile-flags-txt nil
|
||||
"When non-nil, use flags from compile_flags.txt if present.
|
||||
|
||||
The lines from that files will be appended to `company-clang-arguments'.
|
||||
|
||||
And if such file is found, Clang is called from the directory containing
|
||||
it. That allows the flags use relative file names within the project."
|
||||
:type 'boolean
|
||||
:safe 'booleanp)
|
||||
|
||||
(defcustom company-clang-arguments nil
|
||||
"Additional arguments to pass to clang when completing.
|
||||
Prefix files (-include ...) can be selected with `company-clang-set-prefix'
|
||||
or automatically through a custom `company-clang-prefix-guesser'."
|
||||
:type '(repeat (string :tag "Argument")))
|
||||
|
||||
(defcustom company-clang-prefix-guesser 'company-clang-guess-prefix
|
||||
"A function to determine the prefix file for the current buffer."
|
||||
:type '(function :tag "Guesser function" nil))
|
||||
|
||||
(defvar company-clang-modes '(c-mode c++-mode objc-mode)
|
||||
"Major modes which clang may complete.")
|
||||
|
||||
(defcustom company-clang-insert-arguments t
|
||||
"When non-nil, insert function arguments as a template after completion."
|
||||
:type 'boolean
|
||||
:package-version '(company . "0.8.0"))
|
||||
|
||||
;; prefix ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defvar company-clang--prefix nil)
|
||||
|
||||
(defsubst company-clang--guess-pch-file (file)
|
||||
(let ((dir (directory-file-name (file-name-directory file))))
|
||||
(when (equal (file-name-nondirectory dir) "Classes")
|
||||
(setq dir (file-name-directory dir)))
|
||||
(car (directory-files dir t "\\([^.]h\\|[^h]\\).pch\\'" t))))
|
||||
|
||||
(defsubst company-clang--file-substring (file beg end)
|
||||
(with-temp-buffer
|
||||
(insert-file-contents-literally file nil beg end)
|
||||
(buffer-string)))
|
||||
|
||||
(defun company-clang-guess-prefix ()
|
||||
"Try to guess the prefix file for the current buffer."
|
||||
;; Prefixes seem to be called .pch. Pre-compiled headers do, too.
|
||||
;; So we look at the magic number to rule them out.
|
||||
(let* ((file (company-clang--guess-pch-file buffer-file-name))
|
||||
(magic-number (and file (company-clang--file-substring file 0 4))))
|
||||
(unless (member magic-number '("CPCH" "gpch"))
|
||||
file)))
|
||||
|
||||
(defun company-clang-set-prefix (&optional prefix)
|
||||
"Use PREFIX as a prefix (-include ...) file for clang completion."
|
||||
(interactive (let ((def (funcall company-clang-prefix-guesser)))
|
||||
(unless (stringp def)
|
||||
(setq def default-directory))
|
||||
(list (read-file-name "Prefix file: "
|
||||
(when def (file-name-directory def))
|
||||
def t (when def (file-name-nondirectory def))))))
|
||||
;; TODO: pre-compile?
|
||||
(setq company-clang--prefix (and (stringp prefix)
|
||||
(file-regular-p prefix)
|
||||
prefix)))
|
||||
|
||||
;; Clean-up on exit.
|
||||
(add-hook 'kill-emacs-hook 'company-clang-set-prefix)
|
||||
|
||||
;; parsing ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;; TODO: Handle Pattern (syntactic hints would be neat).
|
||||
;; Do we ever see OVERLOAD (or OVERRIDE)?
|
||||
(defconst company-clang--completion-pattern
|
||||
"^COMPLETION: \\_<\\(%s[a-zA-Z0-9_:]*\\)\\(?:\\(?: (InBase)\\)? : \\(.*\\)$\\)?$")
|
||||
|
||||
(defconst company-clang--error-buffer-name "*clang-error*")
|
||||
|
||||
(defun company-clang--lang-option ()
|
||||
(if (eq major-mode 'objc-mode)
|
||||
(if (string= "m" (file-name-extension buffer-file-name))
|
||||
"objective-c" "objective-c++")
|
||||
(substring (symbol-name major-mode) 0 -5)))
|
||||
|
||||
(defun company-clang--parse-output (prefix _objc)
|
||||
(goto-char (point-min))
|
||||
(let ((pattern (format company-clang--completion-pattern
|
||||
(regexp-quote prefix)))
|
||||
(case-fold-search nil)
|
||||
lines match)
|
||||
(while (re-search-forward pattern nil t)
|
||||
(setq match (match-string-no-properties 1))
|
||||
(unless (equal match "Pattern")
|
||||
(save-match-data
|
||||
(when (string-match ":" match)
|
||||
(setq match (substring match 0 (match-beginning 0)))))
|
||||
(let ((meta (match-string-no-properties 2)))
|
||||
(when (and meta (not (string= match meta)))
|
||||
(put-text-property 0 1 'meta
|
||||
(company-clang--strip-formatting meta)
|
||||
match)))
|
||||
(push match lines)))
|
||||
lines))
|
||||
|
||||
(defun company-clang--meta (candidate)
|
||||
(get-text-property 0 'meta candidate))
|
||||
|
||||
(defun company-clang--annotation (candidate)
|
||||
(let ((ann (company-clang--annotation-1 candidate)))
|
||||
(if (not (and ann (string-prefix-p "(*)" ann)))
|
||||
ann
|
||||
(with-temp-buffer
|
||||
(insert ann)
|
||||
(search-backward ")")
|
||||
(let ((pt (1+ (point))))
|
||||
(re-search-forward ".\\_>" nil t)
|
||||
(delete-region pt (point)))
|
||||
(buffer-string)))))
|
||||
|
||||
(defun company-clang--annotation-1 (candidate)
|
||||
(let ((meta (company-clang--meta candidate)))
|
||||
(cond
|
||||
((null meta) nil)
|
||||
((string-match "[^:]:[^:]" meta)
|
||||
(substring meta (1+ (match-beginning 0))))
|
||||
((string-match "(anonymous)" meta) nil)
|
||||
((string-match "\\((.*)[ a-z]*\\'\\)" meta)
|
||||
(let ((paren (match-beginning 1)))
|
||||
(if (not (eq (aref meta (1- paren)) ?>))
|
||||
(match-string 1 meta)
|
||||
(with-temp-buffer
|
||||
(insert meta)
|
||||
(goto-char paren)
|
||||
(substring meta (1- (search-backward "<"))))))))))
|
||||
|
||||
(defun company-clang--strip-formatting (text)
|
||||
(replace-regexp-in-string
|
||||
"#]" " "
|
||||
(replace-regexp-in-string "[<{[]#\\|#[>}]" "" text t)
|
||||
t))
|
||||
|
||||
(defun company-clang--handle-error (res args)
|
||||
(goto-char (point-min))
|
||||
(let* ((buf (get-buffer-create company-clang--error-buffer-name))
|
||||
(cmd (concat company-clang-executable " " (mapconcat 'identity args " ")))
|
||||
(pattern (format company-clang--completion-pattern ""))
|
||||
(message-truncate-lines t)
|
||||
(err (if (re-search-forward pattern nil t)
|
||||
(buffer-substring-no-properties (point-min)
|
||||
(1- (match-beginning 0)))
|
||||
;; Warn the user more aggressively if no match was found.
|
||||
(message "clang failed with error %d: %s" res cmd)
|
||||
(buffer-string))))
|
||||
|
||||
(with-current-buffer buf
|
||||
(let ((inhibit-read-only t))
|
||||
(erase-buffer)
|
||||
(insert (current-time-string)
|
||||
(format "\nclang failed with error %d:\n" res)
|
||||
cmd "\n\n")
|
||||
(insert err)
|
||||
(setq buffer-read-only t)
|
||||
(goto-char (point-min))))))
|
||||
|
||||
(defun company-clang--start-process (prefix callback &rest args)
|
||||
(let* ((objc (derived-mode-p 'objc-mode))
|
||||
(buf (get-buffer-create "*clang-output*"))
|
||||
;; Looks unnecessary in Emacs 25.1 and later.
|
||||
(process-adaptive-read-buffering nil)
|
||||
(existing-process (get-buffer-process buf)))
|
||||
(when existing-process
|
||||
(kill-process existing-process))
|
||||
(with-current-buffer buf
|
||||
(erase-buffer)
|
||||
(setq buffer-undo-list t))
|
||||
(let* ((process-connection-type nil)
|
||||
(process (apply #'start-file-process "company-clang" buf
|
||||
company-clang-executable args)))
|
||||
(set-process-sentinel
|
||||
process
|
||||
(lambda (proc status)
|
||||
(unless (string-match-p "hangup\\|killed" status)
|
||||
(funcall
|
||||
callback
|
||||
(let ((res (process-exit-status proc)))
|
||||
(with-current-buffer buf
|
||||
(unless (eq 0 res)
|
||||
(company-clang--handle-error res args))
|
||||
;; Still try to get any useful input.
|
||||
(company-clang--parse-output prefix objc)))))))
|
||||
(unless (company-clang--auto-save-p)
|
||||
(send-region process (point-min) (point-max))
|
||||
(send-string process "\n")
|
||||
(process-send-eof process)))))
|
||||
|
||||
(defsubst company-clang--build-location (pos)
|
||||
(save-excursion
|
||||
(goto-char pos)
|
||||
(format "%s:%d:%d"
|
||||
(if (company-clang--auto-save-p) buffer-file-name "-")
|
||||
(line-number-at-pos)
|
||||
(1+ (length
|
||||
(encode-coding-region
|
||||
(line-beginning-position)
|
||||
(point)
|
||||
'utf-8
|
||||
t))))))
|
||||
|
||||
(defsubst company-clang--build-complete-args (pos)
|
||||
(append '("-fsyntax-only" "-Xclang" "-code-completion-macros")
|
||||
(unless (company-clang--auto-save-p)
|
||||
(list "-x" (company-clang--lang-option)))
|
||||
(company-clang--arguments)
|
||||
(when (stringp company-clang--prefix)
|
||||
(list "-include" (expand-file-name company-clang--prefix)))
|
||||
(list "-Xclang" (format "-code-completion-at=%s"
|
||||
(company-clang--build-location pos)))
|
||||
(list (if (company-clang--auto-save-p) buffer-file-name "-"))))
|
||||
|
||||
(defun company-clang--arguments ()
|
||||
(let ((fname "compile_flags.txt")
|
||||
(args company-clang-arguments)
|
||||
current-dir-rel)
|
||||
(when company-clang-use-compile-flags-txt
|
||||
(let ((dir (locate-dominating-file default-directory fname)))
|
||||
(when dir
|
||||
(setq current-dir-rel (file-relative-name default-directory dir))
|
||||
(setq default-directory dir)
|
||||
(with-temp-buffer
|
||||
(insert-file-contents fname)
|
||||
(setq args
|
||||
(append
|
||||
args
|
||||
(split-string (buffer-substring-no-properties
|
||||
(point-min) (point-max))
|
||||
"[\n\r]+"
|
||||
t
|
||||
"[ \t]+"))))
|
||||
(unless (equal current-dir-rel "./")
|
||||
(push (format "-I%s" current-dir-rel) args)))))
|
||||
args))
|
||||
|
||||
(defun company-clang--candidates (prefix callback)
|
||||
(and (company-clang--auto-save-p)
|
||||
(buffer-modified-p)
|
||||
(basic-save-buffer))
|
||||
(when (null company-clang--prefix)
|
||||
(company-clang-set-prefix (or (funcall company-clang-prefix-guesser)
|
||||
'none)))
|
||||
(let ((default-directory default-directory))
|
||||
(apply 'company-clang--start-process
|
||||
prefix
|
||||
callback
|
||||
(company-clang--build-complete-args
|
||||
(if (company-clang--check-version 4.0 9.0)
|
||||
(point)
|
||||
(- (point) (length prefix)))))))
|
||||
|
||||
(defun company-clang--prefix ()
|
||||
(if company-clang-begin-after-member-access
|
||||
(company-grab-symbol-cons "\\.\\|->\\|::" 2)
|
||||
(company-grab-symbol)))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defconst company-clang-required-version 1.1)
|
||||
|
||||
(defvar company-clang--version nil)
|
||||
|
||||
(defun company-clang--auto-save-p ()
|
||||
(not
|
||||
(company-clang--check-version 2.9 3.1)))
|
||||
|
||||
(defun company-clang--check-version (min apple-min)
|
||||
(pcase company-clang--version
|
||||
(`(apple . ,ver) (>= ver apple-min))
|
||||
(`(normal . ,ver) (>= ver min))
|
||||
(_ (error "pcase-exhaustive is not in Emacs 24.3!"))))
|
||||
|
||||
(defsubst company-clang-version ()
|
||||
"Return the version of `company-clang-executable'."
|
||||
(with-temp-buffer
|
||||
(call-process company-clang-executable nil t nil "--version")
|
||||
(goto-char (point-min))
|
||||
(if (re-search-forward
|
||||
"\\(clang\\|Apple LLVM\\|bcc32x\\|bcc64\\) version \\([0-9.]+\\)" nil t)
|
||||
(cons
|
||||
(if (equal (match-string-no-properties 1) "Apple LLVM")
|
||||
'apple
|
||||
'normal)
|
||||
(string-to-number (match-string-no-properties 2)))
|
||||
0)))
|
||||
|
||||
(defun company-clang (command &optional arg &rest ignored)
|
||||
"`company-mode' completion backend for Clang.
|
||||
Clang is a parser for C and ObjC. Clang version 1.1 or newer is required.
|
||||
|
||||
Additional command line arguments can be specified in
|
||||
`company-clang-arguments'. Prefix files (-include ...) can be selected
|
||||
with `company-clang-set-prefix' or automatically through a custom
|
||||
`company-clang-prefix-guesser'.
|
||||
|
||||
With Clang versions before 2.9, we have to save the buffer before
|
||||
performing completion. With Clang 2.9 and later, buffer contents are
|
||||
passed via standard input."
|
||||
(interactive (list 'interactive))
|
||||
(cl-case command
|
||||
(interactive (company-begin-backend 'company-clang))
|
||||
(init (when (memq major-mode company-clang-modes)
|
||||
(unless company-clang-executable
|
||||
(error "Company found no clang executable"))
|
||||
(setq company-clang--version (company-clang-version))
|
||||
(unless (company-clang--check-version
|
||||
company-clang-required-version
|
||||
company-clang-required-version)
|
||||
(error "Company requires clang version %s"
|
||||
company-clang-required-version))))
|
||||
(prefix (and (memq major-mode company-clang-modes)
|
||||
buffer-file-name
|
||||
company-clang-executable
|
||||
(not (company-in-string-or-comment))
|
||||
(or (company-clang--prefix) 'stop)))
|
||||
(candidates (cons :async
|
||||
(lambda (cb) (company-clang--candidates arg cb))))
|
||||
(meta (company-clang--meta arg))
|
||||
(annotation (company-clang--annotation arg))
|
||||
(post-completion (let ((anno (company-clang--annotation arg)))
|
||||
(when (and company-clang-insert-arguments anno)
|
||||
(insert anno)
|
||||
(if (string-match "\\`:[^:]" anno)
|
||||
(company-template-objc-templatify anno)
|
||||
(company-template-c-like-templatify
|
||||
(concat arg anno))))))))
|
||||
|
||||
(provide 'company-clang)
|
||||
;;; company-clang.el ends here
|
Binary file not shown.
|
@ -1,206 +0,0 @@
|
|||
;;; company-cmake.el --- company-mode completion backend for CMake
|
||||
|
||||
;; Copyright (C) 2013-2014, 2017-2018 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Chen Bin <chenbin DOT sh AT gmail>
|
||||
;; Version: 0.2
|
||||
|
||||
;; 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
;;
|
||||
;; company-cmake offers completions for module names, variable names and
|
||||
;; commands used by CMake. And their descriptions.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'company)
|
||||
(require 'cl-lib)
|
||||
|
||||
(defgroup company-cmake nil
|
||||
"Completion backend for CMake."
|
||||
:group 'company)
|
||||
|
||||
(defcustom company-cmake-executable
|
||||
(executable-find "cmake")
|
||||
"Location of cmake executable."
|
||||
:type 'file)
|
||||
|
||||
(defvar company-cmake-executable-arguments
|
||||
'("--help-command-list"
|
||||
"--help-module-list"
|
||||
"--help-variable-list")
|
||||
"The arguments we pass to cmake, separately.
|
||||
They affect which types of symbols we get completion candidates for.")
|
||||
|
||||
(defvar company-cmake--completion-pattern
|
||||
"^\\(%s[a-zA-Z0-9_<>]%s\\)$"
|
||||
"Regexp to match the candidates.")
|
||||
|
||||
(defvar company-cmake-modes '(cmake-mode)
|
||||
"Major modes in which cmake may complete.")
|
||||
|
||||
(defvar company-cmake--candidates-cache nil
|
||||
"Cache for the raw candidates.")
|
||||
|
||||
(defvar company-cmake--meta-command-cache nil
|
||||
"Cache for command arguments to retrieve descriptions for the candidates.")
|
||||
|
||||
(defun company-cmake--replace-tags (rlt)
|
||||
(setq rlt (replace-regexp-in-string
|
||||
"\\(.*?\\(IS_GNU\\)?\\)<LANG>\\(.*\\)"
|
||||
(lambda (_match)
|
||||
(mapconcat 'identity
|
||||
(if (match-beginning 2)
|
||||
'("\\1CXX\\3" "\\1C\\3" "\\1G77\\3")
|
||||
'("\\1CXX\\3" "\\1C\\3" "\\1Fortran\\3"))
|
||||
"\n"))
|
||||
rlt t))
|
||||
(setq rlt (replace-regexp-in-string
|
||||
"\\(.*\\)<CONFIG>\\(.*\\)"
|
||||
(mapconcat 'identity '("\\1DEBUG\\2" "\\1RELEASE\\2"
|
||||
"\\1RELWITHDEBINFO\\2" "\\1MINSIZEREL\\2")
|
||||
"\n")
|
||||
rlt))
|
||||
rlt)
|
||||
|
||||
(defun company-cmake--fill-candidates-cache (arg)
|
||||
"Fill candidates cache if needed."
|
||||
(let (rlt)
|
||||
(unless company-cmake--candidates-cache
|
||||
(setq company-cmake--candidates-cache (make-hash-table :test 'equal)))
|
||||
|
||||
;; If hash is empty, fill it.
|
||||
(unless (gethash arg company-cmake--candidates-cache)
|
||||
(with-temp-buffer
|
||||
(let ((res (call-process company-cmake-executable nil t nil arg)))
|
||||
(unless (zerop res)
|
||||
(message "cmake executable exited with error=%d" res)))
|
||||
(setq rlt (buffer-string)))
|
||||
(setq rlt (company-cmake--replace-tags rlt))
|
||||
(puthash arg rlt company-cmake--candidates-cache))
|
||||
))
|
||||
|
||||
(defun company-cmake--parse (prefix content cmd)
|
||||
(let ((start 0)
|
||||
(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)
|
||||
(let ((match (match-string 1 line)))
|
||||
(when match
|
||||
(puthash match cmd company-cmake--meta-command-cache)
|
||||
(push match rlt)))))
|
||||
rlt))
|
||||
|
||||
(defun company-cmake--candidates (prefix)
|
||||
(let (results
|
||||
cmd-opts
|
||||
str)
|
||||
|
||||
(unless company-cmake--meta-command-cache
|
||||
(setq company-cmake--meta-command-cache (make-hash-table :test 'equal)))
|
||||
|
||||
(dolist (arg company-cmake-executable-arguments)
|
||||
(company-cmake--fill-candidates-cache arg)
|
||||
(setq cmd-opts (replace-regexp-in-string "-list$" "" arg) )
|
||||
|
||||
(setq str (gethash arg company-cmake--candidates-cache))
|
||||
(when str
|
||||
(setq results (nconc results
|
||||
(company-cmake--parse prefix str cmd-opts)))))
|
||||
results))
|
||||
|
||||
(defun company-cmake--unexpand-candidate (candidate)
|
||||
(cond
|
||||
((string-match "^CMAKE_\\(C\\|CXX\\|Fortran\\)\\(_.*\\)$" candidate)
|
||||
(setq candidate (concat "CMAKE_<LANG>" (match-string 2 candidate))))
|
||||
|
||||
;; C flags
|
||||
((string-match "^\\(.*_\\)IS_GNU\\(C\\|CXX\\|G77\\)$" candidate)
|
||||
(setq candidate (concat (match-string 1 candidate) "IS_GNU<LANG>")))
|
||||
|
||||
;; C flags
|
||||
((string-match "^\\(.*_\\)OVERRIDE_\\(C\\|CXX\\|Fortran\\)$" candidate)
|
||||
(setq candidate (concat (match-string 1 candidate) "OVERRIDE_<LANG>")))
|
||||
|
||||
((string-match "^\\(.*\\)\\(_DEBUG\\|_RELEASE\\|_RELWITHDEBINFO\\|_MINSIZEREL\\)\\(.*\\)$" candidate)
|
||||
(setq candidate (concat (match-string 1 candidate)
|
||||
"_<CONFIG>"
|
||||
(match-string 3 candidate)))))
|
||||
candidate)
|
||||
|
||||
(defun company-cmake--meta (candidate)
|
||||
(let ((cmd-opts (gethash candidate company-cmake--meta-command-cache))
|
||||
result)
|
||||
(setq candidate (company-cmake--unexpand-candidate candidate))
|
||||
|
||||
;; Don't cache the documentation of every candidate (command)
|
||||
;; Cache in this case will cost too much memory.
|
||||
(with-temp-buffer
|
||||
(call-process company-cmake-executable nil t nil cmd-opts candidate)
|
||||
;; Go to the third line, trim it and return the result.
|
||||
;; Tested with cmake 2.8.9.
|
||||
(goto-char (point-min))
|
||||
(forward-line 2)
|
||||
(setq result (buffer-substring-no-properties (line-beginning-position)
|
||||
(line-end-position)))
|
||||
(setq result (replace-regexp-in-string "^[ \t\n\r]+" "" result))
|
||||
result)))
|
||||
|
||||
(defun company-cmake--doc-buffer (candidate)
|
||||
(let ((cmd-opts (gethash candidate company-cmake--meta-command-cache)))
|
||||
|
||||
(setq candidate (company-cmake--unexpand-candidate candidate))
|
||||
(with-temp-buffer
|
||||
(call-process company-cmake-executable nil t nil cmd-opts candidate)
|
||||
;; Go to the third line, trim it and return the doc buffer.
|
||||
;; Tested with cmake 2.8.9.
|
||||
(goto-char (point-min))
|
||||
(forward-line 2)
|
||||
(company-doc-buffer
|
||||
(buffer-substring-no-properties (line-beginning-position)
|
||||
(point-max))))))
|
||||
|
||||
(defun company-cmake-prefix-dollar-brace-p ()
|
||||
"Test if the current symbol follows ${."
|
||||
(save-excursion
|
||||
(skip-syntax-backward "w_")
|
||||
(and (eq (char-before (point)) ?\{)
|
||||
(eq (char-before (1- (point))) ?$))))
|
||||
|
||||
(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))
|
||||
(cl-case command
|
||||
(interactive (company-begin-backend 'company-cmake))
|
||||
(init (when (memq major-mode company-cmake-modes)
|
||||
(unless company-cmake-executable
|
||||
(error "Company found no cmake executable"))))
|
||||
(prefix (and (memq major-mode company-cmake-modes)
|
||||
(or (not (company-in-string-or-comment))
|
||||
(company-cmake-prefix-dollar-brace-p))
|
||||
(company-grab-symbol)))
|
||||
(candidates (company-cmake--candidates arg))
|
||||
(meta (company-cmake--meta arg))
|
||||
(doc-buffer (company-cmake--doc-buffer arg))
|
||||
))
|
||||
|
||||
(provide 'company-cmake)
|
||||
;;; company-cmake.el ends here
|
Binary file not shown.
|
@ -1,446 +0,0 @@
|
|||
;;; company-css.el --- company-mode completion backend for css-mode -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2009, 2011, 2014, 2018 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
;;
|
||||
;; In Emacs >= 26, company-capf is used instead.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'company)
|
||||
(require 'cl-lib)
|
||||
|
||||
(declare-function web-mode-language-at-pos "web-mode" (&optional pos))
|
||||
|
||||
(defconst company-css-property-alist
|
||||
;; see http://www.w3.org/TR/CSS21/propidx.html
|
||||
'(("azimuth" angle "left-side" "far-left" "left" "center-left" "center"
|
||||
"center-right" "right" "far-right" "right-side" "behind" "leftwards"
|
||||
"rightwards")
|
||||
("background" background-color background-image background-repeat
|
||||
background-attachment background-position
|
||||
background-clip background-origin background-size)
|
||||
("background-attachment" "scroll" "fixed")
|
||||
("background-color" color "transparent")
|
||||
("background-image" uri "none")
|
||||
("background-position" percentage length "left" "center" "right" percentage
|
||||
length "top" "center" "bottom" "left" "center" "right" "top" "center"
|
||||
"bottom")
|
||||
("background-repeat" "repeat" "repeat-x" "repeat-y" "no-repeat")
|
||||
("border" border-width border-style border-color)
|
||||
("border-bottom" border)
|
||||
("border-bottom-color" border-color)
|
||||
("border-bottom-style" border-style)
|
||||
("border-bottom-width" border-width)
|
||||
("border-collapse" "collapse" "separate")
|
||||
("border-color" color "transparent")
|
||||
("border-left" border)
|
||||
("border-left-color" border-color)
|
||||
("border-left-style" border-style)
|
||||
("border-left-width" border-width)
|
||||
("border-right" border)
|
||||
("border-right-color" border-color)
|
||||
("border-right-style" border-style)
|
||||
("border-right-width" border-width)
|
||||
("border-spacing" length length)
|
||||
("border-style" border-style)
|
||||
("border-top" border)
|
||||
("border-top-color" border-color)
|
||||
("border-top-style" border-style)
|
||||
("border-top-width" border-width)
|
||||
("border-width" border-width)
|
||||
("bottom" length percentage "auto")
|
||||
("caption-side" "top" "bottom")
|
||||
("clear" "none" "left" "right" "both")
|
||||
("clip" shape "auto")
|
||||
("color" color)
|
||||
("content" "normal" "none" string uri counter "attr()" "open-quote"
|
||||
"close-quote" "no-open-quote" "no-close-quote")
|
||||
("counter-increment" identifier integer "none")
|
||||
("counter-reset" identifier integer "none")
|
||||
("cue" cue-before cue-after)
|
||||
("cue-after" uri "none")
|
||||
("cue-before" uri "none")
|
||||
("cursor" uri "*" "auto" "crosshair" "default" "pointer" "move" "e-resize"
|
||||
"ne-resize" "nw-resize" "n-resize" "se-resize" "sw-resize" "s-resize"
|
||||
"w-resize" "text" "wait" "help" "progress")
|
||||
("direction" "ltr" "rtl")
|
||||
("display" "inline" "block" "list-item" "run-in" "inline-block" "table"
|
||||
"inline-table" "table-row-group" "table-header-group" "table-footer-group"
|
||||
"table-row" "table-column-group" "table-column" "table-cell"
|
||||
"table-caption" "none")
|
||||
("elevation" angle "below" "level" "above" "higher" "lower")
|
||||
("empty-cells" "show" "hide")
|
||||
("float" "left" "right" "none")
|
||||
("font" font-style font-weight font-size "/" line-height
|
||||
font-family "caption" "icon" "menu" "message-box" "small-caption"
|
||||
"status-bar" "normal" "small-caps"
|
||||
;; CSS3
|
||||
font-stretch)
|
||||
("font-family" family-name generic-family)
|
||||
("font-size" absolute-size relative-size length percentage)
|
||||
("font-style" "normal" "italic" "oblique")
|
||||
("font-weight" "normal" "bold" "bolder" "lighter" "100" "200" "300" "400"
|
||||
"500" "600" "700" "800" "900")
|
||||
("height" length percentage "auto")
|
||||
("left" length percentage "auto")
|
||||
("letter-spacing" "normal" length)
|
||||
("line-height" "normal" number length percentage)
|
||||
("list-style" list-style-type list-style-position list-style-image)
|
||||
("list-style-image" uri "none")
|
||||
("list-style-position" "inside" "outside")
|
||||
("list-style-type" "disc" "circle" "square" "decimal" "decimal-leading-zero"
|
||||
"lower-roman" "upper-roman" "lower-greek" "lower-latin" "upper-latin"
|
||||
"armenian" "georgian" "lower-alpha" "upper-alpha" "none")
|
||||
("margin" margin-width)
|
||||
("margin-bottom" margin-width)
|
||||
("margin-left" margin-width)
|
||||
("margin-right" margin-width)
|
||||
("margin-top" margin-width)
|
||||
("max-height" length percentage "none")
|
||||
("max-width" length percentage "none")
|
||||
("min-height" length percentage)
|
||||
("min-width" length percentage)
|
||||
("orphans" integer)
|
||||
("outline" outline-color outline-style outline-width)
|
||||
("outline-color" color "invert")
|
||||
("outline-style" border-style)
|
||||
("outline-width" border-width)
|
||||
("overflow" "visible" "hidden" "scroll" "auto"
|
||||
;; CSS3:
|
||||
"no-display" "no-content")
|
||||
("padding" padding-width)
|
||||
("padding-bottom" padding-width)
|
||||
("padding-left" padding-width)
|
||||
("padding-right" padding-width)
|
||||
("padding-top" padding-width)
|
||||
("page-break-after" "auto" "always" "avoid" "left" "right")
|
||||
("page-break-before" "auto" "always" "avoid" "left" "right")
|
||||
("page-break-inside" "avoid" "auto")
|
||||
("pause" time percentage)
|
||||
("pause-after" time percentage)
|
||||
("pause-before" time percentage)
|
||||
("pitch" frequency "x-low" "low" "medium" "high" "x-high")
|
||||
("pitch-range" number)
|
||||
("play-during" uri "mix" "repeat" "auto" "none")
|
||||
("position" "static" "relative" "absolute" "fixed")
|
||||
("quotes" string string "none")
|
||||
("richness" number)
|
||||
("right" length percentage "auto")
|
||||
("speak" "normal" "none" "spell-out")
|
||||
("speak-header" "once" "always")
|
||||
("speak-numeral" "digits" "continuous")
|
||||
("speak-punctuation" "code" "none")
|
||||
("speech-rate" number "x-slow" "slow" "medium" "fast" "x-fast" "faster"
|
||||
"slower")
|
||||
("stress" number)
|
||||
("table-layout" "auto" "fixed")
|
||||
("text-align" "left" "right" "center" "justify")
|
||||
("text-indent" length percentage)
|
||||
("text-transform" "capitalize" "uppercase" "lowercase" "none")
|
||||
("top" length percentage "auto")
|
||||
("unicode-bidi" "normal" "embed" "bidi-override")
|
||||
("vertical-align" "baseline" "sub" "super" "top" "text-top" "middle"
|
||||
"bottom" "text-bottom" percentage length)
|
||||
("visibility" "visible" "hidden" "collapse")
|
||||
("voice-family" specific-voice generic-voice "*" specific-voice
|
||||
generic-voice)
|
||||
("volume" number percentage "silent" "x-soft" "soft" "medium" "loud"
|
||||
"x-loud")
|
||||
("white-space" "normal" "pre" "nowrap" "pre-wrap" "pre-line")
|
||||
("widows" integer)
|
||||
("width" length percentage "auto")
|
||||
("word-spacing" "normal" length)
|
||||
("z-index" "auto" integer)
|
||||
;; CSS3
|
||||
("align-content" align-stretch "space-between" "space-around")
|
||||
("align-items" align-stretch "baseline")
|
||||
("align-self" align-items "auto")
|
||||
("animation" animation-name animation-duration animation-timing-function
|
||||
animation-delay animation-iteration-count animation-direction
|
||||
animation-fill-mode)
|
||||
("animation-delay" time)
|
||||
("animation-direction" "normal" "reverse" "alternate" "alternate-reverse")
|
||||
("animation-duration" time)
|
||||
("animation-fill-mode" "none" "forwards" "backwards" "both")
|
||||
("animation-iteration-count" integer "infinite")
|
||||
("animation-name" "none")
|
||||
("animation-play-state" "paused" "running")
|
||||
("animation-timing-function" transition-timing-function
|
||||
"step-start" "step-end" "steps(,)")
|
||||
("backface-visibility" "visible" "hidden")
|
||||
("background-clip" background-origin)
|
||||
("background-origin" "border-box" "padding-box" "content-box")
|
||||
("background-size" length percentage "auto" "cover" "contain")
|
||||
("border-image" border-image-outset border-image-repeat border-image-source
|
||||
border-image-slice border-image-width)
|
||||
("border-image-outset" length)
|
||||
("border-image-repeat" "stretch" "repeat" "round" "space")
|
||||
("border-image-source" uri "none")
|
||||
("border-image-slice" length)
|
||||
("border-image-width" length percentage)
|
||||
("border-radius" length)
|
||||
("border-top-left-radius" length)
|
||||
("border-top-right-radius" length)
|
||||
("border-bottom-left-radius" length)
|
||||
("border-bottom-right-radius" length)
|
||||
("box-decoration-break" "slice" "clone")
|
||||
("box-shadow" length color)
|
||||
("box-sizing" "content-box" "border-box")
|
||||
("break-after" "auto" "always" "avoid" "left" "right" "page" "column"
|
||||
"avoid-page" "avoid-column")
|
||||
("break-before" break-after)
|
||||
("break-inside" "avoid" "auto")
|
||||
("columns" column-width column-count)
|
||||
("column-count" integer)
|
||||
("column-fill" "auto" "balance")
|
||||
("column-gap" length "normal")
|
||||
("column-rule" column-rule-width column-rule-style column-rule-color)
|
||||
("column-rule-color" color)
|
||||
("column-rule-style" border-style)
|
||||
("column-rule-width" border-width)
|
||||
("column-span" "all" "none")
|
||||
("column-width" length "auto")
|
||||
("filter" url "blur()" "brightness()" "contrast()" "drop-shadow()"
|
||||
"grayscale()" "hue-rotate()" "invert()" "opacity()" "saturate()" "sepia()")
|
||||
("flex" flex-grow flex-shrink flex-basis)
|
||||
("flex-basis" percentage length "auto")
|
||||
("flex-direction" "row" "row-reverse" "column" "column-reverse")
|
||||
("flex-flow" flex-direction flex-wrap)
|
||||
("flex-grow" number)
|
||||
("flex-shrink" number)
|
||||
("flex-wrap" "nowrap" "wrap" "wrap-reverse")
|
||||
("font-feature-setting" normal string number)
|
||||
("font-kerning" "auto" "normal" "none")
|
||||
("font-language-override" "normal" string)
|
||||
("font-size-adjust" "none" number)
|
||||
("font-stretch" "normal" "ultra-condensed" "extra-condensed" "condensed"
|
||||
"semi-condensed" "semi-expanded" "expanded" "extra-expanded" "ultra-expanded")
|
||||
("font-synthesis" "none" "weight" "style")
|
||||
("font-variant" font-variant-alternates font-variant-caps
|
||||
font-variant-east-asian font-variant-ligatures font-variant-numeric
|
||||
font-variant-position)
|
||||
("font-variant-alternates" "normal" "historical-forms" "stylistic()"
|
||||
"styleset()" "character-variant()" "swash()" "ornaments()" "annotation()")
|
||||
("font-variant-caps" "normal" "small-caps" "all-small-caps" "petite-caps"
|
||||
"all-petite-caps" "unicase" "titling-caps")
|
||||
("font-variant-east-asian" "jis78" "jis83" "jis90" "jis04" "simplified"
|
||||
"traditional" "full-width" "proportional-width" "ruby")
|
||||
("font-variant-ligatures" "normal" "none" "common-ligatures"
|
||||
"no-common-ligatures" "discretionary-ligatures" "no-discretionary-ligatures"
|
||||
"historical-ligatures" "no-historical-ligatures" "contextual" "no-contextual")
|
||||
("font-variant-numeric" "normal" "ordinal" "slashed-zero"
|
||||
"lining-nums" "oldstyle-nums" "proportional-nums" "tabular-nums"
|
||||
"diagonal-fractions" "stacked-fractions")
|
||||
("font-variant-position" "normal" "sub" "super")
|
||||
("hyphens" "none" "manual" "auto")
|
||||
("justify-content" align-common "space-between" "space-around")
|
||||
("line-break" "auto" "loose" "normal" "strict")
|
||||
("marquee-direction" "forward" "reverse")
|
||||
("marquee-play-count" integer "infinite")
|
||||
("marquee-speed" "slow" "normal" "fast")
|
||||
("marquee-style" "scroll" "slide" "alternate")
|
||||
("opacity" number)
|
||||
("order" number)
|
||||
("outline-offset" length)
|
||||
("overflow-x" overflow)
|
||||
("overflow-y" overflow)
|
||||
("overflow-style" "auto" "marquee-line" "marquee-block")
|
||||
("overflow-wrap" "normal" "break-word")
|
||||
("perspective" "none" length)
|
||||
("perspective-origin" percentage length "left" "center" "right" "top" "bottom")
|
||||
("resize" "none" "both" "horizontal" "vertical")
|
||||
("tab-size" integer length)
|
||||
("text-align-last" "auto" "start" "end" "left" "right" "center" "justify")
|
||||
("text-decoration" text-decoration-color text-decoration-line text-decoration-style)
|
||||
("text-decoration-color" color)
|
||||
("text-decoration-line" "none" "underline" "overline" "line-through" "blink")
|
||||
("text-decoration-style" "solid" "double" "dotted" "dashed" "wavy")
|
||||
("text-overflow" "clip" "ellipsis")
|
||||
("text-shadow" color length)
|
||||
("text-underline-position" "auto" "under" "left" "right")
|
||||
("transform" "matrix(,,,,,)" "translate(,)" "translateX()" "translateY()"
|
||||
"scale()" "scaleX()" "scaleY()" "rotate()" "skewX()" "skewY()" "none")
|
||||
("transform-origin" perspective-origin)
|
||||
("transform-style" "flat" "preserve-3d")
|
||||
("transition" transition-property transition-duration
|
||||
transition-timing-function transition-delay)
|
||||
("transition-delay" time)
|
||||
("transition-duration" time)
|
||||
("transition-timing-function"
|
||||
"ease" "linear" "ease-in" "ease-out" "ease-in-out" "cubic-bezier(,,,)")
|
||||
("transition-property" "none" "all" identifier)
|
||||
("word-wrap" overflow-wrap)
|
||||
("word-break" "normal" "break-all" "keep-all"))
|
||||
"A list of CSS properties and their possible values.")
|
||||
|
||||
(defconst company-css-value-classes
|
||||
'((absolute-size "xx-small" "x-small" "small" "medium" "large" "x-large"
|
||||
"xx-large")
|
||||
(align-common "flex-start" "flex-end" "center")
|
||||
(align-stretch align-common "stretch")
|
||||
(border-style "none" "hidden" "dotted" "dashed" "solid" "double" "groove"
|
||||
"ridge" "inset" "outset")
|
||||
(border-width "thick" "medium" "thin")
|
||||
(color "aqua" "black" "blue" "fuchsia" "gray" "green" "lime" "maroon" "navy"
|
||||
"olive" "orange" "purple" "red" "silver" "teal" "white" "yellow")
|
||||
(counter "counter(,)")
|
||||
(family-name "Courier" "Helvetica" "Times")
|
||||
(generic-family "serif" "sans-serif" "cursive" "fantasy" "monospace")
|
||||
(generic-voice "male" "female" "child")
|
||||
(margin-width "auto") ;; length percentage
|
||||
(relative-size "larger" "smaller")
|
||||
(shape "rect(,,,)")
|
||||
(uri "url()"))
|
||||
"A list of CSS property value classes and their contents.")
|
||||
;; missing, because not completable
|
||||
;; <angle><frequency><identifier><integer><length><number><padding-width>
|
||||
;; <percentage><specific-voice><string><time><uri>
|
||||
|
||||
(defconst company-css-html-tags
|
||||
'("a" "abbr" "acronym" "address" "applet" "area" "b" "base" "basefont" "bdo"
|
||||
"big" "blockquote" "body" "br" "button" "caption" "center" "cite" "code"
|
||||
"col" "colgroup" "dd" "del" "dfn" "dir" "div" "dl" "dt" "em" "fieldset"
|
||||
"font" "form" "frame" "frameset" "h1" "h2" "h3" "h4" "h5" "h6" "head" "hr"
|
||||
"html" "i" "iframe" "img" "input" "ins" "isindex" "kbd" "label" "legend"
|
||||
"li" "link" "map" "menu" "meta" "noframes" "noscript" "object" "ol"
|
||||
"optgroup" "option" "p" "param" "pre" "q" "s" "samp" "script" "select"
|
||||
"small" "span" "strike" "strong" "style" "sub" "sup" "table" "tbody" "td"
|
||||
"textarea" "tfoot" "th" "thead" "title" "tr" "tt" "u" "ul" "var"
|
||||
;; HTML5
|
||||
"section" "article" "aside" "header" "footer" "nav" "figure" "figcaption"
|
||||
"time" "mark" "main")
|
||||
"A list of HTML tags for use in CSS completion.")
|
||||
|
||||
(defconst company-css-pseudo-classes
|
||||
'("active" "after" "before" "first" "first-child" "first-letter" "first-line"
|
||||
"focus" "hover" "lang" "left" "link" "right" "visited")
|
||||
"Identifiers for CSS pseudo-elements and pseudo-classes.")
|
||||
|
||||
(defconst company-css-property-cache (make-hash-table :size 115 :test 'equal))
|
||||
|
||||
(defun company-css-property-values (attribute)
|
||||
"Access the `company-css-property-alist' cached and flattened."
|
||||
(or (gethash attribute company-css-property-cache)
|
||||
(let (results)
|
||||
(dolist (value (cdr (assoc attribute company-css-property-alist)))
|
||||
(if (symbolp value)
|
||||
(dolist (child (or (cdr (assoc value company-css-value-classes))
|
||||
(company-css-property-values
|
||||
(symbol-name value))))
|
||||
(push child results))
|
||||
(push value results)))
|
||||
(setq results (sort results 'string<))
|
||||
(puthash attribute
|
||||
(if (fboundp 'delete-consecutive-dups)
|
||||
(delete-consecutive-dups results)
|
||||
(delete-dups results))
|
||||
company-css-property-cache)
|
||||
results)))
|
||||
|
||||
;;; bracket detection
|
||||
|
||||
(defconst company-css-braces-syntax-table
|
||||
(let ((table (make-syntax-table)))
|
||||
(setf (aref table ?{) '(4 . 125))
|
||||
(setf (aref table ?}) '(5 . 123))
|
||||
table)
|
||||
"A syntax table giving { and } paren syntax.")
|
||||
|
||||
(defun company-css-inside-braces-p ()
|
||||
"Return non-nil, if point is within matched { and }."
|
||||
(ignore-errors
|
||||
(with-syntax-table company-css-braces-syntax-table
|
||||
(let ((parse-sexp-ignore-comments t))
|
||||
(scan-lists (point) -1 1)))))
|
||||
|
||||
;;; tags
|
||||
(defconst company-css-tag-regexp
|
||||
(concat "\\(?:\\`\\|}\\)[[:space:]]*"
|
||||
;; multiple
|
||||
"\\(?:"
|
||||
;; previous tags:
|
||||
"\\(?:#\\|\\_<[[:alpha:]]\\)[[:alnum:]-#]*\\(?:\\[[^]]*\\]\\)?"
|
||||
;; space or selectors
|
||||
"\\(?:[[:space:]]+\\|[[:space:]]*[+,>][[:space:]]*\\)"
|
||||
"\\)*"
|
||||
"\\(\\(?:#\\|\\_<[[:alpha:]]\\)\\(?:[[:alnum:]-#]*\\_>\\)?\\_>\\|\\)"
|
||||
"\\=")
|
||||
"A regular expression matching CSS tags.")
|
||||
|
||||
;;; pseudo id
|
||||
(defconst company-css-pseudo-regexp
|
||||
(concat "\\(?:\\`\\|}\\)[[:space:]]*"
|
||||
;; multiple
|
||||
"\\(?:"
|
||||
;; previous tags:
|
||||
"\\(?:#\\|\\_<[[:alpha:]]\\)[[:alnum:]-#]*\\(?:\\[[^]]*\\]\\)?"
|
||||
;; space or delimiters
|
||||
"\\(?:[[:space:]]+\\|[[:space:]]*[+,>][[:space:]]*\\)"
|
||||
"\\)*"
|
||||
"\\(?:\\(?:\\#\\|\\_<[[:alpha:]]\\)[[:alnum:]-#]*\\):"
|
||||
"\\([[:alpha:]-]+\\_>\\|\\)\\_>\\=")
|
||||
"A regular expression matching CSS pseudo classes.")
|
||||
|
||||
;;; properties
|
||||
|
||||
(defun company-css-grab-property ()
|
||||
"Return the CSS property before point, if any.
|
||||
Returns \"\" if no property found, but feasible at this position."
|
||||
(when (company-css-inside-braces-p)
|
||||
(company-grab-symbol)))
|
||||
|
||||
;;; values
|
||||
(defconst company-css-property-value-regexp
|
||||
"\\_<\\([[:alpha:]-]+\\):\\(?:[^{};]*[[:space:]]+\\)?\\([^{};]*\\_>\\|\\)\\="
|
||||
"A regular expression matching CSS tags.")
|
||||
|
||||
;;;###autoload
|
||||
(defun company-css (command &optional arg &rest ignored)
|
||||
"`company-mode' completion backend for `css-mode'."
|
||||
(interactive (list 'interactive))
|
||||
(cl-case command
|
||||
(interactive (company-begin-backend 'company-css))
|
||||
(prefix (and (or (derived-mode-p 'css-mode)
|
||||
(and (derived-mode-p 'web-mode)
|
||||
(string= (web-mode-language-at-pos) "css")))
|
||||
(or (company-grab company-css-tag-regexp 1)
|
||||
(company-grab company-css-pseudo-regexp 1)
|
||||
(company-grab company-css-property-value-regexp 2
|
||||
(line-beginning-position))
|
||||
(company-css-grab-property))))
|
||||
(candidates
|
||||
(cond
|
||||
((company-grab company-css-tag-regexp 1)
|
||||
(all-completions arg company-css-html-tags))
|
||||
((company-grab company-css-pseudo-regexp 1)
|
||||
(all-completions arg company-css-pseudo-classes))
|
||||
((company-grab company-css-property-value-regexp 2
|
||||
(line-beginning-position))
|
||||
(all-completions arg
|
||||
(company-css-property-values
|
||||
(company-grab company-css-property-value-regexp 1))))
|
||||
((company-css-grab-property)
|
||||
(all-completions arg company-css-property-alist))))
|
||||
(sorted t)))
|
||||
|
||||
(provide 'company-css)
|
||||
;;; company-css.el ends here
|
Binary file not shown.
|
@ -1,104 +0,0 @@
|
|||
;;; company-dabbrev-code.el --- dabbrev-like company-mode backend for code -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2009, 2011, 2014 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
;;; Commentary:
|
||||
;;
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'company)
|
||||
(require 'company-dabbrev)
|
||||
(require 'cl-lib)
|
||||
|
||||
(defgroup company-dabbrev-code nil
|
||||
"dabbrev-like completion backend for code."
|
||||
:group 'company)
|
||||
|
||||
(defcustom company-dabbrev-code-modes
|
||||
'(prog-mode
|
||||
batch-file-mode csharp-mode css-mode erlang-mode haskell-mode jde-mode
|
||||
lua-mode python-mode)
|
||||
"Modes that use `company-dabbrev-code'.
|
||||
In all these modes (and their derivatives) `company-dabbrev-code' will
|
||||
complete only symbols, not text in comments or strings. In other modes
|
||||
`company-dabbrev-code' will pass control to other backends
|
||||
\(e.g. `company-dabbrev'\). Value t means complete in all modes."
|
||||
:type '(choice (repeat :tag "Some modes" (symbol :tag "Major mode"))
|
||||
(const :tag "All modes" t)))
|
||||
|
||||
(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'."
|
||||
:type '(choice (const :tag "Off" nil)
|
||||
(const :tag "Same major mode" t)
|
||||
(const :tag "Code major modes" code)
|
||||
(const :tag "All" all)))
|
||||
|
||||
(defcustom company-dabbrev-code-time-limit .1
|
||||
"Determines how long `company-dabbrev-code' should look for matches."
|
||||
:type '(choice (const :tag "Off" nil)
|
||||
(number :tag "Seconds")))
|
||||
|
||||
(defcustom company-dabbrev-code-everywhere nil
|
||||
"Non-nil to offer completions in comments and strings."
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom company-dabbrev-code-ignore-case nil
|
||||
"Non-nil to ignore case when collecting completion candidates."
|
||||
:type 'boolean)
|
||||
|
||||
(defun company-dabbrev-code--make-regexp (prefix)
|
||||
(concat "\\_<" (if (equal prefix "")
|
||||
"\\([a-zA-Z]\\|\\s_\\)"
|
||||
(regexp-quote prefix))
|
||||
"\\(\\sw\\|\\s_\\)*\\_>"))
|
||||
|
||||
;;;###autoload
|
||||
(defun company-dabbrev-code (command &optional arg &rest ignored)
|
||||
"dabbrev-like `company-mode' backend for code.
|
||||
The backend looks for all symbols in the current buffer that aren't in
|
||||
comments or strings."
|
||||
(interactive (list 'interactive))
|
||||
(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))
|
||||
(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))
|
||||
(company-dabbrev--search
|
||||
(company-dabbrev-code--make-regexp arg)
|
||||
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))))
|
||||
(ignore-case company-dabbrev-code-ignore-case)
|
||||
(duplicates t)))
|
||||
|
||||
(provide 'company-dabbrev-code)
|
||||
;;; company-dabbrev-code.el ends here
|
Binary file not shown.
|
@ -1,206 +0,0 @@
|
|||
;;; company-dabbrev.el --- dabbrev-like company-mode completion backend -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2009, 2011, 2014, 2015, 2016 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
;;; Commentary:
|
||||
;;
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'company)
|
||||
(require 'cl-lib)
|
||||
|
||||
(defgroup company-dabbrev nil
|
||||
"dabbrev-like completion backend."
|
||||
:group 'company)
|
||||
|
||||
(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'."
|
||||
:type '(choice (const :tag "Off" nil)
|
||||
(const :tag "Same major mode" t)
|
||||
(const :tag "All" all)))
|
||||
|
||||
(defcustom company-dabbrev-ignore-buffers "\\`[ *]"
|
||||
"Regexp matching the names of buffers to ignore.
|
||||
Or a function that returns non-nil for such buffers."
|
||||
:type '(choice (regexp :tag "Regexp")
|
||||
(function :tag "Predicate"))
|
||||
:package-version '(company . "0.9.0"))
|
||||
|
||||
(defcustom company-dabbrev-time-limit .1
|
||||
"Determines how many seconds `company-dabbrev' should look for matches."
|
||||
:type '(choice (const :tag "Off" nil)
|
||||
(number :tag "Seconds")))
|
||||
|
||||
(defcustom company-dabbrev-char-regexp "\\sw"
|
||||
"A regular expression matching the characters `company-dabbrev' looks for."
|
||||
:type 'regexp)
|
||||
|
||||
(defcustom company-dabbrev-ignore-case 'keep-prefix
|
||||
"Non-nil to ignore case when collecting completion candidates.
|
||||
When it's `keep-prefix', the text before point will remain unchanged after
|
||||
candidate is inserted, even some of its characters have different case."
|
||||
:type '(choice
|
||||
(const :tag "Don't ignore case" nil)
|
||||
(const :tag "Ignore case" t)
|
||||
(const :tag "Keep case before point" keep-prefix)))
|
||||
|
||||
(defcustom company-dabbrev-downcase 'case-replace
|
||||
"Whether to downcase the returned candidates.
|
||||
|
||||
The value of nil means keep them as-is.
|
||||
`case-replace' means use the value of `case-replace'.
|
||||
Any other value means downcase.
|
||||
|
||||
If you set this value to nil, you may also want to set
|
||||
`company-dabbrev-ignore-case' to any value other than `keep-prefix'."
|
||||
:type '(choice
|
||||
(const :tag "Keep as-is" nil)
|
||||
(const :tag "Downcase" t)
|
||||
(const :tag "Use case-replace" case-replace)))
|
||||
|
||||
(defcustom company-dabbrev-minimum-length 4
|
||||
"The minimum length for the completion candidate to be included.
|
||||
This variable affects both `company-dabbrev' and `company-dabbrev-code'."
|
||||
:type 'integer
|
||||
:package-version '(company . "0.8.3"))
|
||||
|
||||
(defcustom company-dabbrev-ignore-invisible nil
|
||||
"Non-nil to skip invisible text."
|
||||
:type 'boolean
|
||||
:package-version '(company . "0.9.0"))
|
||||
|
||||
(defmacro company-dabbrev--time-limit-while (test start limit freq &rest body)
|
||||
(declare (indent 3) (debug t))
|
||||
`(let ((company-time-limit-while-counter 0))
|
||||
(catch 'done
|
||||
(while ,test
|
||||
,@body
|
||||
(and ,limit
|
||||
(= (cl-incf company-time-limit-while-counter) ,freq)
|
||||
(setq company-time-limit-while-counter 0)
|
||||
(> (float-time (time-since ,start)) ,limit)
|
||||
(throw 'done 'company-time-out))))))
|
||||
|
||||
(defun company-dabbrev--make-regexp ()
|
||||
(concat "\\(?:" company-dabbrev-char-regexp "\\)+"))
|
||||
|
||||
(defun company-dabbrev--search-buffer (regexp pos symbols start limit
|
||||
ignore-comments)
|
||||
(save-excursion
|
||||
(cl-labels ((maybe-collect-match
|
||||
()
|
||||
(let ((match (match-string-no-properties 0)))
|
||||
(when (and (>= (length match) company-dabbrev-minimum-length)
|
||||
(not (and company-dabbrev-ignore-invisible
|
||||
(invisible-p (match-beginning 0)))))
|
||||
(push match symbols)))))
|
||||
(goto-char (if pos (1- pos) (point-min)))
|
||||
;; Search before pos.
|
||||
(let ((tmp-end (point)))
|
||||
(company-dabbrev--time-limit-while (and (not (input-pending-p))
|
||||
(> tmp-end (point-min)))
|
||||
start limit 1
|
||||
(ignore-errors
|
||||
(forward-char -10000))
|
||||
(forward-line 0)
|
||||
(save-excursion
|
||||
;; Before, we used backward search, but it matches non-greedily, and
|
||||
;; that forced us to use the "beginning/end of word" anchors in
|
||||
;; `company-dabbrev--make-regexp'. It's also about 2x slower.
|
||||
(while (and (not (input-pending-p))
|
||||
(re-search-forward regexp tmp-end t))
|
||||
(if (and ignore-comments (save-match-data (company-in-string-or-comment)))
|
||||
(re-search-forward "\\s>\\|\\s!\\|\\s\"" tmp-end t)
|
||||
(maybe-collect-match))))
|
||||
(setq tmp-end (point))))
|
||||
(goto-char (or pos (point-min)))
|
||||
;; Search after pos.
|
||||
(company-dabbrev--time-limit-while (and (not (input-pending-p))
|
||||
(re-search-forward regexp nil t))
|
||||
start limit 25
|
||||
(if (and ignore-comments (save-match-data (company-in-string-or-comment)))
|
||||
(re-search-forward "\\s>\\|\\s!\\|\\s\"" nil t)
|
||||
(maybe-collect-match)))
|
||||
symbols)))
|
||||
|
||||
(defun company-dabbrev--search (regexp &optional limit other-buffer-modes
|
||||
ignore-comments)
|
||||
(let* ((start (current-time))
|
||||
(symbols (company-dabbrev--search-buffer regexp (point) nil start limit
|
||||
ignore-comments)))
|
||||
(when other-buffer-modes
|
||||
(cl-dolist (buffer (delq (current-buffer) (buffer-list)))
|
||||
(unless (if (stringp company-dabbrev-ignore-buffers)
|
||||
(string-match-p company-dabbrev-ignore-buffers
|
||||
(buffer-name buffer))
|
||||
(funcall company-dabbrev-ignore-buffers buffer))
|
||||
(with-current-buffer buffer
|
||||
(when (or (eq other-buffer-modes 'all)
|
||||
(apply #'derived-mode-p other-buffer-modes))
|
||||
(setq symbols
|
||||
(company-dabbrev--search-buffer regexp nil symbols start
|
||||
limit ignore-comments)))))
|
||||
(and limit
|
||||
(> (float-time (time-since start)) limit)
|
||||
(cl-return))))
|
||||
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)))
|
||||
|
||||
(defun company-dabbrev--filter (prefix candidates)
|
||||
(let ((completion-ignore-case company-dabbrev-ignore-case))
|
||||
(all-completions prefix candidates)))
|
||||
|
||||
;;;###autoload
|
||||
(defun company-dabbrev (command &optional arg &rest ignored)
|
||||
"dabbrev-like `company-mode' completion backend."
|
||||
(interactive (list 'interactive))
|
||||
(cl-case command
|
||||
(interactive (company-begin-backend 'company-dabbrev))
|
||||
(prefix (company-dabbrev--prefix))
|
||||
(candidates
|
||||
(let* ((case-fold-search company-dabbrev-ignore-case)
|
||||
(words (company-dabbrev--search (company-dabbrev--make-regexp)
|
||||
company-dabbrev-time-limit
|
||||
(pcase company-dabbrev-other-buffers
|
||||
(`t (list major-mode))
|
||||
(`all `all))))
|
||||
(downcase-p (if (eq company-dabbrev-downcase 'case-replace)
|
||||
case-replace
|
||||
company-dabbrev-downcase)))
|
||||
(setq words (company-dabbrev--filter arg words))
|
||||
(if downcase-p
|
||||
(mapcar 'downcase words)
|
||||
words)))
|
||||
(ignore-case company-dabbrev-ignore-case)
|
||||
(duplicates t)))
|
||||
|
||||
(provide 'company-dabbrev)
|
||||
;;; company-dabbrev.el ends here
|
Binary file not shown.
|
@ -1,186 +0,0 @@
|
|||
;;; company-eclim.el --- company-mode completion backend for Eclim
|
||||
|
||||
;; Copyright (C) 2009, 2011, 2013, 2015 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
;;
|
||||
;; Using `emacs-eclim' together with (or instead of) this backend is
|
||||
;; recommended, as it allows you to use other Eclim features.
|
||||
;;
|
||||
;; The alternative backend provided by `emacs-eclim' uses `yasnippet'
|
||||
;; instead of `company-template' to expand function calls, and it supports
|
||||
;; some languages other than Java.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'company)
|
||||
(require 'company-template)
|
||||
(require 'cl-lib)
|
||||
|
||||
(defgroup company-eclim nil
|
||||
"Completion backend for Eclim."
|
||||
:group 'company)
|
||||
|
||||
(defun company-eclim-executable-find ()
|
||||
(let (file)
|
||||
(cl-dolist (eclipse-root '("/Applications/eclipse" "/usr/lib/eclipse"
|
||||
"/usr/local/lib/eclipse"))
|
||||
(and (file-exists-p (setq file (expand-file-name "plugins" eclipse-root)))
|
||||
(setq file (car (last (directory-files file t "^org.eclim_"))))
|
||||
(file-exists-p (setq file (expand-file-name "bin/eclim" file)))
|
||||
(cl-return file)))))
|
||||
|
||||
(defcustom company-eclim-executable
|
||||
(or (bound-and-true-p eclim-executable)
|
||||
(executable-find "eclim")
|
||||
(company-eclim-executable-find))
|
||||
"Location of eclim executable."
|
||||
:type 'file)
|
||||
|
||||
(defcustom company-eclim-auto-save t
|
||||
"Determines whether to save the buffer when retrieving completions.
|
||||
eclim can only complete correctly when the buffer has been saved."
|
||||
:type '(choice (const :tag "Off" nil)
|
||||
(const :tag "On" t)))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defvar-local company-eclim--project-dir 'unknown)
|
||||
|
||||
(defvar-local company-eclim--project-name nil)
|
||||
|
||||
(declare-function json-read "json")
|
||||
(defvar json-array-type)
|
||||
|
||||
(defun company-eclim--call-process (&rest args)
|
||||
(let ((coding-system-for-read 'utf-8)
|
||||
res)
|
||||
(require 'json)
|
||||
(with-temp-buffer
|
||||
(if (= 0 (setq res (apply 'call-process company-eclim-executable nil t nil
|
||||
"-command" args)))
|
||||
(let ((json-array-type 'list))
|
||||
(goto-char (point-min))
|
||||
(unless (eobp)
|
||||
(json-read)))
|
||||
(message "Company-eclim command failed with error %d:\n%s" res
|
||||
(buffer-substring (point-min) (point-max)))
|
||||
nil))))
|
||||
|
||||
(defun company-eclim--project-list ()
|
||||
(company-eclim--call-process "project_list"))
|
||||
|
||||
(defun company-eclim--project-dir ()
|
||||
(if (eq company-eclim--project-dir 'unknown)
|
||||
(let ((dir (locate-dominating-file buffer-file-name ".project")))
|
||||
(when dir
|
||||
(setq company-eclim--project-dir
|
||||
(directory-file-name
|
||||
(expand-file-name dir)))))
|
||||
company-eclim--project-dir))
|
||||
|
||||
(defun company-eclim--project-name ()
|
||||
(or company-eclim--project-name
|
||||
(let ((dir (company-eclim--project-dir)))
|
||||
(when dir
|
||||
(setq company-eclim--project-name
|
||||
(cl-loop for project in (company-eclim--project-list)
|
||||
when (equal (cdr (assoc 'path project)) dir)
|
||||
return (cdr (assoc 'name project))))))))
|
||||
|
||||
(defun company-eclim--candidates (prefix)
|
||||
(interactive "d")
|
||||
(let ((project-file (file-relative-name buffer-file-name
|
||||
(company-eclim--project-dir)))
|
||||
completions)
|
||||
(when company-eclim-auto-save
|
||||
(when (buffer-modified-p)
|
||||
(basic-save-buffer))
|
||||
;; FIXME: Sometimes this isn't finished when we complete.
|
||||
(company-eclim--call-process "java_src_update"
|
||||
"-p" (company-eclim--project-name)
|
||||
"-f" project-file))
|
||||
(dolist (item (cdr (assoc 'completions
|
||||
(company-eclim--call-process
|
||||
"java_complete" "-p" (company-eclim--project-name)
|
||||
"-f" project-file
|
||||
"-o" (number-to-string
|
||||
(company-eclim--search-point prefix))
|
||||
"-e" "utf-8"
|
||||
"-l" "standard"))))
|
||||
(let* ((meta (cdr (assoc 'info item)))
|
||||
(completion meta))
|
||||
(when (string-match " ?[(:-]" completion)
|
||||
(setq completion (substring completion 0 (match-beginning 0))))
|
||||
(put-text-property 0 1 'meta meta completion)
|
||||
(push completion completions)))
|
||||
(let ((completion-ignore-case nil))
|
||||
(all-completions prefix completions))))
|
||||
|
||||
(defun company-eclim--search-point (prefix)
|
||||
(if (or (cl-plusp (length prefix)) (eq (char-before) ?.))
|
||||
(1- (point))
|
||||
(point)))
|
||||
|
||||
(defun company-eclim--meta (candidate)
|
||||
(get-text-property 0 'meta candidate))
|
||||
|
||||
(defun company-eclim--annotation (candidate)
|
||||
(let ((meta (company-eclim--meta candidate)))
|
||||
(when (string-match "\\(([^-]*\\) -" meta)
|
||||
(substring meta (match-beginning 1) (match-end 1)))))
|
||||
|
||||
(defun company-eclim--prefix ()
|
||||
(let ((prefix (company-grab-symbol)))
|
||||
(when prefix
|
||||
;; Completion candidates for annotations don't include '@'.
|
||||
(when (eq ?@ (string-to-char prefix))
|
||||
(setq prefix (substring prefix 1)))
|
||||
prefix)))
|
||||
|
||||
(defun company-eclim (command &optional arg &rest ignored)
|
||||
"`company-mode' completion backend for Eclim.
|
||||
Eclim provides access to Eclipse Java IDE features for other editors.
|
||||
|
||||
Eclim version 1.7.13 or newer (?) is required.
|
||||
|
||||
Completions only work correctly when the buffer has been saved.
|
||||
`company-eclim-auto-save' determines whether to do this automatically."
|
||||
(interactive (list 'interactive))
|
||||
(cl-case command
|
||||
(interactive (company-begin-backend 'company-eclim))
|
||||
(prefix (and (derived-mode-p 'java-mode 'jde-mode)
|
||||
buffer-file-name
|
||||
company-eclim-executable
|
||||
(company-eclim--project-name)
|
||||
(not (company-in-string-or-comment))
|
||||
(or (company-eclim--prefix) 'stop)))
|
||||
(candidates (company-eclim--candidates arg))
|
||||
(meta (company-eclim--meta arg))
|
||||
;; because "" doesn't return everything
|
||||
(no-cache (equal arg ""))
|
||||
(annotation (company-eclim--annotation arg))
|
||||
(post-completion (let ((anno (company-eclim--annotation arg)))
|
||||
(when anno
|
||||
(insert anno)
|
||||
(company-template-c-like-templatify anno))))))
|
||||
|
||||
(provide 'company-eclim)
|
||||
;;; company-eclim.el ends here
|
Binary file not shown.
|
@ -1,226 +0,0 @@
|
|||
;;; company-elisp.el --- company-mode completion backend for Emacs Lisp -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2009, 2011-2013, 2017 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 <http://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
|
Binary file not shown.
|
@ -1,108 +0,0 @@
|
|||
;;; company-etags.el --- company-mode completion backend for etags
|
||||
|
||||
;; Copyright (C) 2009-2011, 2014 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
;;; Commentary:
|
||||
;;
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'company)
|
||||
(require 'cl-lib)
|
||||
(require 'etags)
|
||||
|
||||
(defgroup company-etags nil
|
||||
"Completion backend for etags."
|
||||
:group 'company)
|
||||
|
||||
(defcustom company-etags-use-main-table-list t
|
||||
"Always search `tags-table-list' if set.
|
||||
If this is disabled, `company-etags' will try to find the one table for each
|
||||
buffer automatically."
|
||||
:type '(choice (const :tag "off" nil)
|
||||
(const :tag "on" t)))
|
||||
|
||||
(defcustom company-etags-ignore-case nil
|
||||
"Non-nil to ignore case in completion candidates."
|
||||
:type 'boolean
|
||||
:package-version '(company . "0.7.3"))
|
||||
|
||||
(defcustom company-etags-everywhere nil
|
||||
"Non-nil to offer completions in comments and strings.
|
||||
Set it to t or to a list of major modes."
|
||||
:type '(choice (const :tag "Off" nil)
|
||||
(const :tag "Any supported mode" t)
|
||||
(repeat :tag "Some major modes"
|
||||
(symbol :tag "Major mode")))
|
||||
:package-version '(company . "0.9.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)
|
||||
|
||||
(defun company-etags-find-table ()
|
||||
(let ((file (expand-file-name
|
||||
"TAGS"
|
||||
(locate-dominating-file (or buffer-file-name
|
||||
default-directory)
|
||||
"TAGS"))))
|
||||
(when (and file (file-regular-p file))
|
||||
(list file))))
|
||||
|
||||
(defun company-etags-buffer-table ()
|
||||
(or (and company-etags-use-main-table-list tags-table-list)
|
||||
(if (eq company-etags-buffer-table 'unknown)
|
||||
(setq company-etags-buffer-table (company-etags-find-table))
|
||||
company-etags-buffer-table)))
|
||||
|
||||
(defun company-etags--candidates (prefix)
|
||||
(let ((tags-table-list (company-etags-buffer-table))
|
||||
(tags-file-name tags-file-name)
|
||||
(completion-ignore-case company-etags-ignore-case))
|
||||
(and (or tags-file-name tags-table-list)
|
||||
(fboundp 'tags-completion-table)
|
||||
(save-excursion
|
||||
(visit-tags-table-buffer)
|
||||
(all-completions prefix (tags-completion-table))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun company-etags (command &optional arg &rest ignored)
|
||||
"`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)
|
||||
(or (eq t company-etags-everywhere)
|
||||
(apply #'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))
|
||||
(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))))))))
|
||||
(ignore-case company-etags-ignore-case)))
|
||||
|
||||
(provide 'company-etags)
|
||||
;;; company-etags.el ends here
|
Binary file not shown.
|
@ -1,148 +0,0 @@
|
|||
;;; company-files.el --- company-mode completion backend for file names
|
||||
|
||||
;; Copyright (C) 2009-2011, 2014-2015 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
;;; Commentary:
|
||||
;;
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'company)
|
||||
(require 'cl-lib)
|
||||
|
||||
(defgroup company-files nil
|
||||
"Completion backend for file names."
|
||||
:group 'company)
|
||||
|
||||
(defcustom company-files-exclusions nil
|
||||
"File name extensions and directory names to ignore.
|
||||
The values should use the same format as `completion-ignored-extensions'."
|
||||
:type '(const string)
|
||||
:package-version '(company . "0.9.1"))
|
||||
|
||||
(defun company-files--directory-files (dir prefix)
|
||||
;; Don't use directory-files. It produces directories without trailing /.
|
||||
(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 "")
|
||||
(delete "../" (delete "./" comp))
|
||||
comp))
|
||||
(file-error nil)))
|
||||
|
||||
(defun company-files--exclusions-filtered (completions)
|
||||
(let* ((dir-exclusions (cl-delete-if-not #'company-files--trailing-slash-p
|
||||
company-files-exclusions))
|
||||
(file-exclusions (cl-set-difference company-files-exclusions
|
||||
dir-exclusions)))
|
||||
(cl-loop for c in completions
|
||||
unless (if (company-files--trailing-slash-p c)
|
||||
(member c dir-exclusions)
|
||||
(cl-find-if (lambda (exclusion)
|
||||
(string-suffix-p exclusion c))
|
||||
file-exclusions))
|
||||
collect c)))
|
||||
|
||||
(defvar company-files--regexps
|
||||
(let* ((root (if (eq system-type 'windows-nt)
|
||||
"[a-zA-Z]:/"
|
||||
"/"))
|
||||
(begin (concat "\\(?:\\.\\{1,2\\}/\\|~/\\|" root "\\)")))
|
||||
(list (concat "\"\\(" begin "[^\"\n]*\\)")
|
||||
(concat "\'\\(" begin "[^\'\n]*\\)")
|
||||
(concat "\\(?:[ \t=\[]\\|^\\)\\(" begin "[^ \t\n]*\\)"))))
|
||||
|
||||
(defun company-files--grab-existing-name ()
|
||||
;; Grab the file name.
|
||||
;; When surrounded with quotes, it can include spaces.
|
||||
(let (file dir)
|
||||
(and (cl-dolist (regexp company-files--regexps)
|
||||
(when (setq file (company-grab-line regexp 1))
|
||||
(cl-return file)))
|
||||
(company-files--connected-p file)
|
||||
(setq dir (file-name-directory file))
|
||||
(not (string-match "//" dir))
|
||||
(file-exists-p dir)
|
||||
file)))
|
||||
|
||||
(defun company-files--connected-p (file)
|
||||
(or (not (file-remote-p file))
|
||||
(file-remote-p file nil t)))
|
||||
|
||||
(defun company-files--trailing-slash-p (file)
|
||||
;; `file-directory-p' is very expensive on remotes. We are relying on
|
||||
;; `file-name-all-completions' returning directories with trailing / instead.
|
||||
(let ((len (length file)))
|
||||
(and (> len 0) (eq (aref file (1- len)) ?/))))
|
||||
|
||||
(defvar company-files--completion-cache nil)
|
||||
|
||||
(defun company-files--complete (prefix)
|
||||
(let* ((dir (file-name-directory prefix))
|
||||
(file (file-name-nondirectory 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)))
|
||||
(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)))
|
||||
candidates)))
|
||||
(children (and directories
|
||||
(cl-mapcan (lambda (d)
|
||||
(mapcar (lambda (c) (concat d c))
|
||||
(company-files--directory-files d "")))
|
||||
directories))))
|
||||
(setq company-files--completion-cache
|
||||
(cons key (append candidates children)))))
|
||||
(all-completions prefix
|
||||
(cdr company-files--completion-cache))))
|
||||
|
||||
(defun company-file--keys-match-p (new old)
|
||||
(and (equal (cdr old) (cdr new))
|
||||
(string-prefix-p (car old) (car new))))
|
||||
|
||||
;;;###autoload
|
||||
(defun company-files (command &optional arg &rest ignored)
|
||||
"`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))
|
||||
(location (cons (dired-noselect
|
||||
(file-name-directory (directory-file-name arg))) 1))
|
||||
(post-completion (when (company-files--trailing-slash-p arg)
|
||||
(delete-char -1)))
|
||||
(sorted t)
|
||||
(no-cache t)))
|
||||
|
||||
(provide 'company-files)
|
||||
;;; company-files.el ends here
|
Binary file not shown.
|
@ -1,119 +0,0 @@
|
|||
;;; company-gtags.el --- company-mode completion backend for GNU Global
|
||||
|
||||
;; Copyright (C) 2009-2011, 2014-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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
;;; Commentary:
|
||||
;;
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'company)
|
||||
(require 'company-template)
|
||||
(require 'cl-lib)
|
||||
|
||||
(defgroup company-gtags nil
|
||||
"Completion backend for GNU Global."
|
||||
:group 'company)
|
||||
|
||||
(define-obsolete-variable-alias
|
||||
'company-gtags-gnu-global-program-name
|
||||
'company-gtags-executable "earlier")
|
||||
|
||||
(defcustom company-gtags-executable
|
||||
(executable-find "global")
|
||||
"Location of GNU global executable."
|
||||
:type 'string)
|
||||
|
||||
(defcustom company-gtags-insert-arguments t
|
||||
"When non-nil, insert function arguments as a template after completion."
|
||||
:type 'boolean
|
||||
:package-version '(company . "0.8.1"))
|
||||
|
||||
(defvar-local company-gtags--tags-available-p 'unknown)
|
||||
|
||||
(defcustom company-gtags-modes '(prog-mode jde-mode)
|
||||
"Modes that use `company-gtags'.
|
||||
In all these modes (and their derivatives) `company-gtags' will perform
|
||||
completion."
|
||||
:type '(repeat (symbol :tag "Major mode"))
|
||||
:package-version '(company . "0.8.4"))
|
||||
|
||||
(defun company-gtags--tags-available-p ()
|
||||
(if (eq company-gtags--tags-available-p 'unknown)
|
||||
(setq company-gtags--tags-available-p
|
||||
(locate-dominating-file buffer-file-name "GTAGS"))
|
||||
company-gtags--tags-available-p))
|
||||
|
||||
(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
|
||||
;; "-T" goes through all the tag files listed in GTAGSLIBPATH
|
||||
(list (current-buffer) nil) nil "-xGqT" (concat "^" prefix)))
|
||||
(goto-char (point-min))
|
||||
(cl-loop while
|
||||
(re-search-forward (concat
|
||||
"^"
|
||||
"\\([^ ]*\\)" ;; completion
|
||||
"[ \t]+\\([[:digit:]]+\\)" ;; linum
|
||||
"[ \t]+\\([^ \t]+\\)" ;; file
|
||||
"[ \t]+\\(.*\\)" ;; definition
|
||||
"$"
|
||||
) nil t)
|
||||
collect
|
||||
(propertize (match-string 1)
|
||||
'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)))
|
||||
(when (string-match (concat (regexp-quote arg) "\\((.*)\\).*") meta)
|
||||
(match-string 1 meta))))
|
||||
|
||||
;;;###autoload
|
||||
(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)
|
||||
(not (company-in-string-or-comment))
|
||||
(company-gtags--tags-available-p)
|
||||
(or (company-grab-symbol) 'stop)))
|
||||
(candidates (company-gtags--fetch-tags arg))
|
||||
(sorted t)
|
||||
(duplicates t)
|
||||
(annotation (company-gtags--annotation arg))
|
||||
(meta (get-text-property 0 'meta arg))
|
||||
(location (get-text-property 0 'location arg))
|
||||
(post-completion (let ((anno (company-gtags--annotation arg)))
|
||||
(when (and company-gtags-insert-arguments anno)
|
||||
(insert anno)
|
||||
(company-template-c-like-templatify anno))))))
|
||||
|
||||
(provide 'company-gtags)
|
||||
;;; company-gtags.el ends here
|
Binary file not shown.
|
@ -1,82 +0,0 @@
|
|||
;;; company-ispell.el --- company-mode completion backend using Ispell
|
||||
|
||||
;; Copyright (C) 2009-2011, 2013-2016 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
;;; Commentary:
|
||||
;;
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'company)
|
||||
(require 'cl-lib)
|
||||
(require 'ispell)
|
||||
|
||||
(defgroup company-ispell nil
|
||||
"Completion backend using Ispell."
|
||||
:group 'company)
|
||||
|
||||
(defcustom company-ispell-dictionary nil
|
||||
"Dictionary to use for `company-ispell'.
|
||||
If nil, use `ispell-complete-word-dict'."
|
||||
:type '(choice (const :tag "default (nil)" nil)
|
||||
(file :tag "dictionary" t)))
|
||||
|
||||
(defvar company-ispell-available 'unknown)
|
||||
|
||||
(defalias 'company-ispell--lookup-words
|
||||
(if (fboundp 'ispell-lookup-words)
|
||||
'ispell-lookup-words
|
||||
'lookup-words))
|
||||
|
||||
(defun company-ispell-available ()
|
||||
(when (eq company-ispell-available 'unknown)
|
||||
(condition-case err
|
||||
(progn
|
||||
(company-ispell--lookup-words "WHATEVER")
|
||||
(setq company-ispell-available t))
|
||||
(error
|
||||
(message "Company-Ispell: %s" (error-message-string err))
|
||||
(setq company-ispell-available nil))))
|
||||
company-ispell-available)
|
||||
|
||||
;;;###autoload
|
||||
(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)))
|
||||
(candidates
|
||||
(let ((words (company-ispell--lookup-words
|
||||
arg
|
||||
(or company-ispell-dictionary ispell-complete-word-dict)))
|
||||
(completion-ignore-case t))
|
||||
(if (string= arg "")
|
||||
;; Small optimization.
|
||||
words
|
||||
;; Work around issue #284.
|
||||
(all-completions arg words))))
|
||||
(sorted t)
|
||||
(ignore-case 'keep-prefix)))
|
||||
|
||||
(provide 'company-ispell)
|
||||
;;; company-ispell.el ends here
|
Binary file not shown.
|
@ -1,314 +0,0 @@
|
|||
;;; company-keywords.el --- A company backend for programming language keywords
|
||||
|
||||
;; Copyright (C) 2009-2011, 2016 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
;;; Commentary:
|
||||
;;
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'company)
|
||||
(require 'cl-lib)
|
||||
|
||||
(defun company-keywords-upper-lower (&rest lst)
|
||||
;; Upcase order is different for _.
|
||||
(nconc (sort (mapcar 'upcase lst) 'string<) lst))
|
||||
|
||||
(defvar company-keywords-alist
|
||||
;; Please contribute corrections or additions.
|
||||
`((c++-mode
|
||||
;; from https://en.cppreference.com/w/cpp/keyword
|
||||
"alignas" "alignof" "and" "and_eq" "asm" "atomic_cancel" "atomic_commit"
|
||||
"atomic_noexcept" "auto" "bitand" "bitor" "bool" "break" "case" "catch"
|
||||
"char" "char16_t" "char32_t" "char8_t" "class" "co_await" "co_return"
|
||||
"co_yield" "compl" "concept" "const" "const_cast" "consteval" "constexpr"
|
||||
"constinit" "continue" "decltype" "default" "delete" "do" "double"
|
||||
"dynamic_cast" "else" "enum" "explicit" "export" "extern" "false" "final"
|
||||
"float" "for" "friend" "goto" "if" "import" "inline" "int" "long" "module"
|
||||
"mutable" "namespace" "new" "noexcept" "not" "not_eq" "nullptr" "operator"
|
||||
"or" "or_eq" "override" "private" "protected" "public" "reflexpr" "register"
|
||||
"reinterpret_cast" "requires" "return" "short" "signed" "sizeof" "static"
|
||||
"static_assert" "static_cast" "struct" "switch" "synchronized" "template"
|
||||
"this" "thread_local" "throw" "true" "try" "typedef" "typeid" "typename"
|
||||
"union" "unsigned" "using" "virtual" "void" "volatile" "wchar_t" "while"
|
||||
"xor" "xor_eq")
|
||||
(c-mode
|
||||
;; from https://en.cppreference.com/w/c/keyword
|
||||
"_Alignas" "_Alignof" "_Atomic" "_Bool" "_Complex" "_Generic" "_Imaginary"
|
||||
"_Noreturn" "_Static_assert" "_Thread_local"
|
||||
"auto" "break" "case" "char" "const" "continue" "default" "do"
|
||||
"double" "else" "enum" "extern" "float" "for" "goto" "if" "inline"
|
||||
"int" "long" "register" "restrict" "return" "short" "signed" "sizeof"
|
||||
"static" "struct" "switch" "typedef" "union" "unsigned" "void" "volatile"
|
||||
"while")
|
||||
(csharp-mode
|
||||
"abstract" "add" "alias" "as" "base" "bool" "break" "byte" "case"
|
||||
"catch" "char" "checked" "class" "const" "continue" "decimal" "default"
|
||||
"delegate" "do" "double" "else" "enum" "event" "explicit" "extern"
|
||||
"false" "finally" "fixed" "float" "for" "foreach" "get" "global" "goto"
|
||||
"if" "implicit" "in" "int" "interface" "internal" "is" "lock" "long"
|
||||
"namespace" "new" "null" "object" "operator" "out" "override" "params"
|
||||
"partial" "private" "protected" "public" "readonly" "ref" "remove"
|
||||
"return" "sbyte" "sealed" "set" "short" "sizeof" "stackalloc" "static"
|
||||
"string" "struct" "switch" "this" "throw" "true" "try" "typeof" "uint"
|
||||
"ulong" "unchecked" "unsafe" "ushort" "using" "value" "var" "virtual"
|
||||
"void" "volatile" "where" "while" "yield")
|
||||
(d-mode
|
||||
;; from http://www.digitalmars.com/d/2.0/lex.html
|
||||
"abstract" "alias" "align" "asm"
|
||||
"assert" "auto" "body" "bool" "break" "byte" "case" "cast" "catch"
|
||||
"cdouble" "cent" "cfloat" "char" "class" "const" "continue" "creal"
|
||||
"dchar" "debug" "default" "delegate" "delete" "deprecated" "do"
|
||||
"double" "else" "enum" "export" "extern" "false" "final" "finally"
|
||||
"float" "for" "foreach" "foreach_reverse" "function" "goto" "idouble"
|
||||
"if" "ifloat" "import" "in" "inout" "int" "interface" "invariant"
|
||||
"ireal" "is" "lazy" "long" "macro" "mixin" "module" "new" "nothrow"
|
||||
"null" "out" "override" "package" "pragma" "private" "protected"
|
||||
"public" "pure" "real" "ref" "return" "scope" "short" "static" "struct"
|
||||
"super" "switch" "synchronized" "template" "this" "throw" "true" "try"
|
||||
"typedef" "typeid" "typeof" "ubyte" "ucent" "uint" "ulong" "union"
|
||||
"unittest" "ushort" "version" "void" "volatile" "wchar" "while" "with")
|
||||
(f90-mode .
|
||||
;; from f90.el
|
||||
;; ".AND." ".GE." ".GT." ".LT." ".LE." ".NE." ".OR." ".TRUE." ".FALSE."
|
||||
,(company-keywords-upper-lower
|
||||
"abs" "abstract" "achar" "acos" "adjustl" "adjustr" "aimag" "aint"
|
||||
"align" "all" "all_prefix" "all_scatter" "all_suffix" "allocatable"
|
||||
"allocate" "allocated" "and" "anint" "any" "any_prefix" "any_scatter"
|
||||
"any_suffix" "asin" "assign" "assignment" "associate" "associated"
|
||||
"asynchronous" "atan" "atan2" "backspace" "bind" "bit_size" "block"
|
||||
"btest" "c_alert" "c_associated" "c_backspace" "c_bool"
|
||||
"c_carriage_return" "c_char" "c_double" "c_double_complex" "c_f_pointer"
|
||||
"c_f_procpointer" "c_float" "c_float_complex" "c_form_feed" "c_funloc"
|
||||
"c_funptr" "c_horizontal_tab" "c_int" "c_int16_t" "c_int32_t" "c_int64_t"
|
||||
"c_int8_t" "c_int_fast16_t" "c_int_fast32_t" "c_int_fast64_t"
|
||||
"c_int_fast8_t" "c_int_least16_t" "c_int_least32_t" "c_int_least64_t"
|
||||
"c_int_least8_t" "c_intmax_t" "c_intptr_t" "c_loc" "c_long"
|
||||
"c_long_double" "c_long_double_complex" "c_long_long" "c_new_line"
|
||||
"c_null_char" "c_null_funptr" "c_null_ptr" "c_ptr" "c_short"
|
||||
"c_signed_char" "c_size_t" "c_vertical_tab" "call" "case" "ceiling"
|
||||
"char" "character" "character_storage_size" "class" "close" "cmplx"
|
||||
"command_argument_count" "common" "complex" "conjg" "contains" "continue"
|
||||
"copy_prefix" "copy_scatter" "copy_suffix" "cos" "cosh" "count"
|
||||
"count_prefix" "count_scatter" "count_suffix" "cpu_time" "cshift"
|
||||
"cycle" "cyclic" "data" "date_and_time" "dble" "deallocate" "deferred"
|
||||
"digits" "dim" "dimension" "distribute" "do" "dot_product" "double"
|
||||
"dprod" "dynamic" "elemental" "else" "elseif" "elsewhere" "end" "enddo"
|
||||
"endfile" "endif" "entry" "enum" "enumerator" "eoshift" "epsilon" "eq"
|
||||
"equivalence" "eqv" "error_unit" "exit" "exp" "exponent" "extends"
|
||||
"extends_type_of" "external" "extrinsic" "false" "file_storage_size"
|
||||
"final" "floor" "flush" "forall" "format" "fraction" "function" "ge"
|
||||
"generic" "get_command" "get_command_argument" "get_environment_variable"
|
||||
"goto" "grade_down" "grade_up" "gt" "hpf_alignment" "hpf_distribution"
|
||||
"hpf_template" "huge" "iachar" "iall" "iall_prefix" "iall_scatter"
|
||||
"iall_suffix" "iand" "iany" "iany_prefix" "iany_scatter" "iany_suffix"
|
||||
"ibclr" "ibits" "ibset" "ichar" "ieee_arithmetic" "ieee_exceptions"
|
||||
"ieee_features" "ieee_get_underflow_mode" "ieee_set_underflow_mode"
|
||||
"ieee_support_underflow_control" "ieor" "if" "ilen" "implicit"
|
||||
"import" "include" "independent" "index" "inherit" "input_unit"
|
||||
"inquire" "int" "integer" "intent" "interface" "intrinsic" "ior"
|
||||
"iostat_end" "iostat_eor" "iparity" "iparity_prefix" "iparity_scatter"
|
||||
"iparity_suffix" "ishft" "ishftc" "iso_c_binding" "iso_fortran_env"
|
||||
"kind" "lbound" "le" "leadz" "len" "len_trim" "lge" "lgt" "lle" "llt"
|
||||
"log" "log10" "logical" "lt" "matmul" "max" "maxexponent" "maxloc"
|
||||
"maxval" "maxval_prefix" "maxval_scatter" "maxval_suffix" "merge"
|
||||
"min" "minexponent" "minloc" "minval" "minval_prefix" "minval_scatter"
|
||||
"minval_suffix" "mod" "module" "modulo" "move_alloc" "mvbits" "namelist"
|
||||
"ne" "nearest" "neqv" "new" "new_line" "nint" "non_intrinsic"
|
||||
"non_overridable" "none" "nopass" "not" "null" "nullify"
|
||||
"number_of_processors" "numeric_storage_size" "only" "onto" "open"
|
||||
"operator" "optional" "or" "output_unit" "pack" "parameter" "parity"
|
||||
"parity_prefix" "parity_scatter" "parity_suffix" "pass" "pause"
|
||||
"pointer" "popcnt" "poppar" "precision" "present" "print" "private"
|
||||
"procedure" "processors" "processors_shape" "product" "product_prefix"
|
||||
"product_scatter" "product_suffix" "program" "protected" "public"
|
||||
"pure" "radix" "random_number" "random_seed" "range" "read" "real"
|
||||
"realign" "recursive" "redistribute" "repeat" "reshape" "result"
|
||||
"return" "rewind" "rrspacing" "same_type_as" "save" "scale" "scan"
|
||||
"select" "selected_char_kind" "selected_int_kind" "selected_real_kind"
|
||||
"sequence" "set_exponent" "shape" "sign" "sin" "sinh" "size" "spacing"
|
||||
"spread" "sqrt" "stop" "subroutine" "sum" "sum_prefix" "sum_scatter"
|
||||
"sum_suffix" "system_clock" "tan" "tanh" "target" "template" "then"
|
||||
"tiny" "transfer" "transpose" "trim" "true" "type" "ubound" "unpack"
|
||||
"use" "value" "verify" "volatile" "wait" "where" "while" "with" "write"))
|
||||
(go-mode
|
||||
;; 1. Keywords ref: https://golang.org/ref/spec#Keywords
|
||||
;; 2. Builtin functions and types ref: https://golang.org/pkg/builtin/
|
||||
"append" "bool" "break" "byte" "cap" "case" "chan" "close" "complex" "complex128"
|
||||
"complex64" "const" "continue" "copy" "default" "defer" "delete" "else" "error"
|
||||
"fallthrough" "false" "float32" "float64" "for" "func" "go" "goto" "if" "imag"
|
||||
"import" "int" "int16" "int32" "int64" "int8" "interface" "len" "make"
|
||||
"map" "new" "nil" "package" "panic" "print" "println" "range" "real" "recover"
|
||||
"return" "rune" "select" "string" "struct" "switch" "true" "type" "uint" "uint16"
|
||||
"uint32" "uint64" "uint8" "uintptr" "var")
|
||||
(java-mode
|
||||
"abstract" "assert" "boolean" "break" "byte" "case" "catch" "char" "class"
|
||||
"continue" "default" "do" "double" "else" "enum" "extends" "final"
|
||||
"finally" "float" "for" "if" "implements" "import" "instanceof" "int"
|
||||
"interface" "long" "native" "new" "package" "private" "protected" "public"
|
||||
"return" "short" "static" "strictfp" "super" "switch" "synchronized"
|
||||
"this" "throw" "throws" "transient" "try" "void" "volatile" "while")
|
||||
(javascript-mode
|
||||
;; https://tc39.github.io/ecma262/ + async, static and undefined
|
||||
"async" "await" "break" "case" "catch" "class" "const" "continue"
|
||||
"debugger" "default" "delete" "do" "else" "enum" "export" "extends" "false"
|
||||
"finally" "for" "function" "if" "import" "in" "instanceof" "let" "new"
|
||||
"null" "return" "static" "super" "switch" "this" "throw" "true" "try"
|
||||
"typeof" "undefined" "var" "void" "while" "with" "yield")
|
||||
(kotlin-mode
|
||||
"abstract" "annotation" "as" "break" "by" "catch" "class" "companion"
|
||||
"const" "constructor" "continue" "data" "do" "else" "enum" "false" "final"
|
||||
"finally" "for" "fun" "if" "import" "in" "init" "inner" "interface"
|
||||
"internal" "is" "lateinit" "nested" "null" "object" "open" "out" "override"
|
||||
"package" "private" "protected" "public" "return" "super" "this" "throw"
|
||||
"trait" "true" "try" "typealias" "val" "var" "when" "while")
|
||||
(objc-mode
|
||||
"@catch" "@class" "@encode" "@end" "@finally" "@implementation"
|
||||
"@interface" "@private" "@protected" "@protocol" "@public"
|
||||
"@selector" "@synchronized" "@throw" "@try" "alloc" "autorelease"
|
||||
"bycopy" "byref" "in" "inout" "oneway" "out" "release" "retain")
|
||||
(perl-mode
|
||||
;; from cperl.el
|
||||
"AUTOLOAD" "BEGIN" "CHECK" "CORE" "DESTROY" "END" "INIT" "__END__"
|
||||
"__FILE__" "__LINE__" "abs" "accept" "alarm" "and" "atan2" "bind"
|
||||
"binmode" "bless" "caller" "chdir" "chmod" "chomp" "chop" "chown" "chr"
|
||||
"chroot" "close" "closedir" "cmp" "connect" "continue" "cos"
|
||||
"crypt" "dbmclose" "dbmopen" "defined" "delete" "die" "do" "dump" "each"
|
||||
"else" "elsif" "endgrent" "endhostent" "endnetent" "endprotoent"
|
||||
"endpwent" "endservent" "eof" "eq" "eval" "exec" "exists" "exit" "exp"
|
||||
"fcntl" "fileno" "flock" "for" "foreach" "fork" "format" "formline"
|
||||
"ge" "getc" "getgrent" "getgrgid" "getgrnam" "gethostbyaddr"
|
||||
"gethostbyname" "gethostent" "getlogin" "getnetbyaddr" "getnetbyname"
|
||||
"getnetent" "getpeername" "getpgrp" "getppid" "getpriority"
|
||||
"getprotobyname" "getprotobynumber" "getprotoent" "getpwent" "getpwnam"
|
||||
"getpwuid" "getservbyname" "getservbyport" "getservent" "getsockname"
|
||||
"getsockopt" "glob" "gmtime" "goto" "grep" "gt" "hex" "if" "index" "int"
|
||||
"ioctl" "join" "keys" "kill" "last" "lc" "lcfirst" "le" "length"
|
||||
"link" "listen" "local" "localtime" "lock" "log" "lstat" "lt" "map"
|
||||
"mkdir" "msgctl" "msgget" "msgrcv" "msgsnd" "my" "ne" "next" "no"
|
||||
"not" "oct" "open" "opendir" "or" "ord" "our" "pack" "package" "pipe"
|
||||
"pop" "pos" "print" "printf" "push" "q" "qq" "quotemeta" "qw" "qx"
|
||||
"rand" "read" "readdir" "readline" "readlink" "readpipe" "recv" "redo"
|
||||
"ref" "rename" "require" "reset" "return" "reverse" "rewinddir" "rindex"
|
||||
"rmdir" "scalar" "seek" "seekdir" "select" "semctl" "semget" "semop"
|
||||
"send" "setgrent" "sethostent" "setnetent" "setpgrp" "setpriority"
|
||||
"setprotoent" "setpwent" "setservent" "setsockopt" "shift" "shmctl"
|
||||
"shmget" "shmread" "shmwrite" "shutdown" "sin" "sleep" "socket"
|
||||
"socketpair" "sort" "splice" "split" "sprintf" "sqrt" "srand" "stat"
|
||||
"study" "sub" "substr" "symlink" "syscall" "sysopen" "sysread" "system"
|
||||
"syswrite" "tell" "telldir" "tie" "time" "times" "tr" "truncate" "uc"
|
||||
"ucfirst" "umask" "undef" "unless" "unlink" "unpack" "unshift" "untie"
|
||||
"until" "use" "utime" "values" "vec" "wait" "waitpid"
|
||||
"wantarray" "warn" "while" "write" "x" "xor" "y")
|
||||
(php-mode
|
||||
"__CLASS__" "__DIR__" "__FILE__" "__FUNCTION__" "__LINE__" "__METHOD__"
|
||||
"__NAMESPACE__" "_once" "abstract" "and" "array" "as" "break" "case"
|
||||
"catch" "cfunction" "class" "clone" "const" "continue" "declare"
|
||||
"default" "die" "do" "echo" "else" "elseif" "empty" "enddeclare"
|
||||
"endfor" "endforeach" "endif" "endswitch" "endwhile" "eval" "exception"
|
||||
"exit" "extends" "final" "for" "foreach" "function" "global"
|
||||
"goto" "if" "implements" "include" "instanceof" "interface"
|
||||
"isset" "list" "namespace" "new" "old_function" "or" "php_user_filter"
|
||||
"print" "private" "protected" "public" "require" "require_once" "return"
|
||||
"static" "switch" "this" "throw" "try" "unset" "use" "var" "while" "xor")
|
||||
(python-mode
|
||||
;; https://docs.python.org/3/reference/lexical_analysis.html#keywords
|
||||
"False" "None" "True" "and" "as" "assert" "break" "class" "continue" "def"
|
||||
"del" "elif" "else" "except" "exec" "finally" "for" "from" "global" "if"
|
||||
"import" "in" "is" "lambda" "nonlocal" "not" "or" "pass" "print" "raise"
|
||||
"return" "try" "while" "with" "yield")
|
||||
(ruby-mode
|
||||
"BEGIN" "END" "alias" "and" "begin" "break" "case" "class" "def" "defined?"
|
||||
"do" "else" "elsif" "end" "ensure" "false" "for" "if" "in" "module"
|
||||
"next" "nil" "not" "or" "redo" "rescue" "retry" "return" "self" "super"
|
||||
"then" "true" "undef" "unless" "until" "when" "while" "yield")
|
||||
;; From https://doc.rust-lang.org/grammar.html#keywords
|
||||
;; but excluding unused reserved words: https://www.reddit.com/r/rust/comments/34fq0k/is_there_a_good_list_of_rusts_keywords/cqucvnj
|
||||
(rust-mode
|
||||
"Self"
|
||||
"as" "box" "break" "const" "continue" "crate" "else" "enum" "extern"
|
||||
"false" "fn" "for" "if" "impl" "in" "let" "loop" "macro" "match" "mod"
|
||||
"move" "mut" "pub" "ref" "return" "self" "static" "struct" "super"
|
||||
"trait" "true" "type" "unsafe" "use" "where" "while")
|
||||
(scala-mode
|
||||
"abstract" "case" "catch" "class" "def" "do" "else" "extends" "false"
|
||||
"final" "finally" "for" "forSome" "if" "implicit" "import" "lazy" "match"
|
||||
"new" "null" "object" "override" "package" "private" "protected"
|
||||
"return" "sealed" "super" "this" "throw" "trait" "true" "try" "type" "val"
|
||||
"var" "while" "with" "yield")
|
||||
(swift-mode
|
||||
"Protocol" "Self" "Type" "and" "as" "assignment" "associatedtype"
|
||||
"associativity" "available" "break" "case" "catch" "class" "column" "continue"
|
||||
"convenience" "default" "defer" "deinit" "didSet" "do" "dynamic" "dynamicType"
|
||||
"else" "elseif" "endif" "enum" "extension" "fallthrough" "false" "file"
|
||||
"fileprivate" "final" "for" "func" "function" "get" "guard" "higherThan" "if"
|
||||
"import" "in" "indirect" "infix" "init" "inout" "internal" "is" "lazy" "left"
|
||||
"let" "line" "lowerThan" "mutating" "nil" "none" "nonmutating" "open"
|
||||
"operator" "optional" "override" "postfix" "precedence" "precedencegroup"
|
||||
"prefix" "private" "protocol" "public" "repeat" "required" "rethrows" "return"
|
||||
"right" "selector" "self" "set" "static" "struct" "subscript" "super" "switch"
|
||||
"throw" "throws" "true" "try" "typealias" "unowned" "var" "weak" "where"
|
||||
"while" "willSet")
|
||||
(julia-mode
|
||||
"abstract" "break" "case" "catch" "const" "continue" "do" "else" "elseif"
|
||||
"end" "eval" "export" "false" "finally" "for" "function" "global" "if"
|
||||
"ifelse" "immutable" "import" "importall" "in" "let" "macro" "module"
|
||||
"otherwise" "quote" "return" "switch" "throw" "true" "try" "type"
|
||||
"typealias" "using" "while"
|
||||
)
|
||||
;; From https://github.com/apache/thrift/blob/master/contrib/thrift.el
|
||||
(thrift-mode
|
||||
"binary" "bool" "byte" "const" "double" "enum" "exception" "extends"
|
||||
"i16" "i32" "i64" "include" "list" "map" "oneway" "optional" "required"
|
||||
"service" "set" "string" "struct" "throws" "typedef" "void"
|
||||
)
|
||||
;; aliases
|
||||
(js2-mode . javascript-mode)
|
||||
(js2-jsx-mode . javascript-mode)
|
||||
(espresso-mode . javascript-mode)
|
||||
(js-mode . javascript-mode)
|
||||
(js-jsx-mode . javascript-mode)
|
||||
(rjsx-mode . javascript-mode)
|
||||
(cperl-mode . perl-mode)
|
||||
(jde-mode . java-mode)
|
||||
(ess-julia-mode . julia-mode)
|
||||
(enh-ruby-mode . ruby-mode))
|
||||
"Alist mapping major-modes to sorted keywords for `company-keywords'.")
|
||||
|
||||
;;;###autoload
|
||||
(defun company-keywords (command &optional arg &rest ignored)
|
||||
"`company-mode' backend for programming language keywords."
|
||||
(interactive (list 'interactive))
|
||||
(cl-case command
|
||||
(interactive (company-begin-backend 'company-keywords))
|
||||
(prefix (and (assq major-mode company-keywords-alist)
|
||||
(not (company-in-string-or-comment))
|
||||
(or (company-grab-symbol) 'stop)))
|
||||
(candidates
|
||||
(let ((completion-ignore-case nil)
|
||||
(symbols (cdr (assq major-mode company-keywords-alist))))
|
||||
(all-completions arg (if (consp symbols)
|
||||
symbols
|
||||
(cdr (assq symbols company-keywords-alist))))))
|
||||
(sorted t)))
|
||||
|
||||
(provide 'company-keywords)
|
||||
;;; company-keywords.el ends here
|
Binary file not shown.
|
@ -1,143 +0,0 @@
|
|||
;;; company-nxml.el --- company-mode completion backend for nxml-mode
|
||||
|
||||
;; Copyright (C) 2009-2011, 2013, 2018 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
;;; Commentary:
|
||||
;;
|
||||
;; In Emacs >= 26, company-capf is used instead.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'company)
|
||||
(require 'cl-lib)
|
||||
|
||||
(defvar rng-open-elements)
|
||||
(defvar rng-validate-mode)
|
||||
(defvar rng-in-attribute-regex)
|
||||
(defvar rng-in-attribute-value-regex)
|
||||
(declare-function rng-set-state-after "rng-nxml")
|
||||
(declare-function rng-match-possible-start-tag-names "rng-match")
|
||||
(declare-function rng-adjust-state-for-attribute "rng-nxml")
|
||||
(declare-function rng-match-possible-attribute-names "rng-match")
|
||||
(declare-function rng-adjust-state-for-attribute-value "rng-nxml")
|
||||
(declare-function rng-match-possible-value-strings "rng-match")
|
||||
|
||||
(defconst company-nxml-token-regexp
|
||||
"\\(?:[_[:alpha:]][-._[:alnum:]]*\\_>\\)")
|
||||
|
||||
(defvar company-nxml-in-attribute-value-regexp
|
||||
(replace-regexp-in-string "w" company-nxml-token-regexp
|
||||
"<w\\(?::w\\)?\
|
||||
\\(?:[ \t\r\n]+w\\(?::w\\)?[ \t\r\n]*=\
|
||||
\[ \t\r\n]*\\(?:\"[^\"]*\"\\|'[^']*'\\)\\)*\
|
||||
\[ \t\r\n]+\\(w\\(:w\\)?\\)[ \t\r\n]*=[ \t\r\n]*\
|
||||
\\(\"\\([^\"]*\\>\\)\\|'\\([^']*\\>\\)\\)\\="
|
||||
t t))
|
||||
|
||||
(defvar company-nxml-in-tag-name-regexp
|
||||
(replace-regexp-in-string "w" company-nxml-token-regexp
|
||||
"<\\(/?w\\(?::w?\\)?\\)?\\=" t t))
|
||||
|
||||
(defun company-nxml-all-completions (prefix alist)
|
||||
(let ((candidates (mapcar 'cdr alist))
|
||||
(case-fold-search nil)
|
||||
filtered)
|
||||
(when (cdar rng-open-elements)
|
||||
(push (concat "/" (cdar rng-open-elements)) candidates))
|
||||
(setq candidates (sort (all-completions prefix candidates) 'string<))
|
||||
(while candidates
|
||||
(unless (equal (car candidates) (car filtered))
|
||||
(push (car candidates) filtered))
|
||||
(pop candidates))
|
||||
(nreverse filtered)))
|
||||
|
||||
(defmacro company-nxml-prepared (&rest body)
|
||||
(declare (indent 0) (debug t))
|
||||
`(let ((lt-pos (save-excursion (search-backward "<" nil t)))
|
||||
xmltok-dtd)
|
||||
(when (and lt-pos (= (rng-set-state-after lt-pos) lt-pos))
|
||||
,@body)))
|
||||
|
||||
(defun company-nxml-tag (command &optional arg &rest ignored)
|
||||
(cl-case command
|
||||
(prefix (and (derived-mode-p 'nxml-mode)
|
||||
rng-validate-mode
|
||||
(company-grab company-nxml-in-tag-name-regexp 1)))
|
||||
(candidates (company-nxml-prepared
|
||||
(company-nxml-all-completions
|
||||
arg (rng-match-possible-start-tag-names))))
|
||||
(sorted t)))
|
||||
|
||||
(defun company-nxml-attribute (command &optional arg &rest ignored)
|
||||
(cl-case command
|
||||
(prefix (and (derived-mode-p 'nxml-mode)
|
||||
rng-validate-mode
|
||||
(memq (char-after) '(?\ ?\t ?\n)) ;; outside word
|
||||
(company-grab rng-in-attribute-regex 1)))
|
||||
(candidates (company-nxml-prepared
|
||||
(and (rng-adjust-state-for-attribute
|
||||
lt-pos (- (point) (length arg)))
|
||||
(company-nxml-all-completions
|
||||
arg (rng-match-possible-attribute-names)))))
|
||||
(sorted t)))
|
||||
|
||||
(defun company-nxml-attribute-value (command &optional arg &rest ignored)
|
||||
(cl-case command
|
||||
(prefix (and (derived-mode-p 'nxml-mode)
|
||||
rng-validate-mode
|
||||
(and (memq (char-after) '(?' ?\" ?\ ?\t ?\n)) ;; outside word
|
||||
(looking-back company-nxml-in-attribute-value-regexp nil)
|
||||
(or (match-string-no-properties 4)
|
||||
(match-string-no-properties 5)
|
||||
""))))
|
||||
(candidates (company-nxml-prepared
|
||||
(let (attr-start attr-end colon)
|
||||
(and (looking-back rng-in-attribute-value-regex lt-pos)
|
||||
(setq colon (match-beginning 2)
|
||||
attr-start (match-beginning 1)
|
||||
attr-end (match-end 1))
|
||||
(rng-adjust-state-for-attribute lt-pos attr-start)
|
||||
(rng-adjust-state-for-attribute-value
|
||||
attr-start colon attr-end)
|
||||
(all-completions
|
||||
arg (rng-match-possible-value-strings))))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun company-nxml (command &optional arg &rest ignored)
|
||||
"`company-mode' completion backend for `nxml-mode'."
|
||||
(interactive (list 'interactive))
|
||||
(cl-case command
|
||||
(interactive (company-begin-backend 'company-nxml))
|
||||
(prefix (or (company-nxml-tag 'prefix)
|
||||
(company-nxml-attribute 'prefix)
|
||||
(company-nxml-attribute-value 'prefix)))
|
||||
(candidates (cond
|
||||
((company-nxml-tag 'prefix)
|
||||
(company-nxml-tag 'candidates arg))
|
||||
((company-nxml-attribute 'prefix)
|
||||
(company-nxml-attribute 'candidates arg))
|
||||
((company-nxml-attribute-value 'prefix)
|
||||
(sort (company-nxml-attribute-value 'candidates arg)
|
||||
'string<))))
|
||||
(sorted t)))
|
||||
|
||||
(provide 'company-nxml)
|
||||
;;; company-nxml.el ends here
|
Binary file not shown.
|
@ -1,57 +0,0 @@
|
|||
;;; company-oddmuse.el --- company-mode completion backend for oddmuse-mode
|
||||
|
||||
;; Copyright (C) 2009-2011, 2014 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
;;; Commentary:
|
||||
;;
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'company)
|
||||
(require 'cl-lib)
|
||||
(eval-when-compile (require 'yaoddmuse nil t))
|
||||
(eval-when-compile (require 'oddmuse nil t))
|
||||
|
||||
(defvar company-oddmuse-link-regexp
|
||||
"\\(\\<[A-Z][[:alnum:]]*\\>\\)\\|\\[\\[\\([[:alnum:]]+\\>\\|\\)")
|
||||
|
||||
(defun company-oddmuse-get-page-table ()
|
||||
(cl-case major-mode
|
||||
(yaoddmuse-mode (with-no-warnings
|
||||
(yaoddmuse-get-pagename-table yaoddmuse-wikiname)))
|
||||
(oddmuse-mode (with-no-warnings
|
||||
(oddmuse-make-completion-table oddmuse-wiki)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun company-oddmuse (command &optional arg &rest ignored)
|
||||
"`company-mode' completion backend for `oddmuse-mode'."
|
||||
(interactive (list 'interactive))
|
||||
(cl-case command
|
||||
(interactive (company-begin-backend 'company-oddmuse))
|
||||
(prefix (let ((case-fold-search nil))
|
||||
(and (memq major-mode '(oddmuse-mode yaoddmuse-mode))
|
||||
(looking-back company-oddmuse-link-regexp (point-at-bol))
|
||||
(or (match-string 1)
|
||||
(match-string 2)))))
|
||||
(candidates (all-completions arg (company-oddmuse-get-page-table)))))
|
||||
|
||||
(provide 'company-oddmuse)
|
||||
;;; company-oddmuse.el ends here
|
Binary file not shown.
|
@ -1,12 +0,0 @@
|
|||
(define-package "company" "20200324.2145" "Modular text completion framework"
|
||||
'((emacs "24.3"))
|
||||
:keywords
|
||||
'("abbrev" "convenience" "matching")
|
||||
:authors
|
||||
'(("Nikolaj Schumacher"))
|
||||
:maintainer
|
||||
'("Dmitry Gutov" . "dgutov@yandex.ru")
|
||||
:url "http://company-mode.github.io/")
|
||||
;; Local Variables:
|
||||
;; no-byte-compile: t
|
||||
;; End:
|
|
@ -1,168 +0,0 @@
|
|||
;;; company-semantic.el --- company-mode completion backend using Semantic
|
||||
|
||||
;; Copyright (C) 2009-2011, 2013-2016 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
;;; Commentary:
|
||||
;;
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'company)
|
||||
(require 'company-template)
|
||||
(require 'cl-lib)
|
||||
|
||||
(defvar semantic-idle-summary-function)
|
||||
(declare-function semantic-documentation-for-tag "semantic/doc" )
|
||||
(declare-function semantic-analyze-current-context "semantic/analyze")
|
||||
(declare-function semantic-analyze-possible-completions "semantic/complete")
|
||||
(declare-function semantic-analyze-find-tags-by-prefix "semantic/analyze/fcn")
|
||||
(declare-function semantic-tag-class "semantic/tag")
|
||||
(declare-function semantic-tag-name "semantic/tag")
|
||||
(declare-function semantic-tag-start "semantic/tag")
|
||||
(declare-function semantic-tag-buffer "semantic/tag")
|
||||
(declare-function semantic-active-p "semantic")
|
||||
(declare-function semantic-format-tag-prototype "semantic/format")
|
||||
|
||||
(defgroup company-semantic nil
|
||||
"Completion backend using Semantic."
|
||||
:group 'company)
|
||||
|
||||
(defcustom company-semantic-metadata-function 'company-semantic-summary-and-doc
|
||||
"The function turning a semantic tag into doc information."
|
||||
:type 'function)
|
||||
|
||||
(defcustom company-semantic-begin-after-member-access t
|
||||
"When non-nil, automatic completion will start whenever the current
|
||||
symbol is preceded by \".\", \"->\" or \"::\", ignoring
|
||||
`company-minimum-prefix-length'.
|
||||
|
||||
If `company-begin-commands' is a list, it should include `c-electric-lt-gt'
|
||||
and `c-electric-colon', for automatic completion right after \">\" and
|
||||
\":\"."
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom company-semantic-insert-arguments t
|
||||
"When non-nil, insert function arguments as a template after completion."
|
||||
:type 'boolean
|
||||
:package-version '(company . "0.9.0"))
|
||||
|
||||
(defvar company-semantic-modes '(c-mode c++-mode jde-mode java-mode))
|
||||
|
||||
(defvar-local company-semantic--current-tags nil
|
||||
"Tags for the current context.")
|
||||
|
||||
(defun company-semantic-documentation-for-tag (tag)
|
||||
(when (semantic-tag-buffer tag)
|
||||
;; When TAG's buffer is unknown, the function below raises an error.
|
||||
(semantic-documentation-for-tag tag)))
|
||||
|
||||
(defun company-semantic-doc-or-summary (tag)
|
||||
(or (company-semantic-documentation-for-tag tag)
|
||||
(and (require 'semantic-idle nil t)
|
||||
(require 'semantic/idle nil t)
|
||||
(funcall semantic-idle-summary-function tag nil t))))
|
||||
|
||||
(defun company-semantic-summary-and-doc (tag)
|
||||
(let ((doc (company-semantic-documentation-for-tag tag))
|
||||
(summary (funcall semantic-idle-summary-function tag nil t)))
|
||||
(and (stringp doc)
|
||||
(string-match "\n*\\(.*\\)$" doc)
|
||||
(setq doc (match-string 1 doc)))
|
||||
(concat summary
|
||||
(when doc
|
||||
(if (< (+ (length doc) (length summary) 4) (window-width))
|
||||
" -- "
|
||||
"\n"))
|
||||
doc)))
|
||||
|
||||
(defun company-semantic-doc-buffer (tag)
|
||||
(let ((doc (company-semantic-documentation-for-tag tag)))
|
||||
(when doc
|
||||
(company-doc-buffer
|
||||
(concat (funcall semantic-idle-summary-function tag nil t)
|
||||
"\n"
|
||||
doc)))))
|
||||
|
||||
(defsubst company-semantic-completions (prefix)
|
||||
(ignore-errors
|
||||
(let ((completion-ignore-case nil)
|
||||
(context (semantic-analyze-current-context)))
|
||||
(setq company-semantic--current-tags
|
||||
(semantic-analyze-possible-completions context 'no-unique))
|
||||
(all-completions prefix company-semantic--current-tags))))
|
||||
|
||||
(defun company-semantic-completions-raw (prefix)
|
||||
(setq company-semantic--current-tags nil)
|
||||
(dolist (tag (semantic-analyze-find-tags-by-prefix prefix))
|
||||
(unless (eq (semantic-tag-class tag) 'include)
|
||||
(push tag company-semantic--current-tags)))
|
||||
(delete "" (mapcar 'semantic-tag-name company-semantic--current-tags)))
|
||||
|
||||
(defun company-semantic-annotation (argument tags)
|
||||
(let* ((tag (assq argument tags))
|
||||
(kind (when tag (elt tag 1))))
|
||||
(cl-case kind
|
||||
(function (let* ((prototype (semantic-format-tag-prototype tag nil nil))
|
||||
(par-pos (string-match "(" prototype)))
|
||||
(when par-pos (substring prototype par-pos)))))))
|
||||
|
||||
(defun company-semantic--prefix ()
|
||||
(if company-semantic-begin-after-member-access
|
||||
(company-grab-symbol-cons "\\.\\|->\\|::" 2)
|
||||
(company-grab-symbol)))
|
||||
|
||||
;;;###autoload
|
||||
(defun company-semantic (command &optional arg &rest ignored)
|
||||
"`company-mode' completion backend using CEDET Semantic."
|
||||
(interactive (list 'interactive))
|
||||
(cl-case command
|
||||
(interactive (company-begin-backend 'company-semantic))
|
||||
(prefix (and (featurep 'semantic)
|
||||
(semantic-active-p)
|
||||
(memq major-mode company-semantic-modes)
|
||||
(not (company-in-string-or-comment))
|
||||
(or (company-semantic--prefix) 'stop)))
|
||||
(candidates (if (and (equal arg "")
|
||||
(not (looking-back "->\\|\\.\\|::" (- (point) 2))))
|
||||
(company-semantic-completions-raw arg)
|
||||
(company-semantic-completions arg)))
|
||||
(meta (funcall company-semantic-metadata-function
|
||||
(assoc arg company-semantic--current-tags)))
|
||||
(annotation (company-semantic-annotation arg
|
||||
company-semantic--current-tags))
|
||||
(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 ""))
|
||||
(duplicates t)
|
||||
(location (let ((tag (assoc arg company-semantic--current-tags)))
|
||||
(when (buffer-live-p (semantic-tag-buffer tag))
|
||||
(cons (semantic-tag-buffer tag)
|
||||
(semantic-tag-start tag)))))
|
||||
(post-completion (let ((anno (company-semantic-annotation
|
||||
arg company-semantic--current-tags)))
|
||||
(when (and company-semantic-insert-arguments anno)
|
||||
(insert anno)
|
||||
(company-template-c-like-templatify (concat arg anno)))
|
||||
))))
|
||||
|
||||
(provide 'company-semantic)
|
||||
;;; company-semantic.el ends here
|
Binary file not shown.
|
@ -1,272 +0,0 @@
|
|||
;;; company-template.el --- utility library for template expansion
|
||||
|
||||
;; Copyright (C) 2009, 2010, 2014-2017 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'cl-lib)
|
||||
|
||||
(defface company-template-field
|
||||
'((((background dark)) (:background "yellow" :foreground "black"))
|
||||
(((background light)) (:background "orange" :foreground "black")))
|
||||
"Face used for editable text in template fields."
|
||||
:group 'company-faces)
|
||||
|
||||
(defvar company-template-forward-field-item
|
||||
'(menu-item "" company-template-forward-field
|
||||
:filter company-template--keymap-filter))
|
||||
|
||||
(defvar company-template-nav-map
|
||||
(let ((keymap (make-sparse-keymap)))
|
||||
(define-key keymap [tab] company-template-forward-field-item)
|
||||
(define-key keymap (kbd "TAB") company-template-forward-field-item)
|
||||
keymap))
|
||||
|
||||
(defvar company-template-clear-field-item
|
||||
'(menu-item "" company-template-clear-field
|
||||
:filter company-template--keymap-filter))
|
||||
|
||||
(defvar company-template-field-map
|
||||
(let ((keymap (make-sparse-keymap)))
|
||||
(set-keymap-parent keymap company-template-nav-map)
|
||||
(define-key keymap (kbd "C-d") company-template-clear-field-item)
|
||||
keymap))
|
||||
|
||||
(defvar-local company-template--buffer-templates nil)
|
||||
|
||||
;; interactive ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defun company-template-templates-at (pos)
|
||||
(let (os)
|
||||
(dolist (o (overlays-at pos))
|
||||
;; FIXME: Always return the whole list of templates?
|
||||
;; We remove templates not at point after every command.
|
||||
(when (memq o company-template--buffer-templates)
|
||||
(push o os)))
|
||||
os))
|
||||
|
||||
(defun company-template-move-to-first (templ)
|
||||
(interactive)
|
||||
(goto-char (overlay-start templ))
|
||||
(company-template-forward-field))
|
||||
|
||||
(defun company-template-forward-field ()
|
||||
(interactive)
|
||||
(let ((start (point))
|
||||
(next-field-start (company-template-find-next-field)))
|
||||
(push-mark)
|
||||
(goto-char next-field-start)
|
||||
(company-template-remove-field (company-template-field-at start))))
|
||||
|
||||
(defun company-template-clear-field ()
|
||||
"Clear the field at point."
|
||||
(interactive)
|
||||
(let ((ovl (company-template-field-at (point))))
|
||||
(when ovl
|
||||
(company-template-remove-field ovl t)
|
||||
(let ((after-clear-fn
|
||||
(overlay-get ovl 'company-template-after-clear)))
|
||||
(when (functionp after-clear-fn)
|
||||
(funcall after-clear-fn))))))
|
||||
|
||||
(defun company-template--keymap-filter (cmd)
|
||||
(unless (run-hook-with-args-until-success 'yas-keymap-disable-hook)
|
||||
cmd))
|
||||
|
||||
(defun company-template--after-clear-c-like-field ()
|
||||
"Function that can be called after deleting a field of a c-like template.
|
||||
For c-like templates it is set as `after-post-fn' property on fields in
|
||||
`company-template-add-field'. If there is a next field, delete everything
|
||||
from point to it. If there is no field after point, remove preceding comma
|
||||
if present."
|
||||
(let* ((pos (point))
|
||||
(next-field-start (company-template-find-next-field))
|
||||
(last-field-p (not (company-template-field-at next-field-start))))
|
||||
(cond ((and (not last-field-p)
|
||||
(< pos next-field-start)
|
||||
(string-match "^[ ]*,+[ ]*$" (buffer-substring-no-properties
|
||||
pos next-field-start)))
|
||||
(delete-region pos next-field-start))
|
||||
((and last-field-p
|
||||
(looking-back ",+[ ]*" (line-beginning-position)))
|
||||
(delete-region (match-beginning 0) pos)))))
|
||||
|
||||
(defun company-template-find-next-field ()
|
||||
(let* ((start (point))
|
||||
(templates (company-template-templates-at start))
|
||||
(minimum (apply 'max (mapcar 'overlay-end templates)))
|
||||
(fields (cl-loop for templ in templates
|
||||
append (overlay-get templ 'company-template-fields))))
|
||||
(dolist (pos (mapcar 'overlay-start fields) minimum)
|
||||
(and pos
|
||||
(> pos start)
|
||||
(< pos minimum)
|
||||
(setq minimum pos)))))
|
||||
|
||||
(defun company-template-field-at (&optional point)
|
||||
(cl-loop for ovl in (overlays-at (or point (point)))
|
||||
when (overlay-get ovl 'company-template-parent)
|
||||
return ovl))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defun company-template-declare-template (beg end)
|
||||
(let ((ov (make-overlay beg end)))
|
||||
;; (overlay-put ov 'face 'highlight)
|
||||
(overlay-put ov 'keymap company-template-nav-map)
|
||||
(overlay-put ov 'priority 101)
|
||||
(overlay-put ov 'evaporate t)
|
||||
(push ov company-template--buffer-templates)
|
||||
(add-hook 'post-command-hook 'company-template-post-command nil t)
|
||||
ov))
|
||||
|
||||
(defun company-template-remove-template (templ)
|
||||
(mapc 'company-template-remove-field
|
||||
(overlay-get templ 'company-template-fields))
|
||||
(setq company-template--buffer-templates
|
||||
(delq templ company-template--buffer-templates))
|
||||
(delete-overlay templ))
|
||||
|
||||
(defun company-template-add-field (templ beg end &optional display after-clear-fn)
|
||||
"Add new field to template TEMPL spanning from BEG to END.
|
||||
When DISPLAY is non-nil, set the respective property on the overlay.
|
||||
Leave point at the end of the field.
|
||||
AFTER-CLEAR-FN is a function that can be used to apply custom behavior
|
||||
after deleting a field in `company-template-remove-field'."
|
||||
(cl-assert templ)
|
||||
(when (> end (overlay-end templ))
|
||||
(move-overlay templ (overlay-start templ) end))
|
||||
(let ((ov (make-overlay beg end))
|
||||
(siblings (overlay-get templ 'company-template-fields)))
|
||||
;; (overlay-put ov 'evaporate t)
|
||||
(overlay-put ov 'intangible t)
|
||||
(overlay-put ov 'face 'company-template-field)
|
||||
(when display
|
||||
(overlay-put ov 'display display))
|
||||
(overlay-put ov 'company-template-parent templ)
|
||||
(overlay-put ov 'insert-in-front-hooks '(company-template-insert-hook))
|
||||
(when after-clear-fn
|
||||
(overlay-put ov 'company-template-after-clear after-clear-fn))
|
||||
(overlay-put ov 'keymap company-template-field-map)
|
||||
(overlay-put ov 'priority 101)
|
||||
(push ov siblings)
|
||||
(overlay-put templ 'company-template-fields siblings)))
|
||||
|
||||
(defun company-template-remove-field (ovl &optional clear)
|
||||
(when (overlayp ovl)
|
||||
(when (overlay-buffer ovl)
|
||||
(when clear
|
||||
(delete-region (overlay-start ovl) (overlay-end ovl)))
|
||||
(delete-overlay ovl))
|
||||
(let* ((templ (overlay-get ovl 'company-template-parent))
|
||||
(siblings (overlay-get templ 'company-template-fields)))
|
||||
(setq siblings (delq ovl siblings))
|
||||
(overlay-put templ 'company-template-fields siblings))))
|
||||
|
||||
(defun company-template-clean-up (&optional pos)
|
||||
"Clean up all templates that don't contain POS."
|
||||
(let ((local-ovs (overlays-at (or pos (point)))))
|
||||
(dolist (templ company-template--buffer-templates)
|
||||
(unless (memq templ local-ovs)
|
||||
(company-template-remove-template templ)))))
|
||||
|
||||
;; hooks ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defun company-template-insert-hook (ovl after-p &rest _ignore)
|
||||
"Called when a snippet input prompt is modified."
|
||||
(unless after-p
|
||||
(company-template-remove-field ovl t)))
|
||||
|
||||
(defun company-template-post-command ()
|
||||
(company-template-clean-up)
|
||||
(unless company-template--buffer-templates
|
||||
(remove-hook 'post-command-hook 'company-template-post-command t)))
|
||||
|
||||
;; common ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defun company-template-c-like-templatify (call)
|
||||
(let* ((end (point-marker))
|
||||
(beg (- (point) (length call)))
|
||||
(templ (company-template-declare-template beg end))
|
||||
paren-open paren-close)
|
||||
(with-syntax-table (make-syntax-table (syntax-table))
|
||||
(modify-syntax-entry ?< "(")
|
||||
(modify-syntax-entry ?> ")")
|
||||
(when (search-backward ")" beg t)
|
||||
(setq paren-close (point-marker))
|
||||
(forward-char 1)
|
||||
(delete-region (point) end)
|
||||
(backward-sexp)
|
||||
(forward-char 1)
|
||||
(setq paren-open (point-marker)))
|
||||
(when (search-backward ">" beg t)
|
||||
(let ((angle-close (point-marker)))
|
||||
(forward-char 1)
|
||||
(backward-sexp)
|
||||
(forward-char)
|
||||
(company-template--c-like-args templ angle-close)))
|
||||
(when (looking-back "\\((\\*)\\)(" (line-beginning-position))
|
||||
(delete-region (match-beginning 1) (match-end 1)))
|
||||
(when paren-open
|
||||
(goto-char paren-open)
|
||||
(company-template--c-like-args templ paren-close)))
|
||||
(if (overlay-get templ 'company-template-fields)
|
||||
(company-template-move-to-first templ)
|
||||
(company-template-remove-template templ)
|
||||
(goto-char end))))
|
||||
|
||||
(defun company-template--c-like-args (templ end)
|
||||
(let ((last-pos (point)))
|
||||
(while (re-search-forward "\\([^,]+\\),?" end 'move)
|
||||
(when (zerop (car (parse-partial-sexp last-pos (point))))
|
||||
(company-template-add-field templ last-pos (match-end 1) nil
|
||||
#'company-template--after-clear-c-like-field)
|
||||
(skip-chars-forward " ")
|
||||
(setq last-pos (point))))))
|
||||
|
||||
;; objc ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defun company-template-objc-templatify (selector)
|
||||
(let* ((end (point-marker))
|
||||
(beg (- (point) (length selector) 1))
|
||||
(templ (company-template-declare-template beg end))
|
||||
(cnt 0))
|
||||
(save-excursion
|
||||
(goto-char beg)
|
||||
(catch 'stop
|
||||
(while (search-forward ":" end t)
|
||||
(if (looking-at "\\(([^)]*)\\) ?")
|
||||
(company-template-add-field templ (point) (match-end 1))
|
||||
;; Not sure which conditions this case manifests under, but
|
||||
;; apparently it did before, when I wrote the first test for this
|
||||
;; function. FIXME: Revisit it.
|
||||
(company-template-add-field templ (point)
|
||||
(progn
|
||||
(insert (format "arg%d" cnt))
|
||||
(point)))
|
||||
(when (< (point) end)
|
||||
(insert " "))
|
||||
(cl-incf cnt))
|
||||
(when (>= (point) end)
|
||||
(throw 'stop t)))))
|
||||
(company-template-move-to-first templ)))
|
||||
|
||||
(provide 'company-template)
|
||||
;;; company-template.el ends here
|
Binary file not shown.
|
@ -1,71 +0,0 @@
|
|||
;;; company-tempo.el --- company-mode completion backend for tempo
|
||||
|
||||
;; Copyright (C) 2009-2011, 2015 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
;;; Commentary:
|
||||
;;
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'company)
|
||||
(require 'cl-lib)
|
||||
(require 'tempo)
|
||||
|
||||
(defgroup company-tempo nil
|
||||
"Tempo completion backend."
|
||||
:group 'company)
|
||||
|
||||
(defcustom company-tempo-expand nil
|
||||
"Whether to expand a tempo tag after completion."
|
||||
:type '(choice (const :tag "Off" nil)
|
||||
(const :tag "On" t)))
|
||||
|
||||
(defsubst company-tempo-lookup (match)
|
||||
(cdr (assoc match (tempo-build-collection))))
|
||||
|
||||
(defun company-tempo-insert (match)
|
||||
"Replace MATCH with the expanded tempo template."
|
||||
(search-backward match)
|
||||
(goto-char (match-beginning 0))
|
||||
(replace-match "")
|
||||
(call-interactively (company-tempo-lookup match)))
|
||||
|
||||
(defsubst company-tempo-meta (match)
|
||||
(let ((templ (company-tempo-lookup match))
|
||||
doc)
|
||||
(and templ
|
||||
(setq doc (documentation templ t))
|
||||
(car (split-string doc "\n" t)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun company-tempo (command &optional arg &rest ignored)
|
||||
"`company-mode' completion backend for tempo."
|
||||
(interactive (list 'interactive))
|
||||
(cl-case command
|
||||
(interactive (company-begin-backend 'company-tempo))
|
||||
(prefix (or (car (tempo-find-match-string tempo-match-finder)) ""))
|
||||
(candidates (all-completions arg (tempo-build-collection)))
|
||||
(meta (company-tempo-meta arg))
|
||||
(post-completion (when company-tempo-expand (company-tempo-insert arg)))
|
||||
(sorted t)))
|
||||
|
||||
(provide 'company-tempo)
|
||||
;;; company-tempo.el ends here
|
Binary file not shown.
|
@ -1,194 +0,0 @@
|
|||
;;; company-tng.el --- company-mode configuration for single-button interaction
|
||||
|
||||
;; Copyright (C) 2017 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Nikita Leshenko
|
||||
|
||||
;; 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
;;; Commentary:
|
||||
;;
|
||||
;; company-tng (Tab and Go) allows you to perform completion using just TAB.
|
||||
;; Pressing it will both select the next completion candidate in the list and
|
||||
;; insert it into the buffer (or make it look like it's inserted, in fact).
|
||||
;;
|
||||
;; It cycles the candidates like `yank-pop' or `dabbrev-expand' or Vim:
|
||||
;; Pressing TAB selects the first item in the completion menu and inserts it in
|
||||
;; the buffer. Pressing TAB again selects the second item and replaces the
|
||||
;; "inserted" item with the second one. This can continue as long as the user
|
||||
;; wishes to cycle through the menu. You can also press S-TAB to select the
|
||||
;; previous candidate, of course.
|
||||
;;
|
||||
;; The benefits are that you only have to use one shortcut key and there is no
|
||||
;; need to confirm the entry.
|
||||
;;
|
||||
;; Usage:
|
||||
;;
|
||||
;; To apply the default configuration for company-tng call
|
||||
;; `company-tng-configure-default' from your init script.
|
||||
;;
|
||||
;; You can also configure company-tng manually:
|
||||
;;
|
||||
;; Add `company-tng-frontend' to `company-frontends':
|
||||
;;
|
||||
;; (add-to-list 'company-frontends 'company-tng-frontend)
|
||||
;;
|
||||
;; We recommend to bind TAB to `company-select-next', S-TAB to
|
||||
;; `company-select-previous', and unbind RET and other now-unnecessary
|
||||
;; keys from `company-active-map':
|
||||
;;
|
||||
;; (define-key company-active-map (kbd "TAB") 'company-select-next)
|
||||
;; (define-key company-active-map (kbd "<backtab>") 'company-select-previous)
|
||||
;; (define-key company-active-map (kbd "RET") nil)
|
||||
;;
|
||||
;; Note that it's not necessary to rebind keys to use this frontend,
|
||||
;; you can use the arrow keys or M-n/M-p to select and insert
|
||||
;; candidates. You also need to decide which keys to unbind, depending
|
||||
;; on whether you want them to do the Company action or the default
|
||||
;; Emacs action (for example C-s or C-w).
|
||||
;;
|
||||
;; We recommend to disable `company-require-match' to allow free typing at any
|
||||
;; point.
|
||||
;;
|
||||
;; By default, company-tng doesn't work well with backends that use
|
||||
;; `post-completion' (for actions such as expanding snippets in
|
||||
;; company-yasnippet or company-template). In company-tng, completion candidates
|
||||
;; are inserted into the buffer as the user selects them and the completion is
|
||||
;; finished implicitly when the user continues typing after selecting a
|
||||
;; candidate. Modifying the buffer (by expanding a snippet) when the user
|
||||
;; continues typing would be surprising and undesirable, since the candidate was
|
||||
;; already inserted into the buffer. For this reason company-tng disables
|
||||
;; `post-completion' in all backends.
|
||||
;;
|
||||
;; YASnippet and company-tng both use TAB, which causes conflicts. The
|
||||
;; recommended way to use YASnippet with company-tng is to choose a different
|
||||
;; key for expanding a snippet and moving to the next snippet field:
|
||||
;;
|
||||
;; (define-key yas-minor-mode-map "\C-j" 'yas-expand)
|
||||
;; (define-key yas-keymap "\C-j" 'yas-next-field-or-maybe-expand)
|
||||
;; (dolist (keymap (list yas-minor-mode-map yas-keymap))
|
||||
;; (define-key keymap (kbd "TAB") nil)
|
||||
;; (define-key keymap [(tab)] nil))
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'company)
|
||||
(require 'cl-lib)
|
||||
|
||||
(defvar-local company-tng--overlay nil)
|
||||
|
||||
;;;###autoload
|
||||
(defun company-tng-frontend (command)
|
||||
"When the user changes the selection at least once, this
|
||||
frontend will display the candidate in the buffer as if it's
|
||||
already there and any key outside of `company-active-map' will
|
||||
confirm the selection and finish the completion."
|
||||
(cl-case command
|
||||
(show
|
||||
(let ((ov (make-overlay (point) (point))))
|
||||
(setq company-tng--overlay ov)
|
||||
(overlay-put ov 'priority 2))
|
||||
(advice-add 'company-select-next :before-until 'company-tng--allow-unselected)
|
||||
(advice-add 'company-fill-propertize :filter-args 'company-tng--adjust-tooltip-highlight))
|
||||
(update
|
||||
(let ((ov company-tng--overlay)
|
||||
(selected (nth company-selection company-candidates))
|
||||
(prefix (length company-prefix)))
|
||||
(move-overlay ov (- (point) prefix) (point))
|
||||
(overlay-put ov
|
||||
(if (= prefix 0) 'after-string 'display)
|
||||
(and company-selection-changed selected))))
|
||||
(hide
|
||||
(when company-tng--overlay
|
||||
(delete-overlay company-tng--overlay)
|
||||
(kill-local-variable 'company-tng--overlay))
|
||||
(advice-remove 'company-select-next 'company-tng--allow-unselected)
|
||||
(advice-remove 'company-fill-propertize 'company-tng--adjust-tooltip-highlight))
|
||||
(pre-command
|
||||
(when (and company-selection-changed
|
||||
(not (company--company-command-p (this-command-keys))))
|
||||
(company--unread-this-command-keys)
|
||||
(setq this-command 'company-complete-selection)
|
||||
(advice-add 'company-call-backend :before-until 'company-tng--supress-post-completion)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun company-tng-configure-default ()
|
||||
"Applies the default configuration to enable company-tng."
|
||||
(setq company-require-match nil)
|
||||
(setq company-frontends '(company-tng-frontend
|
||||
company-pseudo-tooltip-frontend
|
||||
company-echo-metadata-frontend))
|
||||
(let ((keymap company-active-map))
|
||||
(define-key keymap [return] nil)
|
||||
(define-key keymap (kbd "RET") nil)
|
||||
(define-key keymap [tab] 'company-select-next)
|
||||
(define-key keymap (kbd "TAB") 'company-select-next)
|
||||
(define-key keymap [backtab] 'company-select-previous)
|
||||
(define-key keymap (kbd "S-TAB") 'company-select-previous)))
|
||||
|
||||
(defun company-tng--allow-unselected (&optional arg)
|
||||
"Advice `company-select-next' to allow for an 'unselected'
|
||||
state. Unselected means that no user interaction took place on the
|
||||
completion candidates and it's marked by setting
|
||||
`company-selection-changed' to nil. This advice will call the underlying
|
||||
`company-select-next' unless we need to transition to or from an unselected
|
||||
state.
|
||||
|
||||
Possible state transitions:
|
||||
- (arg > 0) unselected -> first candidate selected
|
||||
- (arg < 0) first candidate selected -> unselected
|
||||
- (arg < 0 wrap-round) unselected -> last candidate selected
|
||||
- (arg < 0 no wrap-round) unselected -> unselected
|
||||
|
||||
There is no need to advice `company-select-previous' because it calls
|
||||
`company-select-next' internally."
|
||||
(cond
|
||||
;; Selecting next
|
||||
((or (not arg) (> arg 0))
|
||||
(unless company-selection-changed
|
||||
(company-set-selection (1- (or arg 1)) 'force-update)
|
||||
t))
|
||||
;; Selecting previous
|
||||
((< arg 0)
|
||||
(when (and company-selection-changed
|
||||
(< (+ company-selection arg) 0))
|
||||
(company-set-selection 0)
|
||||
(setq company-selection-changed nil)
|
||||
(company-call-frontends 'update)
|
||||
t)
|
||||
)))
|
||||
|
||||
(defun company-tng--adjust-tooltip-highlight (args)
|
||||
"Prevent the tooltip from highlighting the current selection if it wasn't
|
||||
made explicitly (i.e. `company-selection-changed' is true)"
|
||||
(unless company-selection-changed
|
||||
;; The 4th arg of `company-fill-propertize' is selected
|
||||
(setf (nth 3 args) nil))
|
||||
args)
|
||||
|
||||
(defun company-tng--supress-post-completion (command &rest args)
|
||||
"Installed as a :before-until advice on `company-call-backend' and
|
||||
prevents the 'post-completion command from being delivered to the backend
|
||||
for the next iteration. post-completion do things like expand snippets
|
||||
which are undesirable because completions are implicit in company-tng and
|
||||
visible side-effects after the completion are surprising."
|
||||
(when (eq command 'post-completion)
|
||||
(advice-remove 'company-call-backend 'company-tng--supress-post-completion)
|
||||
t))
|
||||
|
||||
(provide 'company-tng)
|
||||
;;; company-tng.el ends here
|
Binary file not shown.
|
@ -1,123 +0,0 @@
|
|||
;;; company-xcode.el --- company-mode completion backend for Xcode projects
|
||||
|
||||
;; Copyright (C) 2009-2011, 2014 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
;;; Commentary:
|
||||
;;
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'company)
|
||||
(require 'cl-lib)
|
||||
|
||||
(defgroup company-xcode nil
|
||||
"Completion backend for Xcode projects."
|
||||
:group 'company)
|
||||
|
||||
(defcustom company-xcode-xcodeindex-executable (executable-find "xcodeindex")
|
||||
"Location of xcodeindex executable."
|
||||
:type 'file)
|
||||
|
||||
(defvar company-xcode-tags nil)
|
||||
|
||||
(defun company-xcode-reset ()
|
||||
"Reset the cached tags."
|
||||
(interactive)
|
||||
(setq company-xcode-tags nil))
|
||||
|
||||
(defcustom company-xcode-types
|
||||
'("Class" "Constant" "Enum" "Macro" "Modeled Class" "Structure"
|
||||
"Type" "Union" "Function")
|
||||
"The types of symbols offered by `company-xcode'.
|
||||
No context-enabled completion is available. Types like methods will be
|
||||
offered regardless of whether the class supports them. The defaults should be
|
||||
valid in most contexts."
|
||||
:set (lambda (variable value)
|
||||
(set variable value)
|
||||
(company-xcode-reset))
|
||||
:type '(set (const "Category") (const "Class") (const "Class Method")
|
||||
(const "Class Variable") (const "Constant") (const "Enum")
|
||||
(const "Field") (const "Instance Method")
|
||||
(const "Instance Variable") (const "Macro")
|
||||
(const "Modeled Class") (const "Modeled Method")
|
||||
(const "Modeled Property") (const "Property") (const "Protocol")
|
||||
(const "Structure") (const "Type") (const "Union")
|
||||
(const "Variable") (const "Function")))
|
||||
|
||||
(defvar-local company-xcode-project 'unknown)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defun company-xcode-fetch (project-bundle)
|
||||
(setq project-bundle (directory-file-name project-bundle))
|
||||
(message "Retrieving dump from %s..." project-bundle)
|
||||
(with-temp-buffer
|
||||
(let ((default-directory (file-name-directory project-bundle)))
|
||||
(call-process company-xcode-xcodeindex-executable nil (current-buffer)
|
||||
nil "dump" "-project"
|
||||
(file-name-nondirectory project-bundle) "-quiet")
|
||||
(goto-char (point-min))
|
||||
(let ((regexp (concat "^\\([^\t\n]*\\)\t[^\t\n]*\t"
|
||||
(regexp-opt company-xcode-types)
|
||||
"\t[^\t\n]*\t[^\t\n]*"))
|
||||
candidates)
|
||||
(while (re-search-forward regexp nil t)
|
||||
(cl-pushnew (match-string 1) candidates :test #'equal))
|
||||
(message "Retrieving dump from %s...done" project-bundle)
|
||||
candidates))))
|
||||
|
||||
(defun company-xcode-find-project ()
|
||||
(let ((dir (if buffer-file-name
|
||||
(file-name-directory buffer-file-name)
|
||||
(expand-file-name default-directory)))
|
||||
(prev-dir nil)
|
||||
file)
|
||||
(while (not (or file (equal dir prev-dir)))
|
||||
(setq file (car (directory-files dir t ".xcodeproj\\'" t))
|
||||
prev-dir dir
|
||||
dir (file-name-directory (directory-file-name dir))))
|
||||
file))
|
||||
|
||||
(defun company-xcode-tags ()
|
||||
(when (eq company-xcode-project 'unknown)
|
||||
(setq company-xcode-project (company-xcode-find-project)))
|
||||
(when company-xcode-project
|
||||
(cdr (or (assoc company-xcode-project company-xcode-tags)
|
||||
(car (push (cons company-xcode-project
|
||||
(company-xcode-fetch company-xcode-project))
|
||||
company-xcode-tags))))))
|
||||
;;;###autoload
|
||||
(defun company-xcode (command &optional arg &rest ignored)
|
||||
"`company-mode' completion backend for Xcode projects."
|
||||
(interactive (list 'interactive))
|
||||
(cl-case command
|
||||
(interactive (company-begin-backend 'company-xcode))
|
||||
(prefix (and company-xcode-xcodeindex-executable
|
||||
(company-xcode-tags)
|
||||
(not (company-in-string-or-comment))
|
||||
(or (company-grab-symbol) 'stop)))
|
||||
(candidates (let ((completion-ignore-case nil))
|
||||
(company-xcode-tags)
|
||||
(all-completions arg (company-xcode-tags))))))
|
||||
|
||||
|
||||
(provide 'company-xcode)
|
||||
;;; company-xcode.el ends here
|
Binary file not shown.
|
@ -1,176 +0,0 @@
|
|||
;;; company-yasnippet.el --- company-mode completion backend for Yasnippet
|
||||
|
||||
;; Copyright (C) 2014, 2015, 2020 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Dmitry Gutov
|
||||
|
||||
;; 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
;;; Commentary:
|
||||
;;
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'company)
|
||||
(require 'cl-lib)
|
||||
|
||||
(declare-function yas--table-hash "yasnippet")
|
||||
(declare-function yas--get-snippet-tables "yasnippet")
|
||||
(declare-function yas-expand-snippet "yasnippet")
|
||||
(declare-function yas--template-content "yasnippet")
|
||||
(declare-function yas--template-expand-env "yasnippet")
|
||||
(declare-function yas--warning "yasnippet")
|
||||
|
||||
(defvar company-yasnippet-annotation-fn
|
||||
(lambda (name)
|
||||
(concat
|
||||
(unless company-tooltip-align-annotations " -> ")
|
||||
name))
|
||||
"Function to format completion annotation.
|
||||
It has to accept one argument: the snippet's name.")
|
||||
|
||||
(defun company-yasnippet--key-prefixes ()
|
||||
;; Mostly copied from `yas--templates-for-key-at-point'.
|
||||
(defvar yas-key-syntaxes)
|
||||
(save-excursion
|
||||
(let ((original (point))
|
||||
(methods yas-key-syntaxes)
|
||||
prefixes
|
||||
method)
|
||||
(while methods
|
||||
(unless (eq method (car methods))
|
||||
(goto-char original))
|
||||
(setq method (car methods))
|
||||
(cond ((stringp method)
|
||||
(skip-syntax-backward method)
|
||||
(setq methods (cdr methods)))
|
||||
((functionp method)
|
||||
(unless (eq (funcall method original)
|
||||
'again)
|
||||
(setq methods (cdr methods))))
|
||||
(t
|
||||
(setq methods (cdr methods))
|
||||
(yas--warning "Invalid element `%s' in `yas-key-syntaxes'" method)))
|
||||
(let ((prefix (buffer-substring-no-properties (point) original)))
|
||||
(unless (equal prefix (car prefixes))
|
||||
(push prefix prefixes))))
|
||||
prefixes)))
|
||||
|
||||
(defun company-yasnippet--candidates (prefix)
|
||||
;; Process the prefixes in reverse: unlike Yasnippet, we look for prefix
|
||||
;; matches, so the longest prefix with any matches should be the most useful.
|
||||
(cl-loop with tables = (yas--get-snippet-tables)
|
||||
for key-prefix in (company-yasnippet--key-prefixes)
|
||||
;; Only consider keys at least as long as the symbol at point.
|
||||
when (>= (length key-prefix) (length prefix))
|
||||
thereis (company-yasnippet--completions-for-prefix prefix
|
||||
key-prefix
|
||||
tables)))
|
||||
|
||||
(defun company-yasnippet--completions-for-prefix (prefix key-prefix tables)
|
||||
(cl-mapcan
|
||||
(lambda (table)
|
||||
(let ((keyhash (yas--table-hash table))
|
||||
res)
|
||||
(when keyhash
|
||||
(maphash
|
||||
(lambda (key value)
|
||||
(when (and (stringp key)
|
||||
(string-prefix-p key-prefix key))
|
||||
(maphash
|
||||
(lambda (name template)
|
||||
(push
|
||||
(propertize key
|
||||
'yas-annotation name
|
||||
'yas-template template
|
||||
'yas-prefix-offset (- (length key-prefix)
|
||||
(length prefix)))
|
||||
res))
|
||||
value)))
|
||||
keyhash))
|
||||
res))
|
||||
tables))
|
||||
|
||||
(defun company-yasnippet--doc (arg)
|
||||
(let ((template (get-text-property 0 'yas-template arg))
|
||||
(mode major-mode)
|
||||
(file-name (buffer-file-name)))
|
||||
(with-current-buffer (company-doc-buffer)
|
||||
(let ((buffer-file-name file-name))
|
||||
(yas-minor-mode 1)
|
||||
(condition-case error
|
||||
(yas-expand-snippet (yas--template-content template))
|
||||
(error
|
||||
(message "%s" (error-message-string error))))
|
||||
(delay-mode-hooks
|
||||
(let ((inhibit-message t))
|
||||
(if (eq mode 'web-mode)
|
||||
(progn
|
||||
(setq mode 'html-mode)
|
||||
(funcall mode))
|
||||
(funcall mode)))
|
||||
(ignore-errors (font-lock-ensure))))
|
||||
(current-buffer))))
|
||||
|
||||
;;;###autoload
|
||||
(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
|
||||
snippets defined for the current major mode, this backend will always
|
||||
shadow backends that come after it. Recommended usages:
|
||||
|
||||
* In a buffer-local value of `company-backends', grouped with a backend or
|
||||
several that provide actual text completions.
|
||||
|
||||
(add-hook 'js-mode-hook
|
||||
(lambda ()
|
||||
(set (make-local-variable 'company-backends)
|
||||
'((company-dabbrev-code company-yasnippet)))))
|
||||
|
||||
* After keyword `:with', grouped with other backends.
|
||||
|
||||
(push '(company-semantic :with company-yasnippet) company-backends)
|
||||
|
||||
* Not in `company-backends', just bound to a key.
|
||||
|
||||
(global-set-key (kbd \"C-c y\") 'company-yasnippet)
|
||||
"
|
||||
(interactive (list 'interactive))
|
||||
(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)))
|
||||
(annotation
|
||||
(funcall company-yasnippet-annotation-fn
|
||||
(get-text-property 0 'yas-annotation arg)))
|
||||
(candidates (company-yasnippet--candidates arg))
|
||||
(doc-buffer (company-yasnippet--doc arg))
|
||||
(no-cache t)
|
||||
(post-completion
|
||||
(let ((template (get-text-property 0 'yas-template arg))
|
||||
(prefix-offset (get-text-property 0 'yas-prefix-offset arg)))
|
||||
(yas-expand-snippet (yas--template-content template)
|
||||
(- (point) (length arg) prefix-offset)
|
||||
(point)
|
||||
(yas--template-expand-env template))))))
|
||||
|
||||
(provide 'company-yasnippet)
|
||||
;;; company-yasnippet.el ends here
|
Binary file not shown.
File diff suppressed because it is too large
Load diff
Binary file not shown.
|
@ -1 +0,0 @@
|
|||
Good signature from 066DAFCB81E42C40 GNU ELPA Signing Agent (2019) <elpasign@elpa.gnu.org> (trust undefined) created at 2019-09-21T19:56:21+0200 using RSA
|
|
@ -1,36 +0,0 @@
|
|||
;;; darkroom-autoloads.el --- automatically extracted autoloads
|
||||
;;
|
||||
;;; Code:
|
||||
|
||||
(add-to-list 'load-path (directory-file-name
|
||||
(or (file-name-directory #$) (car load-path))))
|
||||
|
||||
|
||||
;;;### (autoloads nil "darkroom" "darkroom.el" (0 0 0 0))
|
||||
;;; Generated autoloads from darkroom.el
|
||||
|
||||
(autoload 'darkroom-mode "darkroom" "\
|
||||
Remove visual distractions and focus on writing. When this
|
||||
mode is active, everything but the buffer's text is elided from
|
||||
view. The buffer margins are set so that text is centered on
|
||||
screen. Text size is increased (display engine allowing) by
|
||||
`darkroom-text-scale-increase'.
|
||||
|
||||
\(fn &optional ARG)" t nil)
|
||||
|
||||
(autoload 'darkroom-tentative-mode "darkroom" "\
|
||||
Enters `darkroom-mode' when all other windows are deleted.
|
||||
|
||||
\(fn &optional ARG)" t nil)
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "darkroom" '("darkroom-")))
|
||||
|
||||
;;;***
|
||||
|
||||
;; Local Variables:
|
||||
;; version-control: never
|
||||
;; no-byte-compile: t
|
||||
;; no-update-autoloads: t
|
||||
;; coding: utf-8
|
||||
;; End:
|
||||
;;; darkroom-autoloads.el ends here
|
|
@ -1,2 +0,0 @@
|
|||
;;; -*- no-byte-compile: t -*-
|
||||
(define-package "darkroom" "0.2" "Remove visual distractions and focus on writing" '((cl-lib "0.5")) :url "http://elpa.gnu.org/packages/darkroom.html" :keywords '("convenience" "emulations") :authors '(("João Távora" . "joaotavora@gmail.com")) :maintainer '("João Távora" . "joaotavora@gmail.com"))
|
|
@ -1,399 +0,0 @@
|
|||
;;; darkroom.el --- Remove visual distractions and focus on writing -*- lexical-binding: t; -*-
|
||||
|
||||
;; Copyright (C) 2014 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: João Távora <joaotavora@gmail.com>
|
||||
;; Maintainer: João Távora <joaotavora@gmail.com>
|
||||
;; Keywords: convenience, emulations
|
||||
;; Package-Requires: ((cl-lib "0.5"))
|
||||
;; Version: 0.2
|
||||
|
||||
;; 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; The main entrypoints to this extension are two minor modes:
|
||||
;;
|
||||
;; M-x darkroom-mode
|
||||
;; M-x darkroom-tentative-mode
|
||||
;;
|
||||
;; `darkroom-mode' makes visual distractions disappear: the
|
||||
;; mode-line is temporarily elided, text is enlarged and margins are
|
||||
;; adjusted so that it's centered on the window.
|
||||
;;
|
||||
;; `darkroom-tentative-mode' is similar, but it doesn't immediately
|
||||
;; turn-on `darkroom-mode', unless the current buffer lives in the
|
||||
;; sole window of the Emacs frame (i.e. all other windows are
|
||||
;; deleted). Whenever the frame is split to display more windows and
|
||||
;; more buffers, the buffer exits `darkroom-mode'. Whenever they are
|
||||
;; deleted, the buffer re-enters `darkroom-mode'.
|
||||
;;
|
||||
;; Personally, I always use `darkroom-tentative-mode'.
|
||||
;;
|
||||
;; See also the customization options `darkroom-margins' and
|
||||
;; `darkroom-fringes-outside-margins', which affect both modes.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'cl-lib)
|
||||
(require 'face-remap)
|
||||
|
||||
(defgroup darkroom nil
|
||||
"Remove visual distractions and focus on writing"
|
||||
:prefix "darkroom-"
|
||||
:group 'emulations)
|
||||
|
||||
(defcustom darkroom-margins 'darkroom-guess-margins
|
||||
"Margins to use in `darkroom-mode'.
|
||||
|
||||
Its value can be:
|
||||
|
||||
- a floating point value betweeen 0 and 1, specifies percentage of
|
||||
window width in columns to use as a margin.
|
||||
|
||||
- a cons cell (LEFT RIGHT) specifying the left and right margins
|
||||
in columns.
|
||||
|
||||
- a function of a single argument, a window, that returns a cons
|
||||
cell interpreted like the previous option. An example is
|
||||
`darkroom-guess-margins', which see. Beware that this function
|
||||
is called very often, so if it does some non-trivial processing
|
||||
on the buffer's text, consider caching that value.
|
||||
|
||||
Value is effective when `darkroom-mode' is toggled."
|
||||
:type '(choice float
|
||||
(cons integer integer)
|
||||
(function-item darkroom-guess-margins :doc "Guess margins")
|
||||
(function darkroom-guess-margins))
|
||||
:group 'darkroom)
|
||||
|
||||
(defcustom darkroom-text-scale-increase 2
|
||||
"Steps to increase text size when in `darkroom-mode'.
|
||||
Value is passed to `text-scale-increase'."
|
||||
:type 'integer
|
||||
:group 'darkroom)
|
||||
|
||||
(defcustom darkroom-fringes-outside-margins t
|
||||
"If non-nil use fringes outside margins for `darkroom-mode'"
|
||||
:type 'boolean
|
||||
:group 'darkroom)
|
||||
|
||||
(defcustom darkroom-margin-increment 0.05
|
||||
"Increment to add used in `darkroom-increase-margins'."
|
||||
:type 'float
|
||||
:group 'darkroom)
|
||||
|
||||
(defcustom darkroom-margins-if-failed-guess 0.15
|
||||
"Margins when `darkroom-guess-margins' fails.
|
||||
If `darkroom-guess-margins' failed to figure out margins to
|
||||
center the text, use this percentage of window width for the
|
||||
symmetical margins."
|
||||
:type 'float
|
||||
:group 'darkroom)
|
||||
|
||||
(defcustom darkroom-verbose nil
|
||||
"If non-nil, be verbose about darkroom operations."
|
||||
:type 'boolean
|
||||
:group 'darkroom)
|
||||
|
||||
(defvar darkroom--guess-margins-statistics-cache nil
|
||||
"Cache used by `darkroom-guess-margins'.")
|
||||
|
||||
(defun darkroom--window-width (&optional window)
|
||||
"Calculate width of WINDOW in columns, considering text scaling.
|
||||
WINDOW defaults to the currently selected window. The function
|
||||
assumes the buffer to be filled with at least one character of an
|
||||
arbitrary, but fixed width. Narrowing is taken in consideration.
|
||||
The return value is a cons (COLS . SCALED-CHAR-WIDTH) where COLS
|
||||
is the desired width in columns and SCALED-CHAR-WIDTH is the
|
||||
width in pixels of a single character."
|
||||
(when (= (point-min) (point-max))
|
||||
(error "Cannot calculate the width of a single character"))
|
||||
(let* ((window (or window (selected-window)))
|
||||
(scaled-char-width (car (window-text-pixel-size
|
||||
window
|
||||
(point-min) (1+ (point-min)))))
|
||||
(char-width (frame-char-width))
|
||||
(margins (window-margins window)))
|
||||
(cons (truncate
|
||||
(+ (window-width window 'pixelwise)
|
||||
(* char-width (or (car margins) 0))
|
||||
(* char-width (or (cdr margins) 0)))
|
||||
scaled-char-width)
|
||||
scaled-char-width)))
|
||||
|
||||
(defun darkroom-guess-margins (window)
|
||||
"Guess suitable margins for `darkroom-margins'.
|
||||
If in suitable conditions, collect some statistics about the
|
||||
buffer's line lengths, and apply a heuristic to figure out how
|
||||
wide to set the margins, comparing it to WINDOW's width in
|
||||
columns. If the buffer's paragraphs are mostly filled to
|
||||
`fill-column', margins should center it on the window, otherwise,
|
||||
the margins specified in `darkroom-margins-if-failed-guess'.
|
||||
|
||||
In any of these conditions,`darkroom-margins-if-failed-guess' is
|
||||
also used:
|
||||
|
||||
* if `visual-line-mode' is on;
|
||||
* if `variable-pitch-mode' is on;
|
||||
* if the buffer is empty.
|
||||
|
||||
For testing purposes, WINDOW can also be an integer number which
|
||||
is a width in columns, in which case it will be used instead of a
|
||||
window's geometry."
|
||||
(if (or visual-line-mode
|
||||
(and buffer-face-mode
|
||||
(eq 'variable-pitch buffer-face-mode-face))
|
||||
(= (point-min) (point-max)))
|
||||
darkroom-margins-if-failed-guess
|
||||
(let* ((window-width-info (if (integerp window)
|
||||
window
|
||||
(darkroom--window-width window)))
|
||||
(window-width (car window-width-info))
|
||||
(scaled-char-width (cdr window-width-info))
|
||||
(top-quartile-avg
|
||||
(or darkroom--guess-margins-statistics-cache
|
||||
(set
|
||||
(make-local-variable 'darkroom--guess-margins-statistics-cache)
|
||||
(let* ((line-widths
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(cl-loop for start = (point)
|
||||
while (search-forward "\n"
|
||||
20000
|
||||
'no-error)
|
||||
for width = (truncate
|
||||
(car
|
||||
(window-text-pixel-size
|
||||
window
|
||||
start (1- (point))))
|
||||
scaled-char-width)
|
||||
unless (zerop width)
|
||||
collect width)))
|
||||
(n4 (max 1 (/ (length line-widths) 4))))
|
||||
(/ (apply '+ (cl-subseq (sort line-widths '>) 0 n4)) n4))))))
|
||||
(cond
|
||||
((> top-quartile-avg
|
||||
window-width)
|
||||
(message "Long lines detected. Consider turning on `visual-line-mode'")
|
||||
darkroom-margins-if-failed-guess)
|
||||
((> top-quartile-avg (* 0.9 fill-column))
|
||||
;; calculate margins so that `fill-column' + 1 colums are
|
||||
;; centered on the window.
|
||||
;;
|
||||
(let ((margin (truncate (* (- window-width (1+ fill-column))
|
||||
(/ (float scaled-char-width)
|
||||
(frame-char-width)))
|
||||
2)))
|
||||
(if darkroom-verbose
|
||||
(message "Choosing %s-wide margins based on fill-column %s"
|
||||
margin fill-column))
|
||||
(cons margin margin)))
|
||||
(t
|
||||
darkroom-margins-if-failed-guess)))))
|
||||
|
||||
(defun darkroom--compute-margins (window)
|
||||
"From `darkroom-margins', computes desired margins for WINDOW."
|
||||
(let ((darkroom-margins
|
||||
(if (functionp darkroom-margins)
|
||||
(funcall darkroom-margins window)
|
||||
darkroom-margins)))
|
||||
(cond ((consp darkroom-margins)
|
||||
darkroom-margins)
|
||||
((and (floatp darkroom-margins)
|
||||
(< darkroom-margins 1))
|
||||
(let ((delta (darkroom--float-to-columns darkroom-margins)))
|
||||
(cons delta delta)))
|
||||
(t
|
||||
(error "Illegal value in `darkroom-margins'")))))
|
||||
|
||||
(defun darkroom--float-to-columns (f)
|
||||
(ceiling (* (let ((edges (window-edges)))
|
||||
(- (nth 2 edges) (nth 0 edges)))
|
||||
f)))
|
||||
|
||||
(defvar darkroom--margin-factor 1
|
||||
"Buffer local factor affecting `darkroom--set-margins'")
|
||||
|
||||
(defun darkroom--set-margins ()
|
||||
"Set darkroom margins for currently selected window"
|
||||
(let* ((window-configuration-change-hook nil)
|
||||
(window (selected-window))
|
||||
(margins (darkroom--compute-margins window)))
|
||||
;; See description of
|
||||
;; `fringes-outside-margins' for the reason
|
||||
;; for this apparent noop
|
||||
(set-window-buffer window (current-buffer))
|
||||
(set-window-margins window
|
||||
(round
|
||||
(* darkroom--margin-factor
|
||||
(car margins)))
|
||||
(round
|
||||
(* darkroom--margin-factor
|
||||
(cdr margins))))))
|
||||
|
||||
(defun darkroom--reset-margins ()
|
||||
"Reset darkroom margins for currently selected window."
|
||||
(set-window-margins (selected-window) 0 0))
|
||||
|
||||
(defun darkroom-increase-margins (increment)
|
||||
"Increase darkroom margins by INCREMENT."
|
||||
(interactive (list darkroom-margin-increment))
|
||||
(set (make-local-variable 'darkroom--margin-factor)
|
||||
(* darkroom--margin-factor (+ 1 increment)))
|
||||
(mapc #'(lambda (w)
|
||||
(with-selected-window w
|
||||
(darkroom--set-margins)))
|
||||
(get-buffer-window-list (current-buffer))))
|
||||
|
||||
(defun darkroom-decrease-margins (decrement)
|
||||
"Decrease darkroom margins by DECREMENT."
|
||||
(interactive (list darkroom-margin-increment))
|
||||
(darkroom-increase-margins (- decrement)))
|
||||
|
||||
(defvar darkroom-mode-map
|
||||
(let ((map (make-sparse-keymap)))
|
||||
(define-key map (kbd "C-M-+") 'darkroom-increase-margins)
|
||||
(define-key map (kbd "C-M--") 'darkroom-decrease-margins)
|
||||
map))
|
||||
|
||||
(defconst darkroom--saved-variables
|
||||
'(mode-line-format
|
||||
header-line-format
|
||||
fringes-outside-margins)
|
||||
"Variables saved in `darkroom--saved-state'")
|
||||
|
||||
(defvar darkroom--saved-state nil
|
||||
"Saved state before `darkroom-mode' is turned on.
|
||||
Alist of (VARIABLE . BEFORE-VALUE)")
|
||||
|
||||
;; (defvar darkroom--saved-text-scale-mode-amount nil
|
||||
;; "Text scale before `darkroom-mode' is turned on.")
|
||||
|
||||
(defun darkroom--enter (&optional just-margins)
|
||||
"Save current state and enter darkroom for the current buffer.
|
||||
With optional JUST-MARGINS, just set the margins."
|
||||
(unless just-margins
|
||||
(setq darkroom--saved-state
|
||||
(mapcar #'(lambda (sym)
|
||||
(cons sym (buffer-local-value sym (current-buffer))))
|
||||
darkroom--saved-variables))
|
||||
(setq mode-line-format nil
|
||||
header-line-format nil
|
||||
fringes-outside-margins darkroom-fringes-outside-margins)
|
||||
(text-scale-increase darkroom-text-scale-increase))
|
||||
(mapc #'(lambda (w)
|
||||
(with-selected-window w
|
||||
(darkroom--set-margins)))
|
||||
(get-buffer-window-list (current-buffer))))
|
||||
|
||||
(defun darkroom--leave ()
|
||||
"Undo the effects of `darkroom--enter'."
|
||||
(mapc #'(lambda (pair)
|
||||
(set (make-local-variable (car pair)) (cdr pair)))
|
||||
darkroom--saved-state)
|
||||
(setq darkroom--saved-state nil)
|
||||
(text-scale-mode -1)
|
||||
(mapc #'(lambda (w)
|
||||
(with-selected-window w
|
||||
(darkroom--reset-margins)))
|
||||
(get-buffer-window-list (current-buffer))))
|
||||
|
||||
(defun darkroom--enter-or-leave ()
|
||||
"Enter or leave darkroom according to window configuration."
|
||||
(cond ((= (count-windows) 1)
|
||||
(darkroom--enter darkroom--saved-state))
|
||||
(darkroom--saved-state
|
||||
(darkroom--leave))
|
||||
(t
|
||||
;; for clarity, don't do anything
|
||||
)))
|
||||
|
||||
(declare-function darkroom-tentative-mode "darkroom" t)
|
||||
|
||||
;;;###autoload
|
||||
(define-minor-mode darkroom-mode
|
||||
"Remove visual distractions and focus on writing. When this
|
||||
mode is active, everything but the buffer's text is elided from
|
||||
view. The buffer margins are set so that text is centered on
|
||||
screen. Text size is increased (display engine allowing) by
|
||||
`darkroom-text-scale-increase'." nil nil nil
|
||||
(when darkroom-tentative-mode
|
||||
(display-warning
|
||||
'darkroom
|
||||
(concat "Turning off `darkroom-tentative-mode' first. "
|
||||
"It doesn't go with `darkroom-mode'.")
|
||||
(let ((darkroom-mode nil))
|
||||
(darkroom-tentative-mode -1))))
|
||||
(cond (darkroom-mode
|
||||
(darkroom--enter)
|
||||
(add-hook 'window-configuration-change-hook 'darkroom--set-margins
|
||||
t t))
|
||||
(t
|
||||
(darkroom--leave)
|
||||
(remove-hook 'window-configuration-change-hook 'darkroom--set-margins
|
||||
t))))
|
||||
|
||||
;;;###autoload
|
||||
(define-minor-mode darkroom-tentative-mode
|
||||
"Enters `darkroom-mode' when all other windows are deleted."
|
||||
nil " Room" darkroom-mode-map
|
||||
;; always begin by removing the hook
|
||||
;;
|
||||
(remove-hook 'window-configuration-change-hook
|
||||
'darkroom--enter-or-leave 'local)
|
||||
(when darkroom-mode
|
||||
(display-warning
|
||||
'darkroom
|
||||
(concat "Turning off `darkroom-mode' first. "
|
||||
"It doesn't go with `darkroom-tentative-mode'.")
|
||||
(let ((darkroom-tentative-mode nil))
|
||||
(darkroom-mode -1))))
|
||||
;; turn darkroom on or off according to window state
|
||||
;;
|
||||
(cond (darkroom-tentative-mode
|
||||
;; re-add the hook when we are turning ourselves on
|
||||
;;
|
||||
(add-hook 'window-configuration-change-hook
|
||||
'darkroom--enter-or-leave 'append 'local)
|
||||
;; call this right away if we're supposed to turn darkroom on
|
||||
;; immediately.
|
||||
;;
|
||||
(darkroom--enter-or-leave))
|
||||
(t
|
||||
(darkroom--leave))))
|
||||
|
||||
;;;; ChangeLog:
|
||||
|
||||
;; 2019-03-15 João Távora <joaotavora@gmail.com>
|
||||
;;
|
||||
;; Update packages/darkroom from upstream
|
||||
;;
|
||||
;; Merge subtree commit '30d1b83a8cf7abfad8281f5d063e3316338bdfa4'
|
||||
;;
|
||||
;; 2015-03-28 João Távora <joaotavora@gmail.com>
|
||||
;;
|
||||
;; Update packages/darkroom by merging its external subtree
|
||||
;;
|
||||
;; 2014-12-19 João Távora <joaotavora@gmail.com>
|
||||
;;
|
||||
;; Add packages/darkroom by merging its upstream subtree
|
||||
;;
|
||||
;; * externals-list ("darkroom"): New subtree entry
|
||||
;;
|
||||
|
||||
|
||||
|
||||
(provide 'darkroom)
|
||||
;;; darkroom.el ends here
|
Binary file not shown.
|
@ -1,20 +0,0 @@
|
|||
The main entrypoints to this extension are two minor modes:
|
||||
|
||||
M-x darkroom-mode
|
||||
M-x darkroom-tentative-mode
|
||||
|
||||
`darkroom-mode' makes visual distractions disappear: the
|
||||
mode-line is temporarily elided, text is enlarged and margins are
|
||||
adjusted so that it's centered on the window.
|
||||
|
||||
`darkroom-tentative-mode' is similar, but it doesn't immediately
|
||||
turn-on `darkroom-mode', unless the current buffer lives in the
|
||||
sole window of the Emacs frame (i.e. all other windows are
|
||||
deleted). Whenever the frame is split to display more windows and
|
||||
more buffers, the buffer exits `darkroom-mode'. Whenever they are
|
||||
deleted, the buffer re-enters `darkroom-mode'.
|
||||
|
||||
Personally, I always use `darkroom-tentative-mode'.
|
||||
|
||||
See also the customization options `darkroom-margins' and
|
||||
`darkroom-fringes-outside-margins', which affect both modes.
|
|
@ -1,34 +0,0 @@
|
|||
;;; dart-mode-autoloads.el --- automatically extracted autoloads
|
||||
;;
|
||||
;;; Code:
|
||||
|
||||
(add-to-list 'load-path (directory-file-name
|
||||
(or (file-name-directory #$) (car load-path))))
|
||||
|
||||
|
||||
;;;### (autoloads nil "dart-mode" "dart-mode.el" (0 0 0 0))
|
||||
;;; Generated autoloads from dart-mode.el
|
||||
(add-to-list 'auto-mode-alist '("\\.dart\\'" . dart-mode))
|
||||
|
||||
(autoload 'dart-mode "dart-mode" "\
|
||||
Major mode for editing Dart files.
|
||||
|
||||
The hook `dart-mode-hook' is run with no args at mode
|
||||
initialization.
|
||||
|
||||
Key bindings:
|
||||
\\{dart-mode-map}
|
||||
|
||||
\(fn)" t nil)
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "dart-mode" '("dart-")))
|
||||
|
||||
;;;***
|
||||
|
||||
;; Local Variables:
|
||||
;; version-control: never
|
||||
;; no-byte-compile: t
|
||||
;; no-update-autoloads: t
|
||||
;; coding: utf-8
|
||||
;; End:
|
||||
;;; dart-mode-autoloads.el ends here
|
|
@ -1,2 +0,0 @@
|
|||
;;; -*- no-byte-compile: t -*-
|
||||
(define-package "dart-mode" "20190827.2102" "Major mode for editing Dart files" '((emacs "24.3")) :commit "04fcd649f19d49390079fbf2920a10bf37f6a634" :keywords '("languages") :authors '(("Brady Trainor" . "mail@bradyt.net")) :maintainer '("Brady Trainor" . "mail@bradyt.net") :url "https://github.com/bradyt/dart-mode")
|
|
@ -1,625 +0,0 @@
|
|||
;;; dart-mode.el --- Major mode for editing Dart files -*- lexical-binding: t; -*-
|
||||
|
||||
;; Author: Brady Trainor <mail@bradyt.net>
|
||||
;; URL: https://github.com/bradyt/dart-mode
|
||||
;; Package-Version: 20190827.2102
|
||||
;; Version: 1.0.4
|
||||
;; Package-Requires: ((emacs "24.3"))
|
||||
;; Keywords: languages
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Major mode for editing Dart files.
|
||||
|
||||
;; Provides basic syntax highlighting and indentation.
|
||||
|
||||
;;; Code:
|
||||
|
||||
;;; Configuration
|
||||
|
||||
(defvar dart-mode-map (make-sparse-keymap)
|
||||
"Keymap used in dart-mode buffers.")
|
||||
(define-key dart-mode-map (kbd "<backtab>") 'dart-dedent-simple)
|
||||
(define-key dart-mode-map (kbd "C-c C-i") 'indent-according-to-mode)
|
||||
|
||||
|
||||
;;; Indentation
|
||||
|
||||
(defcustom dart-indent-trigger-commands
|
||||
'(indent-for-tab-command yas-expand yas/expand dart-dedent-simple)
|
||||
"Commands that might trigger a `dart-indent-line' call."
|
||||
:type '(repeat symbol)
|
||||
:group 'dart)
|
||||
|
||||
(defun dart-indent-line-function ()
|
||||
"`indent-line-function' for Dart mode.
|
||||
When the variable `last-command' is equal to one of the symbols
|
||||
inside `dart-indent-trigger-commands' it cycles possible
|
||||
indentation levels from right to left."
|
||||
(if (and (memq this-command dart-indent-trigger-commands)
|
||||
(eq last-command this-command))
|
||||
(dart-indent-simple)
|
||||
(dart-indent-line-relative)))
|
||||
|
||||
(defun dart-indent-simple (&optional backwards)
|
||||
(interactive)
|
||||
(save-excursion
|
||||
(indent-line-to
|
||||
(max 0 (indent-next-tab-stop (current-indentation) backwards))))
|
||||
(when (< (current-column) (current-indentation))
|
||||
(back-to-indentation)))
|
||||
|
||||
(defun dart-dedent-simple ()
|
||||
(interactive)
|
||||
(dart-indent-simple 'backwards))
|
||||
|
||||
(defun dart-depth-of-line ()
|
||||
(save-excursion
|
||||
(back-to-indentation)
|
||||
(let ((depth (car (syntax-ppss))))
|
||||
(when (and (char-after)
|
||||
(= (char-syntax (char-after)) ?\)))
|
||||
(while (and (char-after)
|
||||
(/= (char-syntax (char-after)) ?\()
|
||||
(/= (char-after) ?\C-j))
|
||||
(when (= (char-syntax (char-after)) ?\))
|
||||
(setq depth (1- depth)))
|
||||
(forward-char)))
|
||||
depth)))
|
||||
|
||||
(defun dart-indent-line-relative ()
|
||||
(let ((curr-depth (dart-depth-of-line))
|
||||
prev-line
|
||||
prev-depth
|
||||
prev-indent)
|
||||
(save-excursion
|
||||
(beginning-of-line)
|
||||
(catch 'done
|
||||
(while t
|
||||
(when (= (point) 1)
|
||||
(throw 'done t))
|
||||
(forward-line -1)
|
||||
(unless (looking-at (rx (and bol (zero-or-more space) eol)))
|
||||
(setq prev-line t)
|
||||
(setq prev-indent (current-indentation))
|
||||
(setq prev-depth (dart-depth-of-line))
|
||||
(throw 'done t)))))
|
||||
(save-excursion
|
||||
(if prev-line
|
||||
(indent-line-to (max 0 (+ prev-indent
|
||||
(* (- curr-depth prev-depth)
|
||||
tab-width))))
|
||||
(indent-line-to 0)))
|
||||
(when (< (current-column) (current-indentation))
|
||||
(back-to-indentation))))
|
||||
|
||||
|
||||
;;; Fontification
|
||||
|
||||
(defvar dart--file-directives
|
||||
'("as" "deferred" "export" "hide" "import" "library" "of" "part"
|
||||
"show"))
|
||||
|
||||
(defvar dart--builtins
|
||||
;; ECMA 408; Section: Identifier Reference
|
||||
;; "Built-in identifiers"
|
||||
'("abstract" "as" "covariant" "deferred" "dynamic" "export"
|
||||
"external" "factory" "Function" "get" "implements" "import"
|
||||
"interface" "library" "mixin" "operator" "part" "set" "static"
|
||||
"typedef"))
|
||||
|
||||
(defvar dart--keywords
|
||||
;; ECMA 408; Section: Reserved Words
|
||||
'("assert" "break" "case" "catch" "class" "const" "continue"
|
||||
"default" "do" "else" "enum" "extends" "final" "finally" "for"
|
||||
"if" "in" "is" "new" "rethrow" "return" "super" "switch" "this"
|
||||
"throw" "try" "var" "while" "with"))
|
||||
|
||||
(defvar dart--types '("bool" "double" "int" "num" "void"))
|
||||
|
||||
(defvar dart--constants '("false" "null" "true"))
|
||||
|
||||
(defvar dart--async-keywords-re (rx word-start
|
||||
(or "async" "await" "sync" "yield")
|
||||
word-end
|
||||
(zero-or-one ?*)))
|
||||
|
||||
(defvar dart--number-re (rx symbol-start
|
||||
(zero-or-one ?-)
|
||||
(group (or (and (one-or-more digit)
|
||||
(zero-or-one
|
||||
(and ?. (one-or-more digit))))
|
||||
(and ?. (one-or-more digit)))
|
||||
(zero-or-one (and (or ?e ?E)
|
||||
(zero-or-one (or ?+ ?-))
|
||||
(one-or-more digit))))))
|
||||
|
||||
(defvar dart--hex-number-re (rx symbol-start
|
||||
(zero-or-one ?-)
|
||||
(group (or "0x" "0X")
|
||||
(one-or-more (any (?a . ?f)
|
||||
(?A . ?F)
|
||||
digit)))))
|
||||
|
||||
(defvar dart--operator-declaration-re (rx "operator"
|
||||
(one-or-more space)
|
||||
(group
|
||||
(one-or-more (not (any ?\())))))
|
||||
|
||||
(eval-and-compile (defun dart--identifier (&optional case)
|
||||
`(and (or word-start symbol-start)
|
||||
(zero-or-more (any ?$ ?_))
|
||||
,(if case
|
||||
case
|
||||
'alpha)
|
||||
(zero-or-more (or ?$ ?_ alnum)))))
|
||||
|
||||
(defvar dart--metadata-re (rx ?@ (eval (dart--identifier))))
|
||||
|
||||
(defvar dart--types-re (rx (eval (dart--identifier 'upper))))
|
||||
|
||||
(defvar dart--constants-re (rx (and word-start
|
||||
upper
|
||||
(>= 2 (or upper ?_))
|
||||
word-end)))
|
||||
|
||||
(defun dart--string-interpolation-id-func (limit)
|
||||
"Font-lock matcher for string interpolation identifiers.
|
||||
|
||||
These have the form $variableName.
|
||||
|
||||
Can fontify entire match with group 0, or using group 1 for sigil,
|
||||
group 2 for variableName."
|
||||
(catch 'result
|
||||
(let (data end syntax)
|
||||
(while (re-search-forward (rx (group ?$)
|
||||
(group (zero-or-more ?_)
|
||||
lower
|
||||
(zero-or-more (or ?_ alnum))))
|
||||
limit t)
|
||||
(setq data (match-data))
|
||||
(setq end (match-end 2))
|
||||
(setq syntax (syntax-ppss))
|
||||
;; Check that we are in a string and not in a raw string
|
||||
(when (and (nth 3 syntax)
|
||||
(or (= (nth 8 syntax) 1)
|
||||
(not (eq (char-before (nth 8 syntax)) ?r))))
|
||||
(set-match-data data)
|
||||
(goto-char end)
|
||||
(throw 'result t))
|
||||
(when end
|
||||
(goto-char end)))
|
||||
(throw 'result nil))))
|
||||
|
||||
(defun dart--string-interpolation-exp-func (limit)
|
||||
"Font-lock matcher for string interpolation expressions.
|
||||
|
||||
These have the form ${expression}.
|
||||
|
||||
Can fontify entire match with group 0, or using group 1 for sigil,
|
||||
groups 2 and 4 for curly brackets, and 3 for contents."
|
||||
(catch 'result
|
||||
(let (sigil beg open close end depth)
|
||||
;; Loop and put point after ${
|
||||
(while (and (search-forward "${" limit t)
|
||||
;; Check that we are in a string and not in a raw string
|
||||
(save-excursion
|
||||
(and (nth 3 (syntax-ppss))
|
||||
(not (eq (char-before (nth 8 (syntax-ppss))) ?r)))))
|
||||
;; "a string with ${someInterpolation + aValue} inside of it."
|
||||
;; ^^^ ^^
|
||||
;; ||| ||
|
||||
;; sigil -+|+- open close -++- end
|
||||
;; +- beg
|
||||
(setq open (point))
|
||||
(setq beg (- open 1))
|
||||
(setq sigil (- open 2))
|
||||
(setq depth 1)
|
||||
;; Move forward until limit, while depth is positive and we
|
||||
;; are inside string.
|
||||
(while (and (> depth 0)
|
||||
(< (point) limit)
|
||||
(nth 3 (syntax-ppss)))
|
||||
(setq depth (+ depth (pcase (char-after)
|
||||
(?\{ 1)
|
||||
(?\} -1)
|
||||
(_ 0))))
|
||||
(forward-char))
|
||||
(setq end (point))
|
||||
;; If depth is zero, we have found a closing } within string
|
||||
;; and before limit. Set `match-data', `point', and return `t'.
|
||||
(when (= depth 0)
|
||||
(setq close (1- end))
|
||||
(set-match-data (list sigil end
|
||||
sigil beg
|
||||
beg open
|
||||
open close
|
||||
close end))
|
||||
(goto-char end)
|
||||
(throw 'result t))
|
||||
;; If the candidate did not meet criteria, put point at end
|
||||
;; and search again.
|
||||
(goto-char end))
|
||||
;; When there are no more candidate "${", return nil.
|
||||
(throw 'result nil))))
|
||||
|
||||
(defun dart--function-declaration-func (limit)
|
||||
"Font-lock matcher function for function declarations.
|
||||
|
||||
Matches function declarations before LIMIT that look like,
|
||||
|
||||
\"lowercaseIdentifier([...]) [[a]sync[*], {, =>]\"
|
||||
|
||||
For example, \"main\" in \"void main() async\" would be matched."
|
||||
(catch 'result
|
||||
(let (beg end)
|
||||
(while (re-search-forward
|
||||
(rx (group (eval (dart--identifier 'lower))) ?\() limit t)
|
||||
(setq beg (match-beginning 1))
|
||||
(setq end (match-end 1))
|
||||
(condition-case nil
|
||||
(progn
|
||||
(up-list)
|
||||
(when (looking-at (rx (one-or-more space)
|
||||
(or "async" "async*" "sync*" "{" "=>")))
|
||||
(set-match-data (list beg end))
|
||||
(goto-char end)
|
||||
(throw 'result t)))
|
||||
(scan-error nil))
|
||||
(goto-char end))
|
||||
(throw 'result nil))))
|
||||
|
||||
(defun dart--abstract-method-func (limit)
|
||||
"Font-lock matcher function for abstract methods.
|
||||
|
||||
Matches function declarations before LIMIT that look like,
|
||||
|
||||
\" [^ ][^=]* lowercaseIdentifier([...]);\"
|
||||
|
||||
For example, \"compareTo\" in \" int compareTo(num other);\" would be
|
||||
matched."
|
||||
(catch 'result
|
||||
(let (beg end)
|
||||
(while (re-search-forward
|
||||
(rx (and (not (any ?\.)) (group (eval (dart--identifier 'lower)))) ?\() limit t)
|
||||
(setq beg (match-beginning 1))
|
||||
(setq end (match-end 1))
|
||||
(condition-case nil
|
||||
(progn
|
||||
(up-list)
|
||||
(when (and (< (point) (point-max))
|
||||
(= (char-after (point)) ?\;))
|
||||
(goto-char beg)
|
||||
(back-to-indentation)
|
||||
(when (and (= (current-column) 2)
|
||||
(not (looking-at "return"))
|
||||
(string-match-p
|
||||
" " (buffer-substring-no-properties
|
||||
(point) beg))
|
||||
(not (string-match-p
|
||||
"=" (buffer-substring-no-properties
|
||||
(point) beg))))
|
||||
(goto-char end)
|
||||
(set-match-data (list beg end))
|
||||
(throw 'result t))))
|
||||
(scan-error nil))
|
||||
(goto-char end)))
|
||||
(throw 'result nil)))
|
||||
|
||||
(defun dart--declared-identifier-func (limit)
|
||||
"Font-lock matcher function for declared identifiers.
|
||||
|
||||
Matches declared identifiers before LIMIT that look like,
|
||||
|
||||
\"finalConstVarOrType lowercaseIdentifier\"
|
||||
|
||||
For example, \"height\" in \"const int height\" would be matched."
|
||||
(catch 'result
|
||||
(let (beg end)
|
||||
(while (re-search-forward
|
||||
(rx
|
||||
(and (group (or (or "const" "final"
|
||||
"bool" "double" "dynamic" "int" "num" "void"
|
||||
"var"
|
||||
"get" "set")
|
||||
(eval (dart--identifier 'upper)))
|
||||
(zero-or-more ?>))
|
||||
(one-or-more (or space ?\C-j))
|
||||
(group (eval (dart--identifier 'lower)))
|
||||
(not (any ?\( alnum ?$ ?_))))
|
||||
limit t)
|
||||
(setq beg (match-beginning 2))
|
||||
(setq end (match-end 2))
|
||||
;; Check for false positives
|
||||
(when (not (member (match-string 2)
|
||||
'("bool" "double" "dynamic" "int" "num" "void"
|
||||
"var"
|
||||
"get" "set")))
|
||||
(goto-char end)
|
||||
(unless (nth 3 (syntax-ppss))
|
||||
(set-match-data (list beg end))
|
||||
(throw 'result t)))
|
||||
(goto-char (match-end 1)))
|
||||
(throw 'result nil))))
|
||||
|
||||
(defun dart--in-parenthesized-expression-or-formal-parameter-list-p ()
|
||||
"Returns `t' if `point' is in parentheses, otherwise `nil'.
|
||||
|
||||
In particular, parenthesized expressions or formal parameter lists."
|
||||
(save-excursion
|
||||
(catch 'result
|
||||
;; Attempt to jump out of parentheses.
|
||||
(condition-case nil
|
||||
(backward-up-list)
|
||||
(scan-error (throw 'result nil)))
|
||||
;; If we've only jumped out of optional or named section of
|
||||
;; formal parameters, try to jump again.
|
||||
(when (member (char-after (point)) '(?\[ ?\{))
|
||||
(condition-case nil
|
||||
(backward-up-list)
|
||||
(scan-error (throw 'result nil))))
|
||||
(throw 'result (= (char-after (point)) ?\()))))
|
||||
|
||||
(defun dart--declared-identifier-anchor-func (limit)
|
||||
"Font-lock matcher for declared identifier.
|
||||
|
||||
Uses `dart--declared-identifier-func' to find candidates before
|
||||
LIMIT, and checks that they are not in parentheses.
|
||||
|
||||
This matcher is an anchor to match multiple identifiers in a
|
||||
single variable declaration. From ECMA-408,
|
||||
|
||||
variableDeclaration:
|
||||
declaredIdentifier (', ' identifier)*
|
||||
;
|
||||
|
||||
After this function sets anchor, font-lock will use the function
|
||||
`dart--declared-identifier-next-func' to find subsequent
|
||||
identifiers."
|
||||
(catch 'result
|
||||
(let (data)
|
||||
(while (dart--declared-identifier-func limit)
|
||||
(setq data (match-data))
|
||||
(unless (dart--in-parenthesized-expression-or-formal-parameter-list-p)
|
||||
(set-match-data data)
|
||||
(goto-char (match-end 0))
|
||||
(throw 'result t))
|
||||
(goto-char (match-end 0)))
|
||||
(throw 'result nil))))
|
||||
|
||||
(defun dart--declared-identifier-next-func (limit)
|
||||
"Font-lock matcher for subsequent identifiers.
|
||||
|
||||
For use after `dart--declared-identifier-anchor-func' sets
|
||||
anchor, this function will look for subsequent identifers to
|
||||
fontify as declared variables. From ECMA-408,
|
||||
|
||||
variableDeclaration:
|
||||
declaredIdentifier (', ' identifier)*
|
||||
;"
|
||||
(catch 'result
|
||||
(let ((depth (car (syntax-ppss))))
|
||||
(while t
|
||||
(cond
|
||||
;; If point is followed by semi-colon, we are done.
|
||||
((or (> (point) limit)
|
||||
(= (char-after (point)) ?\;)
|
||||
(< (car (syntax-ppss)) depth))
|
||||
(throw 'result nil))
|
||||
;; If point is followed by comma, and we are still at same
|
||||
;; depth, then attempt to match another identifier, otherwise
|
||||
;; return nil.
|
||||
((and (= (char-after (point)) ?\x2c) ; ?,
|
||||
(= (car (syntax-ppss)) depth))
|
||||
(if (looking-at (rx ?\x2c
|
||||
(one-or-more space)
|
||||
(group (eval (dart--identifier 'lower)))))
|
||||
(progn (set-match-data (list (match-beginning 1)
|
||||
(match-end 1)))
|
||||
(goto-char (match-end 0))
|
||||
(throw 'result t))
|
||||
(throw 'result nil)))
|
||||
;; Otherwise, if we are still before `point-max' (shouldn't
|
||||
;; this be `limit'? May be a bad attempt to deal with
|
||||
;; multiline searches. Should research how this is done with
|
||||
;; font-lock.), move forward.
|
||||
((< (point) (point-max))
|
||||
(forward-char))
|
||||
;; Otherwise, return nil.
|
||||
(t (throw 'result nil)))))))
|
||||
|
||||
(defun dart--anonymous-function-matcher (limit)
|
||||
"Font-lock matcher for start of anonymous functions.
|
||||
|
||||
Looks for opening parenthesis, tries to jump to opening
|
||||
parenthesis, ensure it is not preceded by for, while, etc. Then
|
||||
tries to jump to closing parenthesis and check if followed by \"
|
||||
{\" or \" =>\".
|
||||
|
||||
Used with `dart--untyped-parameter-anchored-matcher' to fontify
|
||||
untyped parameters. For example, in
|
||||
|
||||
(untypedParameter) => untypedParameter.length"
|
||||
(catch 'result
|
||||
(let (beg end)
|
||||
(while (search-forward "(" limit t)
|
||||
(setq beg (match-beginning 0))
|
||||
(setq end (match-end 0))
|
||||
(unless (looking-back (rx (or (and (or "do" "for" "if" "switch" "while")
|
||||
space)
|
||||
"super")
|
||||
?\()
|
||||
(point-at-bol))
|
||||
(condition-case nil
|
||||
(up-list)
|
||||
(scan-error (throw 'result nil)))
|
||||
(when (looking-at (rx space (or ?\{ "=>")))
|
||||
(set-match-data (list beg end))
|
||||
(goto-char end)
|
||||
(throw 'result t))
|
||||
(goto-char end)))
|
||||
(throw 'result nil))))
|
||||
|
||||
(defun dart--untyped-parameter-anchored-matcher (limit)
|
||||
"Font-lock anchored-matcher for untyped parameters.
|
||||
|
||||
Searches forward for for lowercase idenitifer and ensures depth
|
||||
is still same.
|
||||
|
||||
Used with `dart--anonymous-function-matcher' to fontify
|
||||
untyped parameters. For example, in
|
||||
|
||||
(untypedParameter) => untypedParameter.length"
|
||||
(let (beg end)
|
||||
(catch 'result
|
||||
(if (equal (char-after) ?\))
|
||||
(throw 'result nil))
|
||||
(let ((depth (car (syntax-ppss))))
|
||||
(while (re-search-forward
|
||||
(rx (and (group (or (one-or-more (char ?_))
|
||||
(eval (dart--identifier 'lower))))
|
||||
(or ?, ?\)))))
|
||||
(setq beg (match-beginning 1))
|
||||
(setq end (match-end 1))
|
||||
(goto-char end)
|
||||
(if (or (> (point) limit)
|
||||
(< (car (syntax-ppss)) depth))
|
||||
(throw 'result nil)
|
||||
(set-match-data (list beg end))
|
||||
(throw 'result t))))
|
||||
(throw 'result nil))))
|
||||
|
||||
(defun dart--get-point-at-end-of-list ()
|
||||
(let (pt)
|
||||
(save-excursion
|
||||
(up-list)
|
||||
(setq pt (point)))
|
||||
pt))
|
||||
|
||||
(defvar dart-font-lock-defaults
|
||||
'((dart-font-lock-keywords-1 dart-font-lock-keywords-1
|
||||
dart-font-lock-keywords-2
|
||||
dart-font-lock-keywords-3)))
|
||||
|
||||
(defvar dart-font-lock-keywords-1
|
||||
`((,(regexp-opt dart--file-directives 'words) . font-lock-builtin-face)
|
||||
(dart--function-declaration-func . font-lock-function-name-face)
|
||||
(,dart--operator-declaration-re . (1 font-lock-function-name-face))
|
||||
(dart--abstract-method-func . font-lock-function-name-face)))
|
||||
|
||||
(defvar dart-font-lock-keywords-2
|
||||
`(,dart--async-keywords-re
|
||||
,(regexp-opt dart--keywords 'words)
|
||||
(,(regexp-opt dart--builtins 'words) . font-lock-builtin-face)
|
||||
(,(regexp-opt dart--constants 'words) . font-lock-constant-face)
|
||||
(,dart--hex-number-re . (1 font-lock-constant-face))
|
||||
(,dart--number-re . (1 font-lock-constant-face))
|
||||
(,dart--metadata-re . font-lock-constant-face)
|
||||
(,dart--constants-re . font-lock-constant-face)
|
||||
(,(regexp-opt dart--types 'words) . font-lock-type-face)
|
||||
(,dart--types-re . font-lock-type-face)
|
||||
(dart--function-declaration-func . font-lock-function-name-face)
|
||||
(,dart--operator-declaration-re . (1 font-lock-function-name-face))
|
||||
(dart--abstract-method-func . font-lock-function-name-face)))
|
||||
|
||||
(defvar dart-font-lock-keywords-3
|
||||
(append
|
||||
dart-font-lock-keywords-2
|
||||
`((dart--declared-identifier-func . font-lock-variable-name-face)
|
||||
(dart--declared-identifier-anchor-func
|
||||
. (dart--declared-identifier-next-func
|
||||
nil
|
||||
nil
|
||||
(0 font-lock-variable-name-face)))
|
||||
(dart--anonymous-function-matcher
|
||||
. (dart--untyped-parameter-anchored-matcher
|
||||
(dart--get-point-at-end-of-list)
|
||||
nil
|
||||
(0 font-lock-variable-name-face)))
|
||||
(dart--string-interpolation-id-func (0 font-lock-variable-name-face t))
|
||||
(dart--string-interpolation-exp-func (0 font-lock-variable-name-face t)))))
|
||||
|
||||
(defun dart-syntax-propertize-function (beg end)
|
||||
"Sets syntax-table text properties for raw and/or multiline strings.
|
||||
|
||||
We use fences uniformly for consistency.
|
||||
|
||||
In raw strings, we modify backslash characters to have punctuation
|
||||
syntax rather than escape syntax.
|
||||
|
||||
String interpolation is not handled correctly yet, but the fixes to
|
||||
quote characters in multiline strings, and escape characters in raw
|
||||
strings, ensures that code outside of strings is not highlighted as
|
||||
strings."
|
||||
(goto-char beg)
|
||||
;; We rely on syntax-propertize-extend-region-functions that `beg`
|
||||
;; will be at beginning of line, but we ensure here that we are not
|
||||
;; in a string
|
||||
(while (nth 3 (syntax-ppss))
|
||||
(goto-char (nth 8 (syntax-ppss)))
|
||||
(beginning-of-line))
|
||||
;; Search for string opening
|
||||
(while (re-search-forward (rx (group (optional ?r))
|
||||
(group (or (repeat 3 ?\")
|
||||
(repeat 3 ?\')
|
||||
?\"
|
||||
?\')))
|
||||
end t)
|
||||
(let ((bos (match-beginning 2))
|
||||
(rawp (equal (match-string-no-properties 1) "r"))
|
||||
(string-delimiter (match-string-no-properties 2)))
|
||||
;; Set string fence syntax at beginning of string
|
||||
(put-text-property bos (1+ bos) 'syntax-table (string-to-syntax "|") nil)
|
||||
;; Look for the end of string delimiter, depending on rawp and
|
||||
;; string-delimiter
|
||||
;; Unless rawp, ensure an even number of backslashes
|
||||
(when (or (looking-at (concat (unless rawp (rx (zero-or-more ?\\ ?\\)))
|
||||
string-delimiter))
|
||||
(re-search-forward (concat (unless rawp (rx (not (any ?\\)) (zero-or-more ?\\ ?\\)))
|
||||
string-delimiter)
|
||||
end t))
|
||||
(let ((eos (match-end 0)))
|
||||
;; Set end of string fence delimiter
|
||||
(put-text-property (1- eos) eos 'syntax-table (string-to-syntax "|") nil)
|
||||
;; For all strings, remove fence property between fences
|
||||
;; For raw strings, set all backslashes to punctuation syntax
|
||||
(dolist (pt (number-sequence (1+ bos) (- eos 2)))
|
||||
(when (equal (get-text-property pt 'syntax-table) (string-to-syntax "|"))
|
||||
(remove-text-properties pt (1+ pt) 'syntax-table))
|
||||
(when (and rawp (equal (char-after pt) ?\\))
|
||||
(put-text-property pt (1+ pt) 'syntax-table (string-to-syntax ".") nil)))
|
||||
(goto-char eos))))))
|
||||
|
||||
|
||||
;;; Initialization
|
||||
|
||||
;;;###autoload (add-to-list 'auto-mode-alist '("\\.dart\\'" . dart-mode))
|
||||
|
||||
;;;###autoload
|
||||
(define-derived-mode dart-mode prog-mode "Dart"
|
||||
"Major mode for editing Dart files.
|
||||
|
||||
The hook `dart-mode-hook' is run with no args at mode
|
||||
initialization.
|
||||
|
||||
Key bindings:
|
||||
\\{dart-mode-map}"
|
||||
(modify-syntax-entry ?/ "_ 124b")
|
||||
(modify-syntax-entry ?* ". 23")
|
||||
(modify-syntax-entry ?\n "> b")
|
||||
(modify-syntax-entry ?\' "\"")
|
||||
(modify-syntax-entry ?\> ".")
|
||||
(modify-syntax-entry ?\< ".")
|
||||
(setq-local electric-indent-chars '(?\n ?\) ?\] ?\}))
|
||||
(setq-local comment-start "//")
|
||||
(setq-local comment-end "")
|
||||
(setq fill-column 80)
|
||||
(setq font-lock-defaults dart-font-lock-defaults)
|
||||
(setq-local indent-line-function 'dart-indent-line-function)
|
||||
(setq indent-tabs-mode nil)
|
||||
(setq tab-width 2)
|
||||
(setq-local syntax-propertize-function 'dart-syntax-propertize-function))
|
||||
|
||||
(provide 'dart-mode)
|
||||
|
||||
;;; dart-mode.el ends here
|
Binary file not shown.
|
@ -1,3 +0,0 @@
|
|||
Major mode for editing Dart files.
|
||||
|
||||
Provides basic syntax highlighting and indentation.
|
|
@ -1,31 +0,0 @@
|
|||
;;; dart-server-autoloads.el --- automatically extracted autoloads
|
||||
;;
|
||||
;;; Code:
|
||||
|
||||
(add-to-list 'load-path (directory-file-name
|
||||
(or (file-name-directory #$) (car load-path))))
|
||||
|
||||
|
||||
;;;### (autoloads nil "dart-server" "dart-server.el" (0 0 0 0))
|
||||
;;; Generated autoloads from dart-server.el
|
||||
|
||||
(autoload 'dart-server "dart-server" "\
|
||||
Toggle Dart-Server mode on or off.
|
||||
With a prefix argument ARG, enable Dart-Server mode if ARG is
|
||||
positive, and disable it otherwise. If called from Lisp, enable
|
||||
the mode if ARG is omitted or nil, and toggle it if ARG is `toggle'.
|
||||
\\{dart-server-map}
|
||||
|
||||
\(fn &optional ARG)" t nil)
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "dart-server" '("dart-server-")))
|
||||
|
||||
;;;***
|
||||
|
||||
;; Local Variables:
|
||||
;; version-control: never
|
||||
;; no-byte-compile: t
|
||||
;; no-update-autoloads: t
|
||||
;; coding: utf-8
|
||||
;; End:
|
||||
;;; dart-server-autoloads.el ends here
|
|
@ -1,2 +0,0 @@
|
|||
;;; -*- no-byte-compile: t -*-
|
||||
(define-package "dart-server" "20190817.1254" "Minor mode for editing Dart files" '((emacs "24.5") (cl-lib "0.5") (dash "2.10.0") (flycheck "0.23") (s "1.10")) :commit "aba838e8ee2f30309f366e8a91c17616549003ce" :keywords '("languages") :authors '(("Natalie Weizenbaum") ("Brady Trainor" . "mail@bradyt.com")) :maintainer '("Brady Trainor" . "mail@bradyt.com") :url "https://github.com/bradyt/dart-server")
|
File diff suppressed because it is too large
Load diff
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue