Upgrade packages
This commit is contained in:
parent
3d1a464ca1
commit
553d43f211
419 changed files with 662 additions and 21432 deletions
|
@ -1,128 +0,0 @@
|
|||
;;; ag-autoloads.el --- automatically extracted autoloads
|
||||
;;
|
||||
;;; Code:
|
||||
|
||||
(add-to-list 'load-path (directory-file-name
|
||||
(or (file-name-directory #$) (car load-path))))
|
||||
|
||||
|
||||
;;;### (autoloads nil "ag" "ag.el" (0 0 0 0))
|
||||
;;; Generated autoloads from ag.el
|
||||
|
||||
(autoload 'ag "ag" "\
|
||||
Search using ag in a given DIRECTORY for a given literal search STRING,
|
||||
with STRING defaulting to the symbol under point.
|
||||
|
||||
If called with a prefix, prompts for flags to pass to ag.
|
||||
|
||||
\(fn STRING DIRECTORY)" t nil)
|
||||
|
||||
(autoload 'ag-files "ag" "\
|
||||
Search using ag in a given DIRECTORY for a given literal search STRING,
|
||||
limited to files that match FILE-TYPE. STRING defaults to the
|
||||
symbol under point.
|
||||
|
||||
If called with a prefix, prompts for flags to pass to ag.
|
||||
|
||||
\(fn STRING FILE-TYPE DIRECTORY)" t nil)
|
||||
|
||||
(autoload 'ag-regexp "ag" "\
|
||||
Search using ag in a given directory for a given regexp.
|
||||
The regexp should be in PCRE syntax, not Emacs regexp syntax.
|
||||
|
||||
If called with a prefix, prompts for flags to pass to ag.
|
||||
|
||||
\(fn STRING DIRECTORY)" t nil)
|
||||
|
||||
(autoload 'ag-project "ag" "\
|
||||
Guess the root of the current project and search it with ag
|
||||
for the given literal search STRING.
|
||||
|
||||
If called with a prefix, prompts for flags to pass to ag.
|
||||
|
||||
\(fn STRING)" t nil)
|
||||
|
||||
(autoload 'ag-project-files "ag" "\
|
||||
Search using ag for a given literal search STRING,
|
||||
limited to files that match FILE-TYPE. STRING defaults to the
|
||||
symbol under point.
|
||||
|
||||
If called with a prefix, prompts for flags to pass to ag.
|
||||
|
||||
\(fn STRING FILE-TYPE)" t nil)
|
||||
|
||||
(autoload 'ag-project-regexp "ag" "\
|
||||
Guess the root of the current project and search it with ag
|
||||
for the given regexp. The regexp should be in PCRE syntax, not
|
||||
Emacs regexp syntax.
|
||||
|
||||
If called with a prefix, prompts for flags to pass to ag.
|
||||
|
||||
\(fn REGEXP)" t nil)
|
||||
|
||||
(defalias 'ag-project-at-point 'ag-project)
|
||||
|
||||
(defalias 'ag-regexp-project-at-point 'ag-project-regexp)
|
||||
|
||||
(autoload 'ag-dired "ag" "\
|
||||
Recursively find files in DIR matching literal search STRING.
|
||||
|
||||
The PATTERN is matched against the full path to the file, not
|
||||
only against the file name.
|
||||
|
||||
The results are presented as a `dired-mode' buffer with
|
||||
`default-directory' being DIR.
|
||||
|
||||
See also `ag-dired-regexp'.
|
||||
|
||||
\(fn DIR STRING)" t nil)
|
||||
|
||||
(autoload 'ag-dired-regexp "ag" "\
|
||||
Recursively find files in DIR matching REGEXP.
|
||||
REGEXP should be in PCRE syntax, not Emacs regexp syntax.
|
||||
|
||||
The REGEXP is matched against the full path to the file, not
|
||||
only against the file name.
|
||||
|
||||
Results are presented as a `dired-mode' buffer with
|
||||
`default-directory' being DIR.
|
||||
|
||||
See also `find-dired'.
|
||||
|
||||
\(fn DIR REGEXP)" t nil)
|
||||
|
||||
(autoload 'ag-project-dired "ag" "\
|
||||
Recursively find files in current project matching PATTERN.
|
||||
|
||||
See also `ag-dired'.
|
||||
|
||||
\(fn PATTERN)" t nil)
|
||||
|
||||
(autoload 'ag-project-dired-regexp "ag" "\
|
||||
Recursively find files in current project matching REGEXP.
|
||||
|
||||
See also `ag-dired-regexp'.
|
||||
|
||||
\(fn REGEXP)" t nil)
|
||||
|
||||
(autoload 'ag-kill-buffers "ag" "\
|
||||
Kill all `ag-mode' buffers.
|
||||
|
||||
\(fn)" t nil)
|
||||
|
||||
(autoload 'ag-kill-other-buffers "ag" "\
|
||||
Kill all `ag-mode' buffers other than the current buffer.
|
||||
|
||||
\(fn)" t nil)
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "ag" '("ag-" "ag/")))
|
||||
|
||||
;;;***
|
||||
|
||||
;; Local Variables:
|
||||
;; version-control: never
|
||||
;; no-byte-compile: t
|
||||
;; no-update-autoloads: t
|
||||
;; coding: utf-8
|
||||
;; End:
|
||||
;;; ag-autoloads.el ends here
|
|
@ -1,2 +0,0 @@
|
|||
;;; -*- no-byte-compile: t -*-
|
||||
(define-package "ag" "20190726.9" "A front-end for ag ('the silver searcher'), the C ack replacement." '((dash "2.8.0") (s "1.9.0") (cl-lib "0.5")) :commit "bd81d68466e44301505629454dfc689b6c17d94b" :authors '(("Wilfred Hughes" . "me@wilfred.me.uk")) :maintainer '("Wilfred Hughes" . "me@wilfred.me.uk"))
|
|
@ -1,689 +0,0 @@
|
|||
;;; ag.el --- A front-end for ag ('the silver searcher'), the C ack replacement.
|
||||
|
||||
;; Copyright (C) 2013-2014 Wilfred Hughes <me@wilfred.me.uk>
|
||||
;;
|
||||
;; Author: Wilfred Hughes <me@wilfred.me.uk>
|
||||
;; Created: 11 January 2013
|
||||
;; Version: 0.48
|
||||
;; Package-Version: 20190726.9
|
||||
;; Package-Requires: ((dash "2.8.0") (s "1.9.0") (cl-lib "0.5"))
|
||||
;;; Commentary:
|
||||
|
||||
;; Please see README.md for documentation, or read it online at
|
||||
;; https://github.com/Wilfred/ag.el/#agel
|
||||
|
||||
;;; License:
|
||||
|
||||
;; This file is not part of GNU Emacs.
|
||||
;; However, it is distributed under the same license.
|
||||
|
||||
;; 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, 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; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
|
||||
;;; Code:
|
||||
(require 'cl-lib) ;; cl-letf, cl-defun
|
||||
(require 'dired) ;; dired-sort-inhibit
|
||||
(require 'dash)
|
||||
(require 's)
|
||||
(require 'find-dired) ;; find-dired-filter
|
||||
|
||||
(defgroup ag nil
|
||||
"A front-end for ag - The Silver Searcher."
|
||||
:group 'tools
|
||||
:group 'matching)
|
||||
|
||||
(defcustom ag-executable
|
||||
"ag"
|
||||
"Name of the ag executable to use."
|
||||
:type 'string
|
||||
:group 'ag)
|
||||
|
||||
(defcustom ag-arguments
|
||||
(list "--smart-case" "--stats")
|
||||
"Additional arguments passed to ag.
|
||||
|
||||
Ag.el internally uses --column, --line-number and --color
|
||||
options (with specific colors) to match groups, so options
|
||||
specified here should not conflict.
|
||||
|
||||
--line-number is required on Windows, as otherwise ag will not
|
||||
print line numbers when the input is a stream."
|
||||
:type '(repeat (string))
|
||||
:group 'ag)
|
||||
|
||||
(defcustom ag-dired-arguments
|
||||
(list "--nocolor" "-S")
|
||||
"Additional arguments passed to ag-dired."
|
||||
:type '(repeat (string))
|
||||
:group 'ag)
|
||||
|
||||
(defcustom ag-context-lines nil
|
||||
"Number of context lines to include before and after a matching line."
|
||||
:type 'integer
|
||||
:group 'ag)
|
||||
|
||||
(defcustom ag-group-matches t
|
||||
"Group matches in the same file together.
|
||||
|
||||
If nil, the file name is repeated at the beginning of every match line."
|
||||
:type 'boolean
|
||||
:group 'ag)
|
||||
|
||||
(defcustom ag-highlight-search nil
|
||||
"Non-nil means we highlight the current search term in results.
|
||||
|
||||
This requires the ag command to support --color-match, which is only in v0.14+"
|
||||
:type 'boolean
|
||||
:group 'ag)
|
||||
|
||||
(defcustom ag-reuse-buffers nil
|
||||
"Non-nil means we reuse the existing search results buffer or
|
||||
dired results buffer, rather than creating one buffer per unique
|
||||
search."
|
||||
:type 'boolean
|
||||
:group 'ag)
|
||||
|
||||
(defcustom ag-reuse-window nil
|
||||
"Non-nil means we open search results in the same window,
|
||||
hiding the results buffer."
|
||||
:type 'boolean
|
||||
:group 'ag)
|
||||
|
||||
(defcustom ag-project-root-function nil
|
||||
"A function to determine the project root for `ag-project'.
|
||||
|
||||
If set to a function, call this function with the name of the
|
||||
file or directory for which to determine the project root
|
||||
directory.
|
||||
|
||||
If set to nil, fall back to finding VCS root directories."
|
||||
:type '(choice (const :tag "Default (VCS root)" nil)
|
||||
(function :tag "Function"))
|
||||
:group 'ag)
|
||||
|
||||
(defcustom ag-ignore-list nil
|
||||
"A list of patterns for files/directories to ignore when searching."
|
||||
:type '(repeat (string))
|
||||
:group 'ag)
|
||||
(make-variable-buffer-local 'ag-ignore-list)
|
||||
(put 'ag-ignore-list 'safe-local-variable #'listp)
|
||||
|
||||
(require 'compile)
|
||||
|
||||
;; Although ag results aren't exactly errors, we treat them as errors
|
||||
;; so `next-error' and `previous-error' work. However, we ensure our
|
||||
;; face inherits from `compilation-info-face' so the results are
|
||||
;; styled appropriately.
|
||||
(defface ag-hit-face '((t :inherit compilation-info))
|
||||
"Face name to use for ag matches."
|
||||
:group 'ag)
|
||||
|
||||
(defface ag-match-face '((t :inherit match))
|
||||
"Face name to use for ag matches."
|
||||
:group 'ag)
|
||||
|
||||
(defvar ag-search-finished-hook nil
|
||||
"Hook run when ag completes a search in a buffer.")
|
||||
|
||||
(defun ag/run-finished-hook (buffer how-finished)
|
||||
"Run the ag hook to signal that the search has completed."
|
||||
(with-current-buffer buffer
|
||||
(run-hooks 'ag-search-finished-hook)))
|
||||
|
||||
(defmacro ag/with-patch-function (fun-name fun-args fun-body &rest body)
|
||||
"Temporarily override the definition of FUN-NAME whilst BODY is executed.
|
||||
|
||||
Assumes FUNCTION is already defined (see http://emacs.stackexchange.com/a/3452/304)."
|
||||
`(cl-letf (((symbol-function ,fun-name)
|
||||
(lambda ,fun-args ,fun-body)))
|
||||
,@body))
|
||||
|
||||
(defun ag/next-error-function (n &optional reset)
|
||||
"Open the search result at point in the current window or a
|
||||
different window, according to `ag-reuse-window'."
|
||||
(if ag-reuse-window
|
||||
;; prevent changing the window
|
||||
(ag/with-patch-function
|
||||
'pop-to-buffer (buffer &rest args) (switch-to-buffer buffer)
|
||||
(compilation-next-error-function n reset))
|
||||
|
||||
;; just navigate to the results as normal
|
||||
(compilation-next-error-function n reset)))
|
||||
|
||||
;; Note that we want to use as tight a regexp as we can to try and
|
||||
;; handle weird file names (with colons in them) as well as possible.
|
||||
;; E.g. we use [1-9][0-9]* rather than [0-9]+ so as to accept ":034:"
|
||||
;; in file names.
|
||||
(defvar ag/file-column-pattern-nogroup
|
||||
"^\\(.+?\\):\\([1-9][0-9]*\\):\\([1-9][0-9]*\\):"
|
||||
"A regexp pattern that groups output into filename, line number and column number.")
|
||||
|
||||
(defvar ag/file-column-pattern-group
|
||||
"^\\([[:digit:]]+\\):\\([[:digit:]]+\\):"
|
||||
"A regexp pattern to match line number and column number with grouped output.")
|
||||
|
||||
(defun ag/compilation-match-grouped-filename ()
|
||||
"Match filename backwards when a line/column match is found in grouped output mode."
|
||||
(save-match-data
|
||||
(save-excursion
|
||||
(when (re-search-backward "^File: \\(.*\\)$" (point-min) t)
|
||||
(list (match-string 1))))))
|
||||
|
||||
(define-compilation-mode ag-mode "Ag"
|
||||
"Ag results compilation mode"
|
||||
(set (make-local-variable 'compilation-error-regexp-alist)
|
||||
'(compilation-ag-nogroup compilation-ag-group))
|
||||
(set (make-local-variable 'compilation-error-regexp-alist-alist)
|
||||
(list (cons 'compilation-ag-nogroup (list ag/file-column-pattern-nogroup 1 2 3))
|
||||
(cons 'compilation-ag-group (list ag/file-column-pattern-group
|
||||
'ag/compilation-match-grouped-filename 1 2))))
|
||||
(set (make-local-variable 'compilation-error-face) 'ag-hit-face)
|
||||
(set (make-local-variable 'next-error-function) #'ag/next-error-function)
|
||||
(set (make-local-variable 'compilation-finish-functions)
|
||||
#'ag/run-finished-hook)
|
||||
(add-hook 'compilation-filter-hook 'ag-filter nil t))
|
||||
|
||||
(define-key ag-mode-map (kbd "p") #'compilation-previous-error)
|
||||
(define-key ag-mode-map (kbd "n") #'compilation-next-error)
|
||||
(define-key ag-mode-map (kbd "k") '(lambda () (interactive)
|
||||
(let (kill-buffer-query-functions) (kill-buffer))))
|
||||
|
||||
(defun ag/buffer-name (search-string directory regexp)
|
||||
"Return a buffer name formatted according to ag.el conventions."
|
||||
(cond
|
||||
(ag-reuse-buffers "*ag search*")
|
||||
(regexp (format "*ag search regexp:%s dir:%s*" search-string directory))
|
||||
(:else (format "*ag search text:%s dir:%s*" search-string directory))))
|
||||
|
||||
(defun ag/format-ignore (ignores)
|
||||
"Prepend '--ignore' to every item in IGNORES."
|
||||
(apply #'append
|
||||
(mapcar (lambda (item) (list "--ignore" item)) ignores)))
|
||||
|
||||
(cl-defun ag/search (string directory
|
||||
&key (regexp nil) (file-regex nil) (file-type nil) (files '(".")))
|
||||
"Run ag searching for the STRING given in DIRECTORY.
|
||||
If `files` is passed, tell ag to look only on those files.
|
||||
If REGEXP is non-nil, treat STRING as a regular expression."
|
||||
(let ((default-directory (file-name-as-directory directory))
|
||||
(arguments ag-arguments)
|
||||
(shell-command-switch "-c"))
|
||||
;; Add double dashes at the end of command line if not specified in
|
||||
;; ag-arguments.
|
||||
(unless (equal (car (last arguments)) "--")
|
||||
(setq arguments (append arguments '("--"))))
|
||||
(setq arguments
|
||||
(append '("--line-number" "--column" "--color" "--color-match" "30;43"
|
||||
"--color-path" "1;32")
|
||||
arguments))
|
||||
(if ag-group-matches
|
||||
(setq arguments (cons "--group" arguments))
|
||||
(setq arguments (cons "--nogroup" arguments)))
|
||||
(unless regexp
|
||||
(setq arguments (cons "--literal" arguments)))
|
||||
(when (or (eq system-type 'windows-nt) (eq system-type 'cygwin))
|
||||
;; Use --vimgrep to work around issue #97 on Windows.
|
||||
(setq arguments (cons "--vimgrep" arguments)))
|
||||
(when (char-or-string-p file-regex)
|
||||
(setq arguments (append `("--file-search-regex" ,file-regex) arguments)))
|
||||
(when file-type
|
||||
(setq arguments (cons (format "--%s" file-type) arguments)))
|
||||
(if (integerp current-prefix-arg)
|
||||
(setq arguments (cons (format "--context=%d" (abs current-prefix-arg)) arguments))
|
||||
(when ag-context-lines
|
||||
(setq arguments (cons (format "--context=%d" ag-context-lines) arguments))))
|
||||
(when ag-ignore-list
|
||||
(setq arguments (append (ag/format-ignore ag-ignore-list) arguments)))
|
||||
(unless (file-exists-p default-directory)
|
||||
(error "No such directory %s" default-directory))
|
||||
(let ((command-string
|
||||
(mapconcat #'shell-quote-argument
|
||||
(append (list ag-executable) arguments (append `(,string) files))
|
||||
" ")))
|
||||
;; If we're called with a prefix, let the user modify the command before
|
||||
;; running it. Typically this means they want to pass additional arguments.
|
||||
;; The numeric value is used for context lines: positive is just context
|
||||
;; number (no modification), negative allows further modification.
|
||||
(when (and current-prefix-arg (not (and (integerp current-prefix-arg) (> current-prefix-arg 0))))
|
||||
;; Make a space in the command-string for the user to enter more arguments.
|
||||
(setq command-string (ag/replace-first command-string " -- " " -- "))
|
||||
;; Prompt for the command.
|
||||
(let ((adjusted-point (- (length command-string) (length string) 5)))
|
||||
(setq command-string
|
||||
(read-from-minibuffer "ag command: "
|
||||
(cons command-string adjusted-point)))))
|
||||
;; Call ag.
|
||||
(compilation-start
|
||||
command-string
|
||||
#'ag-mode
|
||||
`(lambda (mode-name) ,(ag/buffer-name string directory regexp))))))
|
||||
|
||||
(defun ag/dwim-at-point ()
|
||||
"If there's an active selection, return that.
|
||||
Otherwise, get the symbol at point, as a string."
|
||||
(cond ((use-region-p)
|
||||
(buffer-substring-no-properties (region-beginning) (region-end)))
|
||||
((symbol-at-point)
|
||||
(substring-no-properties
|
||||
(symbol-name (symbol-at-point))))))
|
||||
|
||||
(defun ag/buffer-extension-regex ()
|
||||
"If the current buffer has an extension, return
|
||||
a PCRE pattern that matches files with that extension.
|
||||
Returns an empty string otherwise."
|
||||
(let ((file-name (buffer-file-name)))
|
||||
(if (stringp file-name)
|
||||
(format "\\.%s$" (ag/escape-pcre (file-name-extension file-name)))
|
||||
"")))
|
||||
|
||||
(defun ag/longest-string (&rest strings)
|
||||
"Given a list of strings and nils, return the longest string."
|
||||
(let ((longest-string nil))
|
||||
(dolist (string (-non-nil strings))
|
||||
(when (< (length longest-string)
|
||||
(length string))
|
||||
(setq longest-string string)))
|
||||
longest-string))
|
||||
|
||||
(defun ag/replace-first (string before after)
|
||||
"Replace the first occurrence of BEFORE in STRING with AFTER."
|
||||
(replace-regexp-in-string
|
||||
(concat "\\(" (regexp-quote before) "\\)" ".*\\'")
|
||||
after string
|
||||
nil nil 1))
|
||||
|
||||
(autoload 'vc-git-root "vc-git")
|
||||
|
||||
(require 'vc-svn)
|
||||
;; Emacs 23.4 doesn't provide vc-svn-root.
|
||||
(unless (functionp 'vc-svn-root)
|
||||
(defun vc-svn-root (file)
|
||||
(vc-find-root file vc-svn-admin-directory)))
|
||||
|
||||
(autoload 'vc-hg-root "vc-hg")
|
||||
|
||||
(autoload 'vc-bzr-root "vc-bzr")
|
||||
|
||||
(defun ag/project-root (file-path)
|
||||
"Guess the project root of the given FILE-PATH.
|
||||
|
||||
Use `ag-project-root-function' if set, or fall back to VCS
|
||||
roots."
|
||||
(if ag-project-root-function
|
||||
(funcall ag-project-root-function file-path)
|
||||
(or (ag/longest-string
|
||||
(vc-git-root file-path)
|
||||
(vc-svn-root file-path)
|
||||
(vc-hg-root file-path)
|
||||
(vc-bzr-root file-path))
|
||||
file-path)))
|
||||
|
||||
(defun ag/dired-align-size-column ()
|
||||
(beginning-of-line)
|
||||
(when (looking-at "^ ")
|
||||
(forward-char 2)
|
||||
(search-forward " " nil t 4)
|
||||
(let* ((size-start (point))
|
||||
(size-end (search-forward " " nil t))
|
||||
(width (and size-end (- size-end size-start))))
|
||||
(when (and size-end
|
||||
(< width 12)
|
||||
(> width 1))
|
||||
(goto-char size-start)
|
||||
(insert (make-string (- 12 width) ? ))))))
|
||||
|
||||
(defun ag/dired-filter (proc string)
|
||||
"Filter the output of ag to make it suitable for `dired-mode'."
|
||||
(let ((buf (process-buffer proc))
|
||||
(inhibit-read-only t))
|
||||
(if (buffer-name buf)
|
||||
(with-current-buffer buf
|
||||
(save-excursion
|
||||
(save-restriction
|
||||
(widen)
|
||||
(let ((beg (point-max)))
|
||||
(goto-char beg)
|
||||
(insert string)
|
||||
(goto-char beg)
|
||||
(or (looking-at "^")
|
||||
(progn
|
||||
(ag/dired-align-size-column)
|
||||
(forward-line 1)))
|
||||
(while (looking-at "^")
|
||||
(insert " ")
|
||||
(ag/dired-align-size-column)
|
||||
(forward-line 1))
|
||||
(goto-char beg)
|
||||
(beginning-of-line)
|
||||
|
||||
;; Remove occurrences of default-directory.
|
||||
(while (search-forward (concat " " default-directory) nil t)
|
||||
(replace-match " " nil t))
|
||||
|
||||
(goto-char (point-max))
|
||||
(if (search-backward "\n" (process-mark proc) t)
|
||||
(progn
|
||||
(dired-insert-set-properties (process-mark proc)
|
||||
(1+ (point)))
|
||||
(move-marker (process-mark proc) (1+ (point)))))))))
|
||||
(delete-process proc))))
|
||||
|
||||
(defun ag/dired-sentinel (proc state)
|
||||
"Update the status/modeline after the process finishes."
|
||||
(let ((buf (process-buffer proc))
|
||||
(inhibit-read-only t))
|
||||
(if (buffer-name buf)
|
||||
(with-current-buffer buf
|
||||
(let ((buffer-read-only nil))
|
||||
(save-excursion
|
||||
(goto-char (point-max))
|
||||
(insert "\n ag " state)
|
||||
(forward-char -1) ;Back up before \n at end of STATE.
|
||||
(insert " at " (substring (current-time-string) 0 19))
|
||||
(forward-char 1)
|
||||
(setq mode-line-process
|
||||
(concat ":" (symbol-name (process-status proc))))
|
||||
;; Since the buffer and mode line will show that the
|
||||
;; process is dead, we can delete it now. Otherwise it
|
||||
;; will stay around until M-x list-processes.
|
||||
(delete-process proc)
|
||||
(force-mode-line-update)))
|
||||
(run-hooks 'dired-after-readin-hook)
|
||||
(message "%s finished." (current-buffer))))))
|
||||
|
||||
(defun ag/kill-process ()
|
||||
"Kill the `ag' process running in the current buffer."
|
||||
(interactive)
|
||||
(let ((ag (get-buffer-process (current-buffer))))
|
||||
(and ag (eq (process-status ag) 'run)
|
||||
(eq (process-filter ag) (function find-dired-filter))
|
||||
(condition-case nil
|
||||
(delete-process ag)
|
||||
(error nil)))))
|
||||
|
||||
(defun ag/escape-pcre (regexp)
|
||||
"Escape the PCRE-special characters in REGEXP so that it is
|
||||
matched literally."
|
||||
(let ((alphanum "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"))
|
||||
(apply #'concat
|
||||
(mapcar
|
||||
(lambda (c)
|
||||
(cond
|
||||
((not (string-match-p (regexp-quote c) alphanum))
|
||||
(concat "\\" c))
|
||||
(t c)))
|
||||
(mapcar #'char-to-string (string-to-list regexp))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun ag (string directory)
|
||||
"Search using ag in a given DIRECTORY for a given literal search STRING,
|
||||
with STRING defaulting to the symbol under point.
|
||||
|
||||
If called with a prefix, prompts for flags to pass to ag."
|
||||
(interactive (list (ag/read-from-minibuffer "Search string")
|
||||
(read-directory-name "Directory: ")))
|
||||
(ag/search string directory))
|
||||
|
||||
;;;###autoload
|
||||
(defun ag-files (string file-type directory)
|
||||
"Search using ag in a given DIRECTORY for a given literal search STRING,
|
||||
limited to files that match FILE-TYPE. STRING defaults to the
|
||||
symbol under point.
|
||||
|
||||
If called with a prefix, prompts for flags to pass to ag."
|
||||
(interactive (list (ag/read-from-minibuffer "Search string")
|
||||
(ag/read-file-type)
|
||||
(read-directory-name "Directory: ")))
|
||||
(apply #'ag/search string directory file-type))
|
||||
|
||||
;;;###autoload
|
||||
(defun ag-regexp (string directory)
|
||||
"Search using ag in a given directory for a given regexp.
|
||||
The regexp should be in PCRE syntax, not Emacs regexp syntax.
|
||||
|
||||
If called with a prefix, prompts for flags to pass to ag."
|
||||
(interactive "sSearch regexp: \nDDirectory: ")
|
||||
(ag/search string directory :regexp t))
|
||||
|
||||
;;;###autoload
|
||||
(defun ag-project (string)
|
||||
"Guess the root of the current project and search it with ag
|
||||
for the given literal search STRING.
|
||||
|
||||
If called with a prefix, prompts for flags to pass to ag."
|
||||
(interactive (list (ag/read-from-minibuffer "Search string")))
|
||||
(ag/search string (ag/project-root default-directory)))
|
||||
|
||||
;;;###autoload
|
||||
(defun ag-project-files (string file-type)
|
||||
"Search using ag for a given literal search STRING,
|
||||
limited to files that match FILE-TYPE. STRING defaults to the
|
||||
symbol under point.
|
||||
|
||||
If called with a prefix, prompts for flags to pass to ag."
|
||||
(interactive (list (ag/read-from-minibuffer "Search string")
|
||||
(ag/read-file-type)))
|
||||
(apply 'ag/search string (ag/project-root default-directory) file-type))
|
||||
|
||||
(defun ag/read-from-minibuffer (prompt)
|
||||
"Read a value from the minibuffer with PROMPT.
|
||||
If there's a string at point, offer that as a default."
|
||||
(let* ((suggested (ag/dwim-at-point))
|
||||
(final-prompt
|
||||
(if suggested
|
||||
(format "%s (default %s): " prompt suggested)
|
||||
(format "%s: " prompt)))
|
||||
;; Ask the user for input, but add `suggested' to the history
|
||||
;; so they can use M-n if they want to modify it.
|
||||
(user-input (read-from-minibuffer
|
||||
final-prompt
|
||||
nil nil nil nil suggested)))
|
||||
;; Return the input provided by the user, or use `suggested' if
|
||||
;; the input was empty.
|
||||
(if (> (length user-input) 0)
|
||||
user-input
|
||||
suggested)))
|
||||
|
||||
;;;###autoload
|
||||
(defun ag-project-regexp (regexp)
|
||||
"Guess the root of the current project and search it with ag
|
||||
for the given regexp. The regexp should be in PCRE syntax, not
|
||||
Emacs regexp syntax.
|
||||
|
||||
If called with a prefix, prompts for flags to pass to ag."
|
||||
(interactive (list (ag/read-from-minibuffer "Search regexp")))
|
||||
(ag/search regexp (ag/project-root default-directory) :regexp t))
|
||||
|
||||
(autoload 'symbol-at-point "thingatpt")
|
||||
|
||||
;;;###autoload
|
||||
(defalias 'ag-project-at-point 'ag-project)
|
||||
(make-obsolete 'ag-project-at-point 'ag-project "0.19")
|
||||
|
||||
;;;###autoload
|
||||
(defalias 'ag-regexp-project-at-point 'ag-project-regexp)
|
||||
(make-obsolete 'ag-regexp-project-at-point 'ag-project-regexp "0.46")
|
||||
|
||||
;;;###autoload
|
||||
(defun ag-dired (dir string)
|
||||
"Recursively find files in DIR matching literal search STRING.
|
||||
|
||||
The PATTERN is matched against the full path to the file, not
|
||||
only against the file name.
|
||||
|
||||
The results are presented as a `dired-mode' buffer with
|
||||
`default-directory' being DIR.
|
||||
|
||||
See also `ag-dired-regexp'."
|
||||
(interactive "DDirectory: \nsFile pattern: ")
|
||||
(ag-dired-regexp dir (ag/escape-pcre string)))
|
||||
|
||||
;;;###autoload
|
||||
(defun ag-dired-regexp (dir regexp)
|
||||
"Recursively find files in DIR matching REGEXP.
|
||||
REGEXP should be in PCRE syntax, not Emacs regexp syntax.
|
||||
|
||||
The REGEXP is matched against the full path to the file, not
|
||||
only against the file name.
|
||||
|
||||
Results are presented as a `dired-mode' buffer with
|
||||
`default-directory' being DIR.
|
||||
|
||||
See also `find-dired'."
|
||||
(interactive "DDirectory: \nsFile regexp: ")
|
||||
(let* ((dired-buffers dired-buffers) ;; do not mess with regular dired buffers
|
||||
(orig-dir dir)
|
||||
(dir (file-name-as-directory (expand-file-name dir)))
|
||||
(buffer-name (if ag-reuse-buffers
|
||||
"*ag dired*"
|
||||
(format "*ag dired pattern:%s dir:%s*" regexp dir)))
|
||||
(cmd (if (string= system-type "windows-nt")
|
||||
(concat ag-executable " " (combine-and-quote-strings ag-dired-arguments " ") " -g \"" regexp "\" "
|
||||
(shell-quote-argument dir)
|
||||
" | grep -v \"^$\" | sed \"s/'/\\\\\\\\'/g\" | xargs -I '{}' "
|
||||
insert-directory-program " "
|
||||
dired-listing-switches " '{}' &")
|
||||
(concat ag-executable " " (combine-and-quote-strings ag-dired-arguments " ") " -g '" regexp "' "
|
||||
(shell-quote-argument dir)
|
||||
" | grep -v '^$' | sed s/\\'/\\\\\\\\\\'/g | xargs -I '{}' "
|
||||
insert-directory-program " "
|
||||
dired-listing-switches " '{}' &"))))
|
||||
(with-current-buffer (get-buffer-create buffer-name)
|
||||
(switch-to-buffer (current-buffer))
|
||||
(widen)
|
||||
(kill-all-local-variables)
|
||||
(if (fboundp 'read-only-mode)
|
||||
(read-only-mode -1)
|
||||
(setq buffer-read-only nil))
|
||||
(let ((inhibit-read-only t)) (erase-buffer))
|
||||
(setq default-directory dir)
|
||||
(run-hooks 'dired-before-readin-hook)
|
||||
(shell-command cmd (current-buffer))
|
||||
(insert " " dir ":\n")
|
||||
(insert " " cmd "\n")
|
||||
(dired-mode dir)
|
||||
(let ((map (make-sparse-keymap)))
|
||||
(set-keymap-parent map (current-local-map))
|
||||
(define-key map "\C-c\C-k" 'ag/kill-process)
|
||||
(use-local-map map))
|
||||
(set (make-local-variable 'dired-sort-inhibit) t)
|
||||
(set (make-local-variable 'revert-buffer-function)
|
||||
`(lambda (ignore-auto noconfirm)
|
||||
(ag-dired-regexp ,orig-dir ,regexp)))
|
||||
(if (fboundp 'dired-simple-subdir-alist)
|
||||
(dired-simple-subdir-alist)
|
||||
(set (make-local-variable 'dired-subdir-alist)
|
||||
(list (cons default-directory (point-min-marker)))))
|
||||
(let ((proc (get-buffer-process (current-buffer))))
|
||||
(set-process-filter proc #'ag/dired-filter)
|
||||
(set-process-sentinel proc #'ag/dired-sentinel)
|
||||
;; Initialize the process marker; it is used by the filter.
|
||||
(move-marker (process-mark proc) 1 (current-buffer)))
|
||||
(setq mode-line-process '(":%s")))))
|
||||
|
||||
;;;###autoload
|
||||
(defun ag-project-dired (pattern)
|
||||
"Recursively find files in current project matching PATTERN.
|
||||
|
||||
See also `ag-dired'."
|
||||
(interactive "sFile pattern: ")
|
||||
(ag-dired-regexp (ag/project-root default-directory) (ag/escape-pcre pattern)))
|
||||
|
||||
;;;###autoload
|
||||
(defun ag-project-dired-regexp (regexp)
|
||||
"Recursively find files in current project matching REGEXP.
|
||||
|
||||
See also `ag-dired-regexp'."
|
||||
(interactive "sFile regexp: ")
|
||||
(ag-dired-regexp (ag/project-root default-directory) regexp))
|
||||
|
||||
;;;###autoload
|
||||
(defun ag-kill-buffers ()
|
||||
"Kill all `ag-mode' buffers."
|
||||
(interactive)
|
||||
(dolist (buffer (buffer-list))
|
||||
(when (eq (buffer-local-value 'major-mode buffer) 'ag-mode)
|
||||
(kill-buffer buffer))))
|
||||
|
||||
;;;###autoload
|
||||
(defun ag-kill-other-buffers ()
|
||||
"Kill all `ag-mode' buffers other than the current buffer."
|
||||
(interactive)
|
||||
(let ((current-buffer (current-buffer)))
|
||||
(dolist (buffer (buffer-list))
|
||||
(when (and
|
||||
(eq (buffer-local-value 'major-mode buffer) 'ag-mode)
|
||||
(not (eq buffer current-buffer)))
|
||||
(kill-buffer buffer)))))
|
||||
|
||||
;; Based on grep-filter.
|
||||
(defun ag-filter ()
|
||||
"Handle escape sequences inserted by the ag process.
|
||||
This function is called from `compilation-filter-hook'."
|
||||
(save-excursion
|
||||
(forward-line 0)
|
||||
(let ((end (point)) beg)
|
||||
(goto-char compilation-filter-start)
|
||||
(forward-line 0)
|
||||
(setq beg (point))
|
||||
;; Only operate on whole lines so we don't get caught with part of an
|
||||
;; escape sequence in one chunk and the rest in another.
|
||||
(when (< (point) end)
|
||||
(setq end (copy-marker end))
|
||||
(when ag-highlight-search
|
||||
;; Highlight ag matches and delete marking sequences.
|
||||
(while (re-search-forward "\033\\[30;43m\\(.*?\\)\033\\[0m\033\\[K" end 1)
|
||||
(replace-match (propertize (match-string 1)
|
||||
'face nil 'font-lock-face 'ag-match-face)
|
||||
t t)))
|
||||
;; Add marker at start of line for files. This is used by the match
|
||||
;; in `compilation-error-regexp-alist' to extract the file name.
|
||||
(when ag-group-matches
|
||||
(goto-char beg)
|
||||
(while (re-search-forward "\033\\[1;32m\\(.*\\)\033\\[0m\033\\[K" end 1)
|
||||
(replace-match
|
||||
(concat "File: " (propertize (match-string 1) 'face nil 'font-lock-face
|
||||
'compilation-info))
|
||||
t t)))
|
||||
;; Delete all remaining escape sequences
|
||||
(goto-char beg)
|
||||
(while (re-search-forward "\033\\[[0-9;]*[mK]" end 1)
|
||||
(replace-match "" t t))))))
|
||||
|
||||
(defun ag/get-supported-types ()
|
||||
"Query the ag executable for which file types it recognises."
|
||||
(let* ((ag-output (shell-command-to-string (format "%s --list-file-types" ag-executable)))
|
||||
(lines (-map #'s-trim (s-lines ag-output)))
|
||||
(types (--keep (when (s-starts-with? "--" it) (s-chop-prefix "--" it )) lines))
|
||||
(extensions (--map (s-split " " it) (--filter (s-starts-with? "." it) lines))))
|
||||
(-zip types extensions)))
|
||||
|
||||
(defun ag/read-file-type ()
|
||||
"Prompt the user for a known file type, or let them specify a PCRE regex."
|
||||
(let* ((all-types-with-extensions (ag/get-supported-types))
|
||||
(all-types (mapcar 'car all-types-with-extensions))
|
||||
(file-type
|
||||
(completing-read "Select file type: "
|
||||
(append '("custom (provide a PCRE regex)") all-types)))
|
||||
(file-type-extensions
|
||||
(cdr (assoc file-type all-types-with-extensions))))
|
||||
(if file-type-extensions
|
||||
(list :file-type file-type)
|
||||
(list :file-regex
|
||||
(read-from-minibuffer "Filenames which match PCRE: "
|
||||
(ag/buffer-extension-regex))))))
|
||||
|
||||
(provide 'ag)
|
||||
;;; ag.el ends here
|
Binary file not shown.
|
@ -1173,7 +1173,7 @@
|
|||
(:maintainer "Alexey Veretennikov" . "alexey.veretennikov@gmail.com")
|
||||
(:url . "https://github.com/fourier/loccur"))])
|
||||
(map .
|
||||
[(2 0)
|
||||
[(2 1)
|
||||
((emacs
|
||||
(25)))
|
||||
"Map manipulation functions" single
|
||||
|
@ -1411,7 +1411,7 @@
|
|||
(:maintainer "Michael Heerdegen" . "michael_heerdegen@web.de")
|
||||
(:url . "https://github.com/michael-heerdegen/on-screen.el"))])
|
||||
(org .
|
||||
[(9 3 2)
|
||||
[(9 3 3)
|
||||
nil "Outline-based notes management and organizer" tar
|
||||
((:url . "https://orgmode.org")
|
||||
(:maintainer "Bastien Guerry" . "bzg@gnu.org")
|
||||
|
@ -1543,11 +1543,11 @@
|
|||
("Mario Lang" . "mlang@delysid.org"))
|
||||
(:maintainer "Mario Lang" . "mlang@delysid.org"))])
|
||||
(posframe .
|
||||
[(0 5 0)
|
||||
[(0 6 0)
|
||||
((emacs
|
||||
(26)))
|
||||
"Pop a posframe (just a frame) at point" single
|
||||
((:keywords "tooltip")
|
||||
((:keywords "convenience" "tooltip")
|
||||
(:authors
|
||||
("Feng Shu" . "tumashu@163.com"))
|
||||
(:maintainer "Feng Shu" . "tumashu@163.com")
|
||||
|
|
|
@ -1 +1 @@
|
|||
Good signature from 066DAFCB81E42C40 GNU ELPA Signing Agent (2019) <elpasign@elpa.gnu.org> (trust undefined) created at 2020-01-29T11:05:03+0100 using RSA
|
||||
Good signature from 066DAFCB81E42C40 GNU ELPA Signing Agent (2019) <elpasign@elpa.gnu.org> (trust undefined) created at 2020-02-05T11:05:09+0100 using RSA
|
|
@ -1,173 +0,0 @@
|
|||
;;; ein-helm.el --- Helm/anything commands
|
||||
|
||||
;; Copyright (C) 2012 Takafumi Arakaki
|
||||
|
||||
;; Author: Takafumi Arakaki <aka.tkf at gmail.com>
|
||||
|
||||
;; This file is NOT part of GNU Emacs.
|
||||
|
||||
;; ein-helm.el 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.
|
||||
|
||||
;; ein-helm.el 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 ein-helm.el. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;;
|
||||
|
||||
;;; Code:
|
||||
|
||||
(declare-function anything-other-buffer "anything")
|
||||
(declare-function helm-other-buffer "helm")
|
||||
|
||||
(require 'ein-kernel)
|
||||
|
||||
|
||||
;;; Macros
|
||||
|
||||
(defmacro ein:helm-export-source (name)
|
||||
(let* ((orig-source (intern (format "ein:helm-source-%s" name)))
|
||||
(any-source (intern (format "anything-c-source-ein-%s" name)))
|
||||
(helm-source (intern (format "helm-c-source-ein-%s" name)))
|
||||
(docstring (format "Alias to `%s'" orig-source)))
|
||||
`(progn
|
||||
(defvaralias ',helm-source ',orig-source ,docstring)
|
||||
(defvaralias ',any-source ',orig-source ,docstring))))
|
||||
|
||||
|
||||
;;; Dynamic Variables
|
||||
|
||||
(defvar ein:helm-pattern 'helm-pattern
|
||||
"Dynamically bound to one of `helm-pattern' or `anything-pattern'.")
|
||||
|
||||
(defvar ein:helm-kernel nil
|
||||
"Dynamically bound to a kernel object.")
|
||||
|
||||
|
||||
|
||||
;;; History search
|
||||
|
||||
(defcustom ein:helm-kernel-history-search-auto-pattern t
|
||||
"Automatically construct search pattern when non-`nil'.
|
||||
|
||||
1. Single space is converted to \"*\".
|
||||
2. A backslash followed by a space is converted to a single space.
|
||||
3. A \"*\" is added at the beginning and end of the pattern.
|
||||
|
||||
This variable applies to both `helm-ein-kernel-history' and
|
||||
`anything-ein-kernel-history'."
|
||||
:type 'boolean
|
||||
:group 'ein)
|
||||
|
||||
(defun ein:helm-kernel-history-search-construct-pattern (pattern)
|
||||
(when ein:helm-kernel-history-search-auto-pattern
|
||||
(setq pattern
|
||||
(replace-regexp-in-string "[^\\\\ ]\\( \\)[^\\\\ ]"
|
||||
"*" pattern nil nil 1))
|
||||
(setq pattern
|
||||
(replace-regexp-in-string "\\\\ " " " pattern))
|
||||
(setq pattern (concat "*" pattern "*")))
|
||||
pattern)
|
||||
|
||||
(defun ein:helm-kernel-history-search-get-candidates ()
|
||||
"Retrieve search result from kernel.
|
||||
It requires the following dynamical variables:
|
||||
* `ein:helm-pattern'
|
||||
* `ein:helm-kernel'"
|
||||
(let* ((pattern (ein:helm-kernel-history-search-construct-pattern
|
||||
(eval ein:helm-pattern)))
|
||||
(candidates (ein:kernel-history-search-synchronously
|
||||
ein:helm-kernel pattern :unique t)))
|
||||
;; Most recent history first:
|
||||
(nreverse candidates)))
|
||||
|
||||
(defvar ein:helm-source-kernel-history
|
||||
'((name . "IPython history")
|
||||
(candidates . ein:helm-kernel-history-search-get-candidates)
|
||||
(requires-pattern . 3)
|
||||
;; There is no need to filter out candidates:
|
||||
(match . (identity))
|
||||
(volatile)
|
||||
(action . insert)
|
||||
(delayed)
|
||||
(multiline))
|
||||
"Helm/anything source for searching kernel history.")
|
||||
|
||||
;;;###autoload
|
||||
(defun anything-ein-kernel-history ()
|
||||
"Search kernel execution history then insert the selected one."
|
||||
(interactive)
|
||||
(let ((ein:helm-pattern 'anything-pattern)
|
||||
(ein:helm-kernel (ein:get-kernel-or-error)))
|
||||
(anything-other-buffer ein:helm-source-kernel-history "*anything ein*")))
|
||||
|
||||
;;;###autoload
|
||||
(defun helm-ein-kernel-history ()
|
||||
"Search kernel execution history then insert the selected one."
|
||||
(interactive)
|
||||
(let ((ein:helm-pattern 'helm-pattern)
|
||||
(ein:helm-kernel (ein:get-kernel-or-error)))
|
||||
(helm-other-buffer ein:helm-source-kernel-history "*helm ein*")))
|
||||
|
||||
|
||||
|
||||
;;; Notebook buffers
|
||||
|
||||
(defvar ein:helm-source-notebook-buffers
|
||||
'((name . "All IPython notebook buffers")
|
||||
(candidates . ein:notebook-opened-buffer-names)
|
||||
(type . buffer))
|
||||
"Helm/anything source for all opened notebook buffers.")
|
||||
|
||||
(defvar ein:helm-source-modified-notebook-buffers
|
||||
'((name . "Modified IPython notebook buffers")
|
||||
(candidates
|
||||
. (lambda ()
|
||||
(ein:notebook-opened-buffer-names #'ein:notebook-modified-p)))
|
||||
(type . buffer))
|
||||
"Helm/anything source for modified notebook buffers.")
|
||||
|
||||
(defvar ein:helm-source-saved-notebook-buffers
|
||||
'((name . "Saved IPython notebook buffers")
|
||||
(candidates
|
||||
. (lambda ()
|
||||
(ein:notebook-opened-buffer-names
|
||||
(lambda (nb) (not (ein:notebook-modified-p nb))))))
|
||||
(type . buffer))
|
||||
"Helm/anything source for saved notebook buffers.")
|
||||
|
||||
|
||||
;;; "Export" sources to `helm/anything-c-source-*'
|
||||
(ein:helm-export-source notebook-buffers)
|
||||
(ein:helm-export-source modified-notebook-buffers)
|
||||
(ein:helm-export-source saved-notebook-buffers)
|
||||
|
||||
|
||||
;;; Helm/anything commands
|
||||
|
||||
(defvar ein:helm-notebook-buffer-sources
|
||||
'(ein:helm-source-modified-notebook-buffers
|
||||
ein:helm-source-saved-notebook-buffers))
|
||||
|
||||
;;;###autoload
|
||||
(defun anything-ein-notebook-buffers ()
|
||||
"Choose opened notebook using anything.el interface."
|
||||
(interactive)
|
||||
(anything-other-buffer ein:helm-notebook-buffer-sources "*anything ein*"))
|
||||
|
||||
;;;###autoload
|
||||
(defun helm-ein-notebook-buffers ()
|
||||
"Choose opened notebook using helm interface."
|
||||
(interactive)
|
||||
(helm-other-buffer ein:helm-notebook-buffer-sources "*helm ein*"))
|
||||
|
||||
(provide 'ein-helm)
|
||||
;;; ein-helm.el ends here
|
Binary file not shown.
|
@ -1,98 +0,0 @@
|
|||
;;; ein-pager.el --- Pager module
|
||||
|
||||
;; Copyright (C) 2012- Takafumi Arakaki
|
||||
|
||||
;; Author: Takafumi Arakaki <aka.tkf at gmail.com>
|
||||
|
||||
;; This file is NOT part of GNU Emacs.
|
||||
|
||||
;; ein-pager.el 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.
|
||||
|
||||
;; ein-pager.el 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 ein-pager.el. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;;
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'ansi-color)
|
||||
|
||||
(require 'ein-core)
|
||||
(require 'ein-events)
|
||||
(require 'view)
|
||||
|
||||
;; FIXME: Make a class with `:get-notebook-name' slot like `ein:worksheet'
|
||||
|
||||
(declare-function ess-help-underline "ess-help")
|
||||
|
||||
(defun ein:pager-new (name events)
|
||||
;; currently pager = name.
|
||||
(ein:pager-bind-events name events)
|
||||
name)
|
||||
|
||||
(defun ein:pager-bind-events (pager events)
|
||||
"Bind events related to PAGER to the event handler EVENTS."
|
||||
(ein:events-on events
|
||||
'open_with_text.Pager
|
||||
#'ein:pager--open-with-text
|
||||
pager))
|
||||
|
||||
(defun ein:pager--open-with-text (pager data)
|
||||
(let ((text (plist-get data :text)))
|
||||
(unless (equal (ein:trim text) "")
|
||||
(ein:pager-clear pager)
|
||||
(ein:pager-expand pager)
|
||||
(ein:pager-append-text pager text))))
|
||||
|
||||
(defun ein:pager-clear (pager)
|
||||
(ein:with-read-only-buffer (get-buffer-create pager)
|
||||
(erase-buffer)))
|
||||
|
||||
(defun ein:pager-expand (pager)
|
||||
(pop-to-buffer (get-buffer-create pager))
|
||||
(goto-char (point-min)))
|
||||
|
||||
(defun ein:pager-append-text (pager text)
|
||||
(ein:with-read-only-buffer (get-buffer-create pager)
|
||||
(insert (ansi-color-apply text))
|
||||
(if (featurep 'ess-help)
|
||||
(ess-help-underline))
|
||||
(unless (eql 'ein:pager-mode major-mode)
|
||||
(ein:pager-mode))))
|
||||
|
||||
;; FIXME: this should be automatically called when opening pager.
|
||||
(defun ein:pager-goto-docstring-bset-loc ()
|
||||
"Goto the best location of the documentation."
|
||||
(interactive)
|
||||
(goto-char (point-min))
|
||||
(search-forward-regexp "^Docstring:")
|
||||
(beginning-of-line 0)
|
||||
(recenter 0))
|
||||
|
||||
(defvar ein:pager-mode-map
|
||||
(let ((map (make-sparse-keymap)))
|
||||
(define-key map "\C-c\C-b" 'ein:pager-goto-docstring-bset-loc)
|
||||
map)
|
||||
"Keymap for ein:pager-mode.")
|
||||
|
||||
(define-derived-mode ein:pager-mode view-mode "ein:pager"
|
||||
"IPython notebook pager mode.
|
||||
Commands:
|
||||
\\{ein:pager-mode-map}"
|
||||
(setq-local view-no-disable-on-exit t)
|
||||
(font-lock-mode))
|
||||
|
||||
|
||||
(provide 'ein-pager)
|
||||
|
||||
;;; ein-pager.el ends here
|
Binary file not shown.
|
@ -1,47 +0,0 @@
|
|||
;;; ein-pseudo-console.el --- Pseudo console mode
|
||||
|
||||
;; Copyright (C) 2012 Takafumi Arakaki
|
||||
|
||||
;; Author: Takafumi Arakaki <aka.tkf at gmail.com>
|
||||
|
||||
;; This file is NOT part of GNU Emacs.
|
||||
|
||||
;; ein-pseudo-console.el 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.
|
||||
|
||||
;; ein-pseudo-console.el 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 ein-pseudo-console.el.
|
||||
;; If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;;
|
||||
|
||||
;;; Code:
|
||||
|
||||
(defvar ein:pseudo-console-mode-map (make-sparse-keymap))
|
||||
|
||||
(let ((map ein:pseudo-console-mode-map))
|
||||
(define-key map "\C-m" 'ein:worksheet-execute-cell-and-insert-below))
|
||||
|
||||
;;;###autoload
|
||||
(define-minor-mode ein:pseudo-console-mode
|
||||
"Pseudo console mode. Hit RET to execute code."
|
||||
:lighter " ein:pseudo"
|
||||
:keymap ein:pseudo-console-mode-map
|
||||
:group 'ein)
|
||||
|
||||
;; To avoid MuMaMo to discard `ein:pseudo-console-mode', make it
|
||||
;; permanent local.
|
||||
(put 'ein:pseudo-console-mode 'permanent-local t)
|
||||
|
||||
(provide 'ein-pseudo-console)
|
||||
|
||||
;;; ein-pseudo-console.el ends here
|
Binary file not shown.
|
@ -76,33 +76,6 @@ Open a buffer with bug report template.
|
|||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "ein-file" '("ein:" "*ein:file-buffername-template*")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "ein-helm" "ein-helm.el" (0 0 0 0))
|
||||
;;; Generated autoloads from ein-helm.el
|
||||
|
||||
(autoload 'anything-ein-kernel-history "ein-helm" "\
|
||||
Search kernel execution history then insert the selected one.
|
||||
|
||||
\(fn)" t nil)
|
||||
|
||||
(autoload 'helm-ein-kernel-history "ein-helm" "\
|
||||
Search kernel execution history then insert the selected one.
|
||||
|
||||
\(fn)" t nil)
|
||||
|
||||
(autoload 'anything-ein-notebook-buffers "ein-helm" "\
|
||||
Choose opened notebook using anything.el interface.
|
||||
|
||||
\(fn)" t nil)
|
||||
|
||||
(autoload 'helm-ein-notebook-buffers "ein-helm" "\
|
||||
Choose opened notebook using helm interface.
|
||||
|
||||
\(fn)" t nil)
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "ein-helm" '("ein:helm-")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "ein-iexec" "ein-iexec.el" (0 0 0 0))
|
||||
|
@ -352,13 +325,6 @@ and the url-or-port argument of ein:notebooklist-open*.
|
|||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "ein-output-area" '("ein:")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "ein-pager" "ein-pager.el" (0 0 0 0))
|
||||
;;; Generated autoloads from ein-pager.el
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "ein-pager" '("ein:pager-")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "ein-process" "ein-process.el" (0 0 0 0))
|
||||
|
@ -366,19 +332,6 @@ and the url-or-port argument of ein:notebooklist-open*.
|
|||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "ein-process" '("ein:")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "ein-pseudo-console" "ein-pseudo-console.el"
|
||||
;;;;;; (0 0 0 0))
|
||||
;;; Generated autoloads from ein-pseudo-console.el
|
||||
|
||||
(autoload 'ein:pseudo-console-mode "ein-pseudo-console" "\
|
||||
Pseudo console mode. Hit RET to execute code.
|
||||
|
||||
\(fn &optional ARG)" t nil)
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "ein-pseudo-console" '("ein:pseudo-console-mode-map")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "ein-pytools" "ein-pytools.el" (0 0 0 0))
|
|
@ -112,9 +112,6 @@
|
|||
`ein:$notebook-kernelinfo' : `ein:kernelinfo'
|
||||
`ein:kernelinfo' instance.
|
||||
|
||||
`ein:$notebook-pager'
|
||||
Variable for `ein:pager-*' functions. See ein-pager.el.
|
||||
|
||||
`ein:$notebook-dirty' : boolean
|
||||
Set to `t' if notebook has unsaved changes. Otherwise `nil'.
|
||||
|
||||
|
@ -148,7 +145,6 @@
|
|||
kernel
|
||||
kernelinfo
|
||||
kernelspec
|
||||
pager
|
||||
dirty
|
||||
metadata
|
||||
notebook-name
|
Binary file not shown.
|
@ -106,10 +106,6 @@ ERRBACK of arity 1 for the contents."
|
|||
(ein:log 'error notice)
|
||||
(when errback (funcall errback url-or-port status-code)))))))))
|
||||
|
||||
|
||||
;; TODO: This is one place to check for redirects - update the url slot if so.
|
||||
;; Will need to pass the response object and check either request-response-history
|
||||
;; or request-response-url.
|
||||
(cl-defun ein:content-query-contents--success (url-or-port path callback
|
||||
&key data symbol-status response
|
||||
&allow-other-keys)
|
||||
|
@ -117,8 +113,6 @@ ERRBACK of arity 1 for the contents."
|
|||
(if (< (ein:notebook-version-numeric url-or-port) 3)
|
||||
(setq content (ein:new-content-legacy url-or-port path data))
|
||||
(setq content (ein:new-content url-or-port path data)))
|
||||
(aif response
|
||||
(setf (ein:$content-url-or-port content) (ein:get-response-redirect it)))
|
||||
(when callback
|
||||
(funcall callback content))))
|
||||
|
Binary file not shown.
Binary file not shown.
|
@ -49,8 +49,6 @@
|
|||
(require 'ein-scratchsheet)
|
||||
(require 'ein-notification)
|
||||
(require 'ein-completer)
|
||||
(require 'ein-pager)
|
||||
(require 'ein-pseudo-console)
|
||||
(require 'ein-events)
|
||||
(require 'ein-notification)
|
||||
(require 'ein-kill-ring)
|
||||
|
@ -133,8 +131,6 @@ Current buffer for these functions is set to the notebook buffer.")
|
|||
;; is at:
|
||||
;; https://github.com/ipython/ipython/wiki/IPEP-16%3A-Notebook-multi-directory-dashboard-and-URL-mapping
|
||||
|
||||
|
||||
(defvar ein:notebook-pager-buffer-name-template "*ein:pager %s/%s*")
|
||||
(defvar ein:notebook-buffer-name-template "*ein: %s/%s*")
|
||||
|
||||
(ein:deflocal ein:%notebook% nil
|
||||
|
@ -386,14 +382,7 @@ of minor mode."
|
|||
(defun ein:notebook-bind-events (notebook events)
|
||||
"Bind events related to PAGER to the event handler EVENTS."
|
||||
(setf (ein:$notebook-events notebook) events)
|
||||
(ein:worksheet-class-bind-events events)
|
||||
;; Bind events for sub components:
|
||||
(setf (ein:$notebook-pager notebook)
|
||||
(ein:pager-new
|
||||
(format ein:notebook-pager-buffer-name-template
|
||||
(ein:$notebook-url-or-port notebook)
|
||||
(ein:$notebook-notebook-name notebook))
|
||||
(ein:$notebook-events notebook))))
|
||||
(ein:worksheet-class-bind-events events))
|
||||
|
||||
(defalias 'ein:notebook-reconnect-kernel 'ein:notebook-reconnect-session-command "The distinction between kernel and session is a bit mysterious, all the action is now occurring in `ein:notebook-reconnect-session-command' these days, for which this function is now an alias.")
|
||||
|
||||
|
@ -1276,8 +1265,12 @@ Tried add-function: the &rest from :around is an emacs-25 compilation issue."
|
|||
("Execute cell and insert below"
|
||||
ein:worksheet-execute-cell-and-insert-below
|
||||
:active (ein:worksheet-at-codecell-p))
|
||||
("Execute all"
|
||||
ein:worksheet-execute-all-cell)
|
||||
("Execute all cells"
|
||||
ein:worksheet-execute-all-cells)
|
||||
("Execute all cells above"
|
||||
ein:worksheet-execute-all-cells-above)
|
||||
("Execute all cells below"
|
||||
ein:worksheet-execute-all-cells-below)
|
||||
))
|
||||
"---"
|
||||
,@(ein:generate-menu
|
Binary file not shown.
|
@ -228,7 +228,8 @@ See `ein:format-time-string'."
|
|||
(ein:url url-or-port (ein:$content-path content)))
|
||||
(with-current-buffer (ein:notebooklist-get-buffer url-or-port)
|
||||
(let ((restore-point (ein:aand (widget-at)
|
||||
(widget-value it)
|
||||
(aif (widget-value it)
|
||||
(and (stringp it) it))
|
||||
(string-match-p "Open\\|Stop\\|Delete" it)
|
||||
(point))))
|
||||
(aif ein:%notebooklist%
|
Binary file not shown.
|
@ -1,4 +1,4 @@
|
|||
(define-package "ein" "20200202.218" "Emacs IPython Notebook"
|
||||
(define-package "ein" "20200205.1547" "Emacs IPython Notebook"
|
||||
'((emacs "25")
|
||||
(websocket "20190620.338")
|
||||
(anaphora "20180618")
|
|
@ -122,15 +122,6 @@ aborts). Instead you will see Race! in debug messages.
|
|||
(setq settings (plist-put settings :sync ein:force-sync))
|
||||
(apply #'request (url-encode-url url) (ein:query-prepare-header url settings)))
|
||||
|
||||
(defun ein:get-response-redirect (response)
|
||||
"Determine if the query has been redirected, and if so return then URL the request was redirected to."
|
||||
(if (length (request-response-history response))
|
||||
(let ((url (url-generic-parse-url (format "%s" (request-response-url response)))))
|
||||
(format "%s://%s:%s"
|
||||
(url-type url)
|
||||
(url-host url)
|
||||
(url-port url)))))
|
||||
|
||||
;;; Cookie
|
||||
|
||||
(defalias 'ein:query-get-cookie 'request-cookie-string)
|
Binary file not shown.
Binary file not shown.
|
@ -1053,11 +1053,41 @@ cell bellow."
|
|||
(ein:worksheet-get-current-cell)))
|
||||
(ein:worksheet-execute-cell-and-goto-next ws cell t))
|
||||
|
||||
(defun ein:worksheet-execute-all-cell (ws)
|
||||
"Execute all cells in the current worksheet buffer."
|
||||
(define-obsolete-function-alias
|
||||
'ein:worksheet-execute-all-cell 'ein:worksheet-execute-all-cells "0.17.0")
|
||||
|
||||
(cl-defun ein:worksheet-execute-all-cells (ws &key above below)
|
||||
"Execute all cells in the current worksheet buffer.
|
||||
If :above or :below specified, execute above/below the current cell."
|
||||
(interactive (list (ein:worksheet--get-ws-or-error)))
|
||||
(mapc #'ein:cell-execute
|
||||
(seq-filter #'ein:codecell-p (ein:worksheet-get-cells ws))))
|
||||
(let* ((all (seq-filter #'ein:codecell-p (ein:worksheet-get-cells ws)))
|
||||
(current-id (aif (ein:worksheet-get-current-cell) (slot-value it 'cell-id)))
|
||||
(not-matching (apply-partially (lambda (my other)
|
||||
(not (string= (slot-value other 'cell-id) my)))
|
||||
current-id)))
|
||||
(mapc #'ein:cell-execute
|
||||
(if (or above below)
|
||||
(append (when (and current-id above)
|
||||
(aif (seq-take-while not-matching all)
|
||||
it
|
||||
(prog1 nil
|
||||
(ein:log 'info
|
||||
"ein:worksheet-execute-all-cells: no cells above current"))))
|
||||
(when (and current-id below)
|
||||
(seq-drop-while not-matching all)))
|
||||
all))))
|
||||
|
||||
(defun ein:worksheet-execute-all-cells-above (ws)
|
||||
"Execute all cells above the current cell (exclusively) in the
|
||||
current worksheet buffer."
|
||||
(interactive (list (ein:worksheet--get-ws-or-error)))
|
||||
(ein:worksheet-execute-all-cells ws :above t))
|
||||
|
||||
(defun ein:worksheet-execute-all-cells-below (ws)
|
||||
"Execute all cells below the current cell (inclusively) in the
|
||||
current worksheet buffer."
|
||||
(interactive (list (ein:worksheet--get-ws-or-error)))
|
||||
(ein:worksheet-execute-all-cells ws :below t))
|
||||
|
||||
;;; Metadata
|
||||
|
||||
|
@ -1114,40 +1144,6 @@ cell bellow."
|
|||
(indent-rigidly
|
||||
beg end (- (ein:find-leftmost-column beg end)))))
|
||||
|
||||
(defun ein:worksheet--cells-before-cell (ws cell)
|
||||
(let ((cells (ein:worksheet-get-cells ws)))
|
||||
(cl-loop for c in cells
|
||||
collecting c
|
||||
until (eql (ein:cell-id c) (ein:cell-id cell)))))
|
||||
|
||||
(defun ein:worksheet--cells-after-cell (ws cell)
|
||||
(let ((cells (ein:worksheet-get-cells ws))
|
||||
(prior-cells (length (ein:worksheet--cells-before-cell ws cell))))
|
||||
(seq-drop cells prior-cells)))
|
||||
|
||||
(defun ein:worksheet-first-executing-cell (cells)
|
||||
(cl-loop for c in cells
|
||||
when (and (ein:codecell-p c)
|
||||
(slot-value c 'running))
|
||||
return c))
|
||||
|
||||
(defun ein:worksheet-jump-to-first-executing-cell ()
|
||||
"Move the point to the first executing cell in the current worksheet."
|
||||
(interactive)
|
||||
(aif (ein:worksheet-first-executing-cell (ein:worksheet-get-cells ein:%worksheet%))
|
||||
(ein:cell-goto it)
|
||||
(message "No cell currently executing.")))
|
||||
|
||||
(defun ein:worksheet-jump-to-next-executing-cell ()
|
||||
"Move the point to the next executing cell in the current worksheet."
|
||||
(interactive)
|
||||
(let* ((curcell (ein:get-cell-at-point--worksheet))
|
||||
(restcells (ein:worksheet--cells-after-cell ein:%worksheet% curcell)))
|
||||
(aif (ein:worksheet-first-executing-cell restcells)
|
||||
(ein:cell-goto it)
|
||||
(message "No additional cells are executing."))))
|
||||
|
||||
|
||||
;;; Auto-execution
|
||||
|
||||
(defun ein:worksheet-toggle-autoexec (cell)
|
Binary file not shown.
Binary file not shown.
|
@ -96,6 +96,7 @@
|
|||
:foreground ,fui-bg))))
|
||||
`(highlight ((t (:inverse-video nil :background ,fui-asphalt))))
|
||||
`(hl-line ((t (:inverse-video nil :background ,fui-asphalt))))
|
||||
`(widget-field ((t (:background ,fui-dark-concrete))))
|
||||
|
||||
;; Face for specific prog modes
|
||||
`(sh-heredoc ((t (:foreground nil :inherit font-lock-string-face))))
|
||||
|
@ -277,6 +278,11 @@
|
|||
;; Highlight-indent-guides
|
||||
`(highlight-indent-guides-odd-face ((t (:background ,fui-deep-asphalt))))
|
||||
`(highlight-indent-guides-even-face ((t (:background nil))))
|
||||
|
||||
;; Telega
|
||||
`(telega-msg-heading ((t (:background nil :foreground ,fui-emerald :inherit nil))))
|
||||
`(telega-msg-inline-reply ((t (:foreground ,fui-dark-concrete :inherit nil))))
|
||||
`(telega-entity-type-texturl ((t (:inherit nil :foreground ,fui-river))))
|
||||
))
|
||||
|
||||
(provide-theme 'flucui-dark)
|
|
@ -96,6 +96,7 @@
|
|||
:foreground ,fui-clouds))))
|
||||
`(highlight ((t (:inverse-video nil :background ,fui-deep-clouds))))
|
||||
`(hl-line ((t (:inverse-video nil :background ,fui-deep-clouds))))
|
||||
`(widget-field ((t (:background ,fui-concrete))))
|
||||
|
||||
;; Face for specific prog modes
|
||||
`(sh-heredoc ((t (:foreground nil :inherit font-lock-string-face))))
|
||||
|
@ -277,7 +278,12 @@
|
|||
;; Highlight-indent-guides
|
||||
`(highlight-indent-guides-odd-face ((t (:background ,fui-deep-clouds))))
|
||||
`(highlight-indent-guides-even-face ((t (:background nil))))
|
||||
))
|
||||
|
||||
;; Telega
|
||||
`(telega-msg-heading ((t (:background nil :foreground ,fui-dark-emerald :inherit nil))))
|
||||
`(telega-msg-inline-reply ((t (:foreground ,fui-concrete :inherit nil))))
|
||||
`(telega-entity-type-texturl ((t (:inherit nil :foreground ,fui-dark-river))))
|
||||
))
|
||||
|
||||
(provide-theme 'flucui-light)
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
(define-package "flucui-themes" "20190321.2313" "Custom theme inspired by the Flat UI palette"
|
||||
(define-package "flucui-themes" "20200204.1930" "Custom theme inspired by the Flat UI palette"
|
||||
'((emacs "24"))
|
||||
:keywords
|
||||
'("lisp")
|
|
@ -1,2 +0,0 @@
|
|||
;;; -*- no-byte-compile: t -*-
|
||||
(define-package "git-commit" "20200123.1706" "Edit Git commit messages" '((emacs "25.1") (dash "20180910") (transient "20190812") (with-editor "20181103")) :commit "e5e475c61ce568a7e20ed8f795fa343a93632871" :keywords '("git" "tools" "vc") :maintainer '("Jonas Bernoulli" . "jonas@bernoul.li") :url "https://github.com/magit/magit")
|
2
elpa/git-commit-20200204.2012/git-commit-pkg.el
Normal file
2
elpa/git-commit-20200204.2012/git-commit-pkg.el
Normal file
|
@ -0,0 +1,2 @@
|
|||
;;; -*- no-byte-compile: t -*-
|
||||
(define-package "git-commit" "20200204.2012" "Edit Git commit messages" '((emacs "25.1") (dash "20180910") (transient "20190812") (with-editor "20181103")) :commit "bdd2b09e48541ac770b7d16f66d5997b971623f5" :keywords '("git" "tools" "vc") :maintainer '("Jonas Bernoulli" . "jonas@bernoul.li") :url "https://github.com/magit/magit")
|
|
@ -12,7 +12,7 @@
|
|||
;; Maintainer: Jonas Bernoulli <jonas@bernoul.li>
|
||||
|
||||
;; Package-Requires: ((emacs "25.1") (dash "20180910") (transient "20190812") (with-editor "20181103"))
|
||||
;; Package-Version: 20200123.1706
|
||||
;; Package-Version: 20200204.2012
|
||||
;; Keywords: git tools vc
|
||||
;; Homepage: https://github.com/magit/magit
|
||||
|
||||
|
@ -768,6 +768,8 @@ With a numeric prefix ARG, go forward ARG comments."
|
|||
(ignore-errors (car (process-lines "git" "config" "user.email")))
|
||||
(read-string "Email: "))))
|
||||
|
||||
(defvar git-commit-read-ident-history nil)
|
||||
|
||||
(defun git-commit-read-ident (prompt)
|
||||
(if (require 'magit-git nil t)
|
||||
(let ((str (magit-completing-read
|
Binary file not shown.
|
@ -1,349 +0,0 @@
|
|||
;;; js2-imenu-extras.el --- Imenu support for additional constructs
|
||||
|
||||
;; Copyright (C) 2012-2014 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Dmitry Gutov <dgutov@yandex.ru>
|
||||
;; Keywords: languages, javascript, imenu
|
||||
|
||||
;; 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:
|
||||
|
||||
;; This package adds Imenu support for additional framework constructs and
|
||||
;; structural patterns to `js2-mode'.
|
||||
|
||||
;; Usage:
|
||||
|
||||
;; (add-hook 'js2-mode-hook 'js2-imenu-extras-mode)
|
||||
|
||||
;; To customize how it works:
|
||||
;; M-x customize-group RET js2-imenu RET
|
||||
|
||||
(eval-when-compile
|
||||
(require 'cl))
|
||||
|
||||
(require 'js2-mode)
|
||||
|
||||
(defvar js2-imenu-extension-styles
|
||||
`((:framework jquery
|
||||
:call-re "\\_<\\(?:jQuery\\|\\$\\|_\\)\\.extend\\s-*("
|
||||
:recorder js2-imenu-record-jquery-extend)
|
||||
|
||||
(:framework jquery-ui
|
||||
:call-re "^\\s-*\\(?:jQuery\\|\\$\\)\\.widget\\s-*("
|
||||
:recorder js2-imenu-record-string-declare)
|
||||
|
||||
(:framework dojo
|
||||
:call-re "^\\s-*dojo.declare\\s-*("
|
||||
:recorder js2-imenu-record-string-declare)
|
||||
|
||||
(:framework backbone
|
||||
:call-re ,(concat "\\_<" js2-mode-identifier-re "\\.extend\\s-*(")
|
||||
:recorder js2-imenu-record-backbone-extend)
|
||||
|
||||
(:framework enyo
|
||||
:call-re "\\_<enyo\\.kind\\s-*("
|
||||
:recorder js2-imenu-record-enyo-kind)
|
||||
|
||||
(:framework react
|
||||
:call-re "\\_<React\\.createClass\\s-*("
|
||||
:recorder js2-imenu-record-react-class)
|
||||
|
||||
(:framework sencha
|
||||
:call-re "^\\s-*Ext\\.define\\s-*("
|
||||
:recorder js2-imenu-record-sencha-class))
|
||||
"List of JavaScript class definition or extension styles.
|
||||
|
||||
:framework is a valid value in `js2-imenu-enabled-frameworks'.
|
||||
|
||||
:call-re is a regular expression that has no capturing groups.
|
||||
|
||||
:recorder is a function name that will be called when the regular
|
||||
expression matches some text in the buffer. When it's called, point will be
|
||||
at the end of the match. The function must keep the point position.")
|
||||
|
||||
(defconst js2-imenu-available-frameworks
|
||||
(mapcar (lambda (style) (plist-get style :framework)) js2-imenu-extension-styles)
|
||||
"List of available JavaScript framework symbols.")
|
||||
|
||||
(defcustom js2-imenu-enabled-frameworks js2-imenu-available-frameworks
|
||||
"Frameworks to be recognized by `js2-mode'."
|
||||
:type (cons 'set (mapcar (lambda (x) (list 'const x))
|
||||
js2-imenu-available-frameworks))
|
||||
:group 'js2-imenu)
|
||||
|
||||
(defcustom js2-imenu-show-other-functions t
|
||||
"Non-nil to show functions not recognized by other mechanisms,
|
||||
in a shared namespace."
|
||||
:type 'boolean
|
||||
:group 'js2-imenu)
|
||||
|
||||
(defcustom js2-imenu-other-functions-ns "?"
|
||||
"Namespace name to use for other functions."
|
||||
:type 'string
|
||||
:group 'js2-imenu)
|
||||
|
||||
(defcustom js2-imenu-show-module-pattern t
|
||||
"Non-nil to recognize the module pattern:
|
||||
|
||||
var foobs = (function(a) {
|
||||
return {fib: function() {}, fub: function() {}};
|
||||
})(b);
|
||||
|
||||
We record the returned hash as belonging to the named module, and
|
||||
prefix any functions defined inside the IIFE with the module name."
|
||||
:type 'boolean
|
||||
:group 'js2-imenu)
|
||||
|
||||
(defcustom js2-imenu-split-string-identifiers t
|
||||
"When non-nil, split string identifiers on dots.
|
||||
Currently used for jQuery widgets, Dojo and Enyo declarations."
|
||||
:type 'boolean
|
||||
:group 'js2-imenu)
|
||||
|
||||
;;;###autoload
|
||||
(defun js2-imenu-extras-setup ()
|
||||
(when js2-imenu-enabled-frameworks
|
||||
(add-hook 'js2-build-imenu-callbacks 'js2-imenu-record-declarations t t))
|
||||
(when (or js2-imenu-show-other-functions js2-imenu-show-module-pattern)
|
||||
(add-hook 'js2-build-imenu-callbacks 'js2-imenu-walk-ast t t)))
|
||||
|
||||
(defun js2-imenu-extras-remove ()
|
||||
(remove-hook 'js2-build-imenu-callbacks 'js2-imenu-record-declarations t)
|
||||
(remove-hook 'js2-build-imenu-callbacks 'js2-imenu-walk-ast t))
|
||||
|
||||
(defun js2-imenu-record-declarations ()
|
||||
(let* ((styles (loop for style in js2-imenu-extension-styles
|
||||
when (memq (plist-get style :framework)
|
||||
js2-imenu-enabled-frameworks)
|
||||
collect style))
|
||||
(re (mapconcat (lambda (style)
|
||||
(concat "\\(" (plist-get style :call-re) "\\)"))
|
||||
styles "\\|")))
|
||||
(goto-char (point-min))
|
||||
(while (js2-re-search-forward re nil t)
|
||||
(loop for i from 0 to (1- (length styles))
|
||||
when (match-beginning (1+ i))
|
||||
return (funcall (plist-get (nth i styles) :recorder))))))
|
||||
|
||||
(defun js2-imenu-record-jquery-extend ()
|
||||
(let ((pred (lambda (subject)
|
||||
(and
|
||||
(js2-prop-get-node-p subject)
|
||||
(string= (js2-name-node-name (js2-prop-get-node-right subject))
|
||||
"prototype")))))
|
||||
(js2-imenu-record-extend-first-arg (1- (point)) pred
|
||||
'js2-compute-nested-prop-get)))
|
||||
|
||||
(defun js2-imenu-record-string-declare ()
|
||||
(js2-imenu-record-extend-first-arg
|
||||
(1- (point)) 'js2-string-node-p
|
||||
(lambda (node)
|
||||
(if js2-imenu-split-string-identifiers
|
||||
(split-string (js2-string-node-value node) "\\." t)
|
||||
(list (js2-string-node-value node))))))
|
||||
|
||||
(defun js2-imenu-record-extend-first-arg (point pred qname-fn)
|
||||
(let* ((node (js2-node-at-point point))
|
||||
(args (js2-call-node-args node))
|
||||
(subject (first args)))
|
||||
(when (funcall pred subject)
|
||||
(loop for arg in (cdr args)
|
||||
when (js2-object-node-p arg)
|
||||
do (js2-record-object-literal
|
||||
arg (funcall qname-fn subject) (js2-node-abs-pos arg))))))
|
||||
|
||||
(defun js2-imenu-record-backbone-or-react ()
|
||||
(let* ((node (js2-node-at-point (1- (point))))
|
||||
(args (js2-call-node-args node))
|
||||
(methods (first args))
|
||||
(parent (js2-node-parent node)))
|
||||
(when (js2-object-node-p methods)
|
||||
(let ((subject (cond ((js2-var-init-node-p parent)
|
||||
(js2-var-init-node-target parent))
|
||||
((js2-assign-node-p parent)
|
||||
(js2-assign-node-left parent)))))
|
||||
(when subject
|
||||
(js2-record-object-literal methods
|
||||
(js2-compute-nested-prop-get subject)
|
||||
(js2-node-abs-pos methods)))))))
|
||||
|
||||
(defalias 'js2-imenu-record-backbone-extend 'js2-imenu-record-backbone-or-react)
|
||||
|
||||
(defalias 'js2-imenu-record-react-class 'js2-imenu-record-backbone-or-react)
|
||||
|
||||
(defun js2-imenu-record-enyo-kind ()
|
||||
(let* ((node (js2-node-at-point (1- (point))))
|
||||
(args (js2-call-node-args node))
|
||||
(options (first args)))
|
||||
(when (js2-object-node-p options)
|
||||
(let ((name-value
|
||||
(loop for elem in (js2-object-node-elems options)
|
||||
thereis
|
||||
(let ((key (js2-object-prop-node-left elem))
|
||||
(value (js2-object-prop-node-right elem)))
|
||||
(when (and (equal
|
||||
(cond ((js2-name-node-p key)
|
||||
(js2-name-node-name key))
|
||||
((js2-string-node-p key)
|
||||
(js2-string-node-value key)))
|
||||
"name")
|
||||
(js2-string-node-p value))
|
||||
(js2-string-node-value value))))))
|
||||
(when name-value
|
||||
(js2-record-object-literal options
|
||||
(if js2-imenu-split-string-identifiers
|
||||
(split-string name-value "\\.")
|
||||
(list name-value))
|
||||
(js2-node-abs-pos options)))))))
|
||||
|
||||
(defun js2-imenu-record-sencha-class ()
|
||||
(let* ((node (js2-node-at-point (1- (point))))
|
||||
(args (js2-call-node-args node))
|
||||
(name (first args))
|
||||
(methods (second args)))
|
||||
(when (and (js2-string-node-p name) (js2-object-node-p methods))
|
||||
(let ((name-value (js2-string-node-value name)))
|
||||
(js2-record-object-literal methods
|
||||
(if js2-imenu-split-string-identifiers
|
||||
(split-string name-value "\\." t)
|
||||
(list name-value))
|
||||
(js2-node-abs-pos methods))))))
|
||||
|
||||
(defun js2-imenu-walk-ast ()
|
||||
(js2-visit-ast
|
||||
js2-mode-ast
|
||||
(lambda (node end-p)
|
||||
(unless end-p
|
||||
(cond
|
||||
((and js2-imenu-show-other-functions
|
||||
(js2-object-prop-node-p node))
|
||||
(js2-imenu-record-orphan-prop-node-function node))
|
||||
((js2-assign-node-p node)
|
||||
(cond
|
||||
((and js2-imenu-show-other-functions
|
||||
(js2-function-node-p
|
||||
(js2-assign-node-right node)))
|
||||
(js2-imenu-record-orphan-assign-node-function
|
||||
(js2-assign-node-left node)
|
||||
(js2-assign-node-right node)))
|
||||
((and js2-imenu-show-module-pattern
|
||||
(js2-call-node-p
|
||||
(js2-assign-node-right node)))
|
||||
(js2-imenu-record-module-pattern
|
||||
(js2-assign-node-left node)
|
||||
(js2-assign-node-right node)))))
|
||||
((js2-var-init-node-p node)
|
||||
(cond
|
||||
((and js2-imenu-show-other-functions
|
||||
(js2-function-node-p
|
||||
(js2-var-init-node-initializer node)))
|
||||
(js2-imenu-record-orphan-assign-node-function
|
||||
(js2-var-init-node-target node)
|
||||
(js2-var-init-node-initializer node)))
|
||||
((and js2-imenu-show-module-pattern
|
||||
(js2-call-node-p
|
||||
(js2-var-init-node-initializer node)))
|
||||
(js2-imenu-record-module-pattern
|
||||
(js2-var-init-node-target node)
|
||||
(js2-var-init-node-initializer node))))))
|
||||
t))))
|
||||
|
||||
(defun js2-imenu-parent-key-names (node)
|
||||
"Get the list of parent key names of NODE.
|
||||
|
||||
For example, for code
|
||||
|
||||
{rules: {password: {required: function() {}}}}
|
||||
|
||||
when NODE is the inner `js2-object-prop-mode',
|
||||
it returns `(\"rules\" \"password\")'."
|
||||
(let (rlt (n node))
|
||||
(while (setq n (js2-imenu-parent-prop-node n))
|
||||
(push (js2-prop-node-name (js2-object-prop-node-left n)) rlt))
|
||||
rlt))
|
||||
|
||||
(defun js2-imenu-parent-prop-node (node)
|
||||
"When the parent of NODE is `js2-object-node',
|
||||
and the grandparent is `js2-object-prop-node',
|
||||
return the grandparent."
|
||||
;; Suppose the code is:
|
||||
;; {parent-key: {required: function() {}}}
|
||||
;; NODE is `required: function() {}'.
|
||||
(let (p2 p3)
|
||||
;; Parent is `{required: function() {}}'.
|
||||
(setq p2 (js2-node-parent node))
|
||||
;; GP is `parent-key: {required: function() {}}'.
|
||||
(when (and p2 (js2-object-node-p p2))
|
||||
(setq p3 (js2-node-parent p2))
|
||||
(if (and p3 (js2-object-prop-node-p p3)) p3))))
|
||||
|
||||
(defun js2-imenu-record-orphan-prop-node-function (node)
|
||||
"Record orphan function when it's the value of NODE.
|
||||
NODE must be `js2-object-prop-node'."
|
||||
(when (js2-function-node-p (js2-object-prop-node-right node))
|
||||
(let ((fn-node (js2-object-prop-node-right node)))
|
||||
(unless (and js2-imenu-function-map
|
||||
(gethash fn-node js2-imenu-function-map))
|
||||
(let ((key-node (js2-object-prop-node-left node))
|
||||
(parent-prop-node (js2-imenu-parent-prop-node node))
|
||||
chain)
|
||||
(setq chain (nconc (js2-imenu-parent-key-names node)
|
||||
(list (js2-prop-node-name key-node))))
|
||||
(push js2-imenu-other-functions-ns chain)
|
||||
(js2-record-imenu-entry fn-node chain
|
||||
(js2-node-abs-pos key-node)))))))
|
||||
|
||||
(defun js2-imenu-record-orphan-assign-node-function (target-node fn-node)
|
||||
"Record orphan function FN-NODE assigned to node TARGET."
|
||||
(when (or (not js2-imenu-function-map)
|
||||
(eq 'skip
|
||||
(gethash fn-node js2-imenu-function-map 'skip)))
|
||||
(let ((chain (js2-compute-nested-prop-get target-node)))
|
||||
(when chain
|
||||
(push js2-imenu-other-functions-ns chain)
|
||||
(js2-record-imenu-entry fn-node chain (js2-node-abs-pos fn-node))))))
|
||||
|
||||
(defun js2-imenu-record-module-pattern (target init)
|
||||
"Recognize and record module pattern use instance.
|
||||
INIT must be `js2-call-node'."
|
||||
(let ((callt (js2-call-node-target init)))
|
||||
;; Just basic call form: (function() {...})();
|
||||
;; TODO: Handle variations without duplicating `js2-wrapper-function-p'?
|
||||
(when (and (js2-paren-node-p callt)
|
||||
(js2-function-node-p (js2-paren-node-expr callt)))
|
||||
(let* ((fn (js2-paren-node-expr callt))
|
||||
(blk (js2-function-node-body fn))
|
||||
(ret (car (last (js2-block-node-kids blk)))))
|
||||
(when (and (js2-return-node-p ret)
|
||||
(js2-object-node-p (js2-return-node-retval ret)))
|
||||
;; TODO: Map function names when revealing module pattern is used.
|
||||
(let ((retval (js2-return-node-retval ret))
|
||||
(target-qname (js2-compute-nested-prop-get target)))
|
||||
(js2-record-object-literal retval target-qname
|
||||
(js2-node-abs-pos retval))
|
||||
(js2-record-imenu-entry fn target-qname
|
||||
(js2-node-abs-pos target))))))))
|
||||
|
||||
;;;###autoload
|
||||
(define-minor-mode js2-imenu-extras-mode
|
||||
"Toggle Imenu support for frameworks and structural patterns."
|
||||
:lighter ""
|
||||
(if js2-imenu-extras-mode
|
||||
(js2-imenu-extras-setup)
|
||||
(js2-imenu-extras-remove)))
|
||||
|
||||
(provide 'js2-imenu-extras)
|
Binary file not shown.
|
@ -1,85 +0,0 @@
|
|||
;;; js2-mode-autoloads.el --- automatically extracted autoloads
|
||||
;;
|
||||
;;; Code:
|
||||
|
||||
(add-to-list 'load-path (directory-file-name
|
||||
(or (file-name-directory #$) (car load-path))))
|
||||
|
||||
|
||||
;;;### (autoloads nil "js2-imenu-extras" "js2-imenu-extras.el" (0
|
||||
;;;;;; 0 0 0))
|
||||
;;; Generated autoloads from js2-imenu-extras.el
|
||||
|
||||
(autoload 'js2-imenu-extras-setup "js2-imenu-extras" "\
|
||||
|
||||
|
||||
\(fn)" nil nil)
|
||||
|
||||
(autoload 'js2-imenu-extras-mode "js2-imenu-extras" "\
|
||||
Toggle Imenu support for frameworks and structural patterns.
|
||||
|
||||
\(fn &optional ARG)" t nil)
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "js2-imenu-extras" '("js2-imenu-")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "js2-mode" "js2-mode.el" (0 0 0 0))
|
||||
;;; Generated autoloads from js2-mode.el
|
||||
|
||||
(autoload 'js2-highlight-unused-variables-mode "js2-mode" "\
|
||||
Toggle highlight of unused variables.
|
||||
|
||||
\(fn &optional ARG)" t nil)
|
||||
|
||||
(autoload 'js2-minor-mode "js2-mode" "\
|
||||
Minor mode for running js2 as a background linter.
|
||||
This allows you to use a different major mode for JavaScript editing,
|
||||
such as `js-mode', while retaining the asynchronous error/warning
|
||||
highlighting features of `js2-mode'.
|
||||
|
||||
\(fn &optional ARG)" t nil)
|
||||
|
||||
(autoload 'js2-mode "js2-mode" "\
|
||||
Major mode for editing JavaScript code.
|
||||
|
||||
\(fn)" t nil)
|
||||
|
||||
(autoload 'js2-jsx-mode "js2-mode" "\
|
||||
Major mode for editing JSX code in Emacs 26 and earlier.
|
||||
|
||||
To edit JSX code in Emacs 27, use `js-mode' as your major mode
|
||||
with `js2-minor-mode' enabled.
|
||||
|
||||
To customize the indentation for this mode, set the SGML offset
|
||||
variables (`sgml-basic-offset' et al) locally, like so:
|
||||
|
||||
(defun set-jsx-indentation ()
|
||||
(setq-local sgml-basic-offset js2-basic-offset))
|
||||
(add-hook \\='js2-jsx-mode-hook #\\='set-jsx-indentation)
|
||||
|
||||
\(fn)" t nil)
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "js2-mode" '("js2-")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "js2-old-indent" "js2-old-indent.el" (0 0 0
|
||||
;;;;;; 0))
|
||||
;;; Generated autoloads from js2-old-indent.el
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "js2-old-indent" '("js2-")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil nil ("js2-mode-pkg.el") (0 0 0 0))
|
||||
|
||||
;;;***
|
||||
|
||||
;; Local Variables:
|
||||
;; version-control: never
|
||||
;; no-byte-compile: t
|
||||
;; no-update-autoloads: t
|
||||
;; coding: utf-8
|
||||
;; End:
|
||||
;;; js2-mode-autoloads.el ends here
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue