[ELPA-diffs] /srv/bzr/emacs/elpa r260: Add ack
revno: 260 committer: Leo Liu sdl@gmail.com branch nick: elpa timestamp: Mon 2012-10-01 22:18:19 +0800 message: Add ack added: packages/ack/ packages/ack/README.rst packages/ack/ack.el packages/ack/pcmpl-ack.el === added directory 'packages/ack' === added file 'packages/ack/README.rst' --- a/packages/ack/README.rst 1970-01-01 00:00:00 + +++ b/packages/ack/README.rst 2012-10-01 14:18:19 + @@ -0,0 +1,77 @@ +== + Emacs Interface to command-line tool ack +== + +From http://betterthangrep.com/ + +ack is a tool like grep, designed for programmers with large trees +of heterogeneous source code. + +ack is written purely in Perl, and takes advantage of the power of +Perl's regular expressions. + +Feature requests and bug reports are welcome. Thanks. + +Features + + +- Neither ``--nogroup`` nor ``--noheading`` is required +- Handle colors using the standard library ``ansi-color.el`` +- Completion for ack options while reading from the minibuffer +- Support both emacs 23 and 24 + +Screenshots +--- + +.. figure:: http://i.imgur.com/a72Ap.png + :width: 400 px + :target: http://i.imgur.com/a72Ap.png + :alt: ack-emacs23-1.png + + ``ack --column 'ack is.*tool'`` + +.. figure:: http://i.imgur.com/U2vFz.png + :width: 400 px + :target: http://i.imgur.com/U2vFz.png + :alt: ack-emacs23-2.png + + ``ack --column --nogroup --nocolor 'ack is.*tool'`` + +Install +--- + +Place ``ack.el`` in the ``load-path`` and add to your init file:: + + (require 'ack) + +or:: + + (autoload 'ack ack nil t) + +Completion +~~ + +Place ``pcmpl-ack.el`` in the ``load-path`` and add:: + + (autoload 'pcomplete/ack pcmpl-ack) + (autoload 'pcomplete/ack-grep pcmpl-ack) + +to your init file. After this you will be able complete ``ack`` +options while ``M-x ack`` or in shell/eshell. + +Usage +- + +- ``M-x ack`` and provide a pattern to search. +- ``C-u M-x ack`` like ``M-x ack`` but allow you to select a + directory to search. + +While reading ack command and args from the minibuffer, the following +key bindings may be useful: + +- ``M-I`` = insert a template for case-insensitive file name search +- ``TAB`` = completion for ack options + +Contributors + +Phillip Lord === added file 'packages/ack/ack.el' --- a/packages/ack/ack.el 1970-01-01 00:00:00 + +++ b/packages/ack/ack.el 2012-10-01 14:18:19 + @@ -0,0 +1,279 @@ +;;; ack.el --- Emacs interface to ack + +;; Copyright (C) 2012 Leo Liu + +;; Author: Leo Liu sdl@gmail.com +;; Keywords: tools, processes, convenience +;; Created: 2012-03-24 +;; Version: 0.7 + +;; 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: + +;; ack is a tool like grep, designed for programmers with large trees +;; of heterogeneous source code - http://betterthangrep.com/. + +;;; Code: + +(require 'compile) +(require 'ansi-color) +(when (= emacs-major-version 24) + (autoload 'shell-completion-vars shell)) + +(defgroup ack nil + Run `ack' and display the results. + :group 'tools + :group 'processes) + +(defcustom ack-project-pattern-list + (list (concat \\` (regexp-quote dir-locals-file) \\') +\\`Project\\.ede\\' +\\.xcodeproj\\' ; xcode +\\`\\.ropeproject\\'; python rope +;; .git .svn .hg .bzr .CVS +\\`\\.\\(?:CVS\\|bzr\\|git\\|hg\\|svn\\)\\') + A list of regexps that match files in a project root. + :type '(repeat string) + :group 'ack) + +;; Used implicitly by `define-compilation-mode' +(defcustom ack-scroll-output nil + Similar to `compilation-scroll-output' but for the *Ack* buffer. + :type 'boolean + :group 'ack) + +(defcustom ack-command + ;; Note: on GNU/Linux ack may be renamed to ack-grep + (concat (file-name-nondirectory (or (executable-find ack-grep) + (executable-find ack) + ack)) ) + The default ack command for \\[ack]. + +Note also options to ack can be specified in ACK_OPTIONS +environment variable and ~/.ackrc, which you can disable by the +--noenv switch. + :type 'string + :group 'ack) + +;;; END of USER OPTIONS + +(defvar ack-history nil History list for ack.) + +(defvar ack-first-column
[ELPA-diffs] ELPA branch, master, updated. 839ab0cf78b9cd4d35dc760bdff92a4d10536781
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project ELPA. The branch, master has been updated via 839ab0cf78b9cd4d35dc760bdff92a4d10536781 (commit) via 30540f0d8e7edfbdc955e00f5ab4f76b27157f67 (commit) via 04c6addb90fd5763baf28f543a0356d4b3e19dfc (commit) via 841f2678fe49fa1f6ce19fcaadf90f2d36bf10df (commit) via 40d439b14842f8658b2ecc12cd7c43f8a4da73b6 (commit) from 0a76035422903c12a6ad6e9d26244b8ddafec59f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log - commit 839ab0cf78b9cd4d35dc760bdff92a4d10536781 Author: Leo Liu sdl@gmail.com Date: Sun Aug 18 11:56:53 2013 +0800 Add temp-buffer-browse to externals-list diff --git a/externals-list b/externals-list index ef40b34..ac809e6 100644 --- a/externals-list +++ b/externals-list @@ -29,6 +29,7 @@ (ioccur :subtree https://github.com/thierryvolpiatto/ioccur.git;) (js2-mode :subtree https://github.com/mooz/js2-mode.git;) ;;FIXME:(org:external ??) ;; Need to introduce snapshots!! + (temp-buffer-browse :subtree https://github.com/leoliu/temp-buffer-browse;) ;;FIXME:(vlf:subtree ??) (websocket :subtree https://github.com/ahyatt/emacs-websocket.git;) ;;FIXME:(yasnippet :subtree https://github.com/capitaomorte/yasnippet.git;) commit 30540f0d8e7edfbdc955e00f5ab4f76b27157f67 Merge: 0a76035 04c6add Author: Leo Liu sdl@gmail.com Date: Sun Aug 18 11:54:38 2013 +0800 Merge temp-buffer-browse as our subdirectory diff --cc packages/temp-buffer-browse/Makefile index 000,02fbd33..02fbd33 mode 00,100644..100644 --- a/packages/temp-buffer-browse/Makefile +++ b/packages/temp-buffer-browse/Makefile diff --cc packages/temp-buffer-browse/README.rst index 000,2b96bcd..2b96bcd mode 00,100644..100644 --- a/packages/temp-buffer-browse/README.rst +++ b/packages/temp-buffer-browse/README.rst diff --cc packages/temp-buffer-browse/temp-buffer-browse.el index 000,d58e9d9..d58e9d9 mode 00,100644..100644 --- a/packages/temp-buffer-browse/temp-buffer-browse.el +++ b/packages/temp-buffer-browse/temp-buffer-browse.el commit 04c6addb90fd5763baf28f543a0356d4b3e19dfc Author: Leo Liu sdl@gmail.com Date: Fri Aug 16 12:58:12 2013 +0800 Fixes for GNU ELPA diff --git a/README.rst b/README.rst index ede4578..2b96bcd 100644 --- a/README.rst +++ b/README.rst @@ -6,6 +6,11 @@ Allow keys ``SPC``, ``DEL`` and ``RET`` immediately following a temp buffer popup to scroll up, scroll down and close the temp buffer window, respectively. +This package is part of `GNU ELPA http://elpa.gnu.org`_ +(``M-x list-packages``). + +Patches, feature requests and bug reports are welcome. Thanks. + To use ~~ diff --git a/temp-buffer-browse.el b/temp-buffer-browse.el index 0d5c38a..d58e9d9 100644 --- a/temp-buffer-browse.el +++ b/temp-buffer-browse.el @@ -1,6 +1,6 @@ ;;; temp-buffer-browse.el --- temp buffer browse mode -*- lexical-binding: t; -*- -;; Copyright (C) 2013 Leo Liu +;; Copyright (C) 2013 Free Software Foundation, Inc. ;; Author: Leo Liu sdl@gmail.com ;; Version: 1.0 commit 841f2678fe49fa1f6ce19fcaadf90f2d36bf10df Author: Leo Liu sdl@gmail.com Date: Wed Aug 14 11:00:28 2013 +0800 Override all variants of RET and DEL keys diff --git a/temp-buffer-browse.el b/temp-buffer-browse.el index e8e1051..0d5c38a 100644 --- a/temp-buffer-browse.el +++ b/temp-buffer-browse.el @@ -63,26 +63,29 @@ non-nil then MAP stays active. (defvar temp-buffer-browse--window nil) (defvar temp-buffer-browse-map - (let ((map (make-sparse-keymap))) -(define-key map \C-m - (lambda () -(interactive) -(when (window-live-p temp-buffer-browse--window) - (quit-window nil temp-buffer-browse--window -(define-key map - (lambda () -(interactive) -(when (window-live-p temp-buffer-browse--window) - (with-selected-window temp-buffer-browse--window -(condition-case nil -(scroll-up) - (end-of-buffer (quit-window))) -(define-key map (kbd DEL) - (lambda () -(interactive) -(when (window-live-p temp-buffer-browse--window) - (with-selected-window temp-buffer-browse--window -(scroll-up '-) + (let ((map (make-sparse-keymap)) +(quit (lambda () +(interactive) +(when (window-live-p temp-buffer-browse--window) + (quit-window nil temp-buffer-browse--window +(up (lambda () + (interactive) + (when (window-live-p temp-buffer-browse--window) +(with-selected-window temp-buffer-browse
[ELPA-diffs] ELPA branch, master, updated. afa778dbeac52aed1d1c57a9daadd2eea204bb56
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project ELPA. The branch, master has been updated via afa778dbeac52aed1d1c57a9daadd2eea204bb56 (commit) from 1fda620165a21c3bcc7f1c7fb2165cdbd9a1fd5e (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log - commit afa778dbeac52aed1d1c57a9daadd2eea204bb56 Author: Leo Liu sdl@gmail.com Date: Thu Sep 5 09:52:09 2013 +0800 * xclip.el: Some cleanups and fix copyright years. (xclip-program, xclip-select-enable-clipboard): Use defcustom. (xclip-select-text): Cleanup. (turn-off-xclip): Remove. (xclip-mode): Check xclip-program here. diff --git a/packages/xclip/xclip.el b/packages/xclip/xclip.el index 27512f3..d08dcd2 100644 --- a/packages/xclip/xclip.el +++ b/packages/xclip/xclip.el @@ -1,11 +1,11 @@ -;;; xclip.el --- Emacs Interface to XClip +;;; xclip.el --- use xclip to copypaste -*- lexical-binding: t; -*- -;; Copyright (C) 2007, 2012 Free Software Foundation, Inc. +;; Copyright (C) 2007, 2012, 2013 Free Software Foundation, Inc. ;; Author: Leo Liu sdl@gmail.com ;; Keywords: convenience, tools ;; Created: 2007-12-30 -;; Version: 1.0 +;; Version: 1.1 ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -22,17 +22,24 @@ ;;; Commentary: -;; This code provides an Emacs interface to the tool with the same -;; name on http://people.debian.org/~kims/xclip/. -;; Just add (xclip-mode 1) to your ~/.emacs. +;; This package allows emacs to copy to and paste from the X clipboard +;; when running in xterm. It uses the external command-line tool xclip +;; found on http://xclip.sourceforge.net. +;; +;; To use: (xclip-mode 1) ;;; Code: -(defvar xclip-program xclip - Name of XClip program tool.) -(defvar xclip-select-enable-clipboard t +(defcustom xclip-program xclip + Name of the xclip program. + :type 'string + :group 'killing) + +(defcustom xclip-select-enable-clipboard t Non-nil means cutting and pasting uses the clipboard. -This is in addition to, but in preference to, the primary selection.) +This is in addition to, but in preference to, the primary selection. + :type 'boolean + :group 'killing) (defvar xclip-last-selected-text-clipboard nil The value of the CLIPBOARD X selection from xclip.) @@ -43,15 +50,15 @@ This is in addition to, but in preference to, the primary selection.) (defun xclip-set-selection (type data) TYPE is a symbol: primary, secondary and clipboard. -See `x-set-selection'. - (when (and (executable-find xclip-program) (getenv DISPLAY)) +See also `x-set-selection'. + (when (getenv DISPLAY) (let* ((process-connection-type nil) (proc (start-process xclip nil xclip-program -selection (symbol-name type (process-send-string proc data) (process-send-eof proc -(defun xclip-select-text (text optional push) +(defun xclip-select-text (text) See `x-select-text'. (xclip-set-selection 'primary text) (setq xclip-last-selected-text-primary text) @@ -60,53 +67,56 @@ See `x-set-selection'. (setq xclip-last-selected-text-clipboard text))) (defun xclip-selection-value () - See `x-cut-buffer-or-selection-value'. - (when (and (executable-find xclip-program) (getenv DISPLAY)) -(let (clip-text primary-text) - (when xclip-select-enable-clipboard -(setq clip-text (shell-command-to-string - (concat (shell-quote-argument xclip-program) - -o -selection clipboard))) -(setq clip-text - (cond ;; check clipboard selection - ((or (not clip-text) (string= clip-text )) -(setq xclip-last-selected-text-primary nil)) - ((eq clip-text xclip-last-selected-text-clipboard) nil) - ((string= clip-text xclip-last-selected-text-clipboard) -;; Record the newer string, -;; so subsequent calls can use the `eq' test. -(setq xclip-last-selected-text-clipboard clip-text) -nil) - (t (setq xclip-last-selected-text-clipboard clip-text) - (setq primary-text (shell-command-to-string - (concat (shell-quote-argument xclip-program) -o))) - (setq primary-text -(cond ;; check primary selection - ((or (not primary-text) (string= primary-text )) - (setq xclip-last-selected-text-primary nil)) - ((eq primary-text xclip-last-selected-text-primary) nil) - ((string= primary-text xclip-last-selected-text-primary
[ELPA-diffs] ELPA branch, master, updated. f160382d9dd3acb36f562e82993e07765411c354
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project ELPA. The branch, master has been updated via f160382d9dd3acb36f562e82993e07765411c354 (commit) from afa778dbeac52aed1d1c57a9daadd2eea204bb56 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log - commit f160382d9dd3acb36f562e82993e07765411c354 Author: Leo Liu sdl@gmail.com Date: Fri Sep 6 12:32:20 2013 +0800 * xclip.el: Use pbcopy and pbpaste if available (xclip-use-pbcopypaste): New variable. (xclip-set-selection, xclip-selection-value, xclip-mode): Use it. diff --git a/packages/xclip/xclip.el b/packages/xclip/xclip.el index d08dcd2..bc9b640 100644 --- a/packages/xclip/xclip.el +++ b/packages/xclip/xclip.el @@ -5,7 +5,7 @@ ;; Author: Leo Liu sdl@gmail.com ;; Keywords: convenience, tools ;; Created: 2007-12-30 -;; Version: 1.1 +;; Version: 1.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 @@ -41,6 +41,15 @@ This is in addition to, but in preference to, the primary selection. :type 'boolean :group 'killing) +(defcustom xclip-use-pbcopypaste (and xclip-select-enable-clipboard + (eq system-type 'darwin) + (executable-find pbcopy) + t) + Non-nil means using pbcopy and pbpaste instead of xclip. +If non-nil `xclip-program' is ignored. + :type 'boolean + :group 'killing) + (defvar xclip-last-selected-text-clipboard nil The value of the CLIPBOARD X selection from xclip.) @@ -51,12 +60,17 @@ This is in addition to, but in preference to, the primary selection. TYPE is a symbol: primary, secondary and clipboard. See also `x-set-selection'. - (when (getenv DISPLAY) -(let* ((process-connection-type nil) - (proc (start-process xclip nil xclip-program --selection (symbol-name type + (let* ((process-connection-type nil) + (proc (cond +(xclip-use-pbcopypaste + (start-file-process pbcopy nil pbcopy)) +((getenv DISPLAY) + (start-file-process xclip nil xclip-program + -selection (symbol-name type)) +(when proc (process-send-string proc data) - (process-send-eof proc + (process-send-eof proc)) +data)) (defun xclip-select-text (text) See `x-select-text'. @@ -68,24 +82,28 @@ See also `x-set-selection'. (defun xclip-selection-value () See `x-selection-value'. - (when (getenv DISPLAY) -(let ((clip-text (when xclip-select-enable-clipboard - (with-output-to-string + (let ((clip-text (when xclip-select-enable-clipboard + (with-output-to-string + (cond +(xclip-use-pbcopypaste + (process-file pbpaste nil standard-output nil)) +((getenv DISPLAY) (process-file xclip-program nil standard-output nil - -o -selection clipboard) - (setq clip-text -(cond ; Check clipboard selection. - ((or (not clip-text) (string= clip-text )) - (setq xclip-last-selected-text-clipboard nil)) - ((eq clip-text xclip-last-selected-text-clipboard) - nil) - ((string= clip-text xclip-last-selected-text-clipboard) - ;; Record the newer string so subsequent calls can use - ;; the `eq' test. - (setq xclip-last-selected-text-clipboard clip-text) - nil) - (t (setq xclip-last-selected-text-clipboard clip-text - (or clip-text + -o -selection clipboard))) +(setq clip-text + (cond ; Check clipboard selection. + ((or (not clip-text) (string= clip-text )) +(setq xclip-last-selected-text-clipboard nil)) + ((eq clip-text xclip-last-selected-text-clipboard) +nil) + ((string= clip-text xclip-last-selected-text-clipboard) +;; Record the newer string so subsequent calls can use the +;; `eq' test. +(setq xclip-last-selected-text-clipboard clip-text) +nil) + (t (setq xclip-last-selected-text-clipboard clip-text +(or clip-text +(when (getenv DISPLAY) (let ((primary-text (with-output-to-string (process-file xclip-program nil
[ELPA-diffs] ELPA branch, master, updated. 474e61713d53a2e66c5739c0c1c595d56ae86e7e
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project ELPA. The branch, master has been updated via 474e61713d53a2e66c5739c0c1c595d56ae86e7e (commit) via 3f1ef74d8fc32f7d9f06ad04f6a9a4f67401d4d0 (commit) via c6134f968d738afd21f938396eb961c0053be033 (commit) via b77a4262aad1b61378a3e7615d1b59de7b90d82c (commit) via efea1b385e5b9d9160e3dd7fa073990cd526 (commit) via b15f2f357fa74d1fc74b74faea3b975c0ee548d6 (commit) from 58a6b636e221bb75c649ff567efcaae28257f039 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log - commit 474e61713d53a2e66c5739c0c1c595d56ae86e7e Merge: 58a6b63 3f1ef74 Author: Leo Liu sdl@gmail.com Date: Sun Nov 3 10:19:14 2013 +0800 Merge branch 'master' of https://github.com/leoliu/temp-buffer-browse commit 3f1ef74d8fc32f7d9f06ad04f6a9a4f67401d4d0 Author: Leo Liu sdl@gmail.com Date: Tue Oct 29 10:21:03 2013 +0800 Don't set wrap-prefix in adaptive-wrap-prefix-mode diff --git a/temp-buffer-browse.el b/temp-buffer-browse.el index 6b62c8b..da2fb73 100644 --- a/temp-buffer-browse.el +++ b/temp-buffer-browse.el @@ -131,7 +131,11 @@ scroll down and close the temp buffer window, respectively. (unless (zerop (or (frame-parameter nil 'left-fringe) 0)) `(left-fringe ,temp-buffer-browse-fringe-bitmap warning)) 'face 'warning)) - (overlay-put o 'wrap-prefix (overlay-get o 'line-prefix)) + ;; NOTE: breaks `adaptive-wrap-prefix-mode' because overlay's + ;; wrap-prefix overrides text property's. Overlay's cannot have + ;; negative priority. + (unless (bound-and-true-p adaptive-wrap-prefix-mode) +(overlay-put o 'wrap-prefix (overlay-get o 'line-prefix))) (set-temporary-overlay-map temp-buffer-browse-map (lambda () commit c6134f968d738afd21f938396eb961c0053be033 Author: Leo Liu sdl@gmail.com Date: Tue Oct 15 15:13:58 2013 +0800 Rename temp-buffer-browse-setup to temp-buffer-browse-activate and autoload since it may be useful in places other than temp-buffer-show-hook. diff --git a/temp-buffer-browse.el b/temp-buffer-browse.el index 22970fc..6b62c8b 100644 --- a/temp-buffer-browse.el +++ b/temp-buffer-browse.el @@ -99,10 +99,11 @@ non-nil then MAP stays active. (define-key map [backspace] down) map)) -(defun temp-buffer-browse-setup () - Browse temp buffers easily. -Set up `SPC', `DEL' and `RET' to scroll up, scroll down and close -the temp buffer window, respectively. +;;;###autoload +(defun temp-buffer-browse-activate () + Activate temporary key bindings for current window. +Specifically set up keys `SPC', `DEL' and `RET' to scroll up, +scroll down and close the temp buffer window, respectively. (unless (derived-mode-p 'completion-list-mode) (setq temp-buffer-browse--window (selected-window)) ;; When re-using existing window don't call @@ -148,8 +149,8 @@ the temp buffer window, respectively. :lighter :global t (if temp-buffer-browse-mode - (add-hook 'temp-buffer-show-hook 'temp-buffer-browse-setup t) -(remove-hook 'temp-buffer-show-hook 'temp-buffer-browse-setup))) + (add-hook 'temp-buffer-show-hook 'temp-buffer-browse-activate t) +(remove-hook 'temp-buffer-show-hook 'temp-buffer-browse-activate))) (provide 'temp-buffer-browse) ;;; temp-buffer-browse.el ends here commit b77a4262aad1b61378a3e7615d1b59de7b90d82c Author: Leo Liu sdl@gmail.com Date: Mon Oct 14 20:38:32 2013 +0800 Also set the overlay's wrap-prefix property diff --git a/temp-buffer-browse.el b/temp-buffer-browse.el index 2e8f40b..22970fc 100644 --- a/temp-buffer-browse.el +++ b/temp-buffer-browse.el @@ -130,6 +130,7 @@ the temp buffer window, respectively. (unless (zerop (or (frame-parameter nil 'left-fringe) 0)) `(left-fringe ,temp-buffer-browse-fringe-bitmap warning)) 'face 'warning)) + (overlay-put o 'wrap-prefix (overlay-get o 'line-prefix)) (set-temporary-overlay-map temp-buffer-browse-map (lambda () @@ -139,7 +140,8 @@ the temp buffer window, respectively. (not (member (this-command-keys) '(\C-m [return]))) (eq this-command (lookup-key temp-buffer-browse-map (this-command-keys - (ignore (overlay-put o 'line-prefix nil) + (ignore (overlay-put o 'line-prefix nil) + (overlay-put o 'wrap-prefix nil) ;;;###autoload (define-minor-mode temp-buffer-browse-mode nil commit efea1b385e5b9d9160e3dd7fa073990cd526
[ELPA-diffs] ELPA branch, master, updated. bf2657fc3752d09361f343b5a7447c2e54765bd9
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project ELPA. The branch, master has been updated via bf2657fc3752d09361f343b5a7447c2e54765bd9 (commit) via 8a45c276b87a3b0ba0fdcb09e0ff70313dc271c0 (commit) via 74fb9433202488c68ae247cc85da49fbe35a9d87 (commit) via 890608ec5ffedcdc15225cc210807793fc09d6d7 (commit) via bffbca81295cff21855082f2998fc7d82d178964 (commit) via 275a592f7094ab70d5aa7d354af7e08dfbe1ae8d (commit) via 92b98d610881b91f655b88ea129712d59729c56e (commit) via 6721c0235ff0ebaea3694f8cbda4af028c055ffc (commit) via 7ed30d135e6c9ab130b5739b52b7613604110593 (commit) via 62f43bb4bf0ac3c0a68d2278528ec69b219dfb9a (commit) via af06ad0fefa2445fd191d05ea39195428faa (commit) via b6005f785e6d320dd061164c772aa9ff9b8e18dc (commit) from 9cb8d5c83a8fabb80576937e7a0df0b2a4389665 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log - commit bf2657fc3752d09361f343b5a7447c2e54765bd9 Merge: 9cb8d5c 8a45c27 Author: Leo Liu sdl@gmail.com Date: Tue Nov 5 13:08:39 2013 +0800 Merge branch 'master' of github.com:leoliu/ggtags commit 8a45c276b87a3b0ba0fdcb09e0ff70313dc271c0 Author: Leo Liu sdl@gmail.com Date: Tue Nov 5 12:59:59 2013 +0800 Doc fix diff --git a/README.rst b/README.rst index 5d079af..e148361 100644 --- a/README.rst +++ b/README.rst @@ -13,14 +13,19 @@ Patches, feature requests and bug reports are welcome. Thanks. Features -#. Automatically run ``global -u`` when needed -#. Highlight valid tag at point -#. Built on top of ``compile.el`` (asynchonrous and other nice - features) +#. Automatically update Global's tag files when needed with tuning for + large source trees. +#. Build on ``compile.el`` for asynchrony and its large feature-set. +#. Intuitive navigation among multiple matches with mode-line display + of current match, total matches and exit status. +#. Manage Global's environment variables on a per-project basis. +#. Support all Global search backends: ``grep``, ``idutils`` etc. +#. Query replace. +#. Highlight tag at point. +#. Abbreviated display of file names. #. Support `exuberant ctags http://ctags.sourceforge.net/`_ backend. -#. Support all output formats of ``global``: ``grep``, ``ctags-x``, +#. Support all Global's output formats: ``grep``, ``ctags-x``, ``cscope`` etc. -#. Abbreviated display of file names Why GNU Global ~~ @@ -32,9 +37,9 @@ between a few tools. Screenshot ~~ -.. figure:: http://i.imgur.com/d430rmm.png +.. figure:: http://i.imgur.com/lwED3aD.png :width: 500px - :target: http://i.imgur.com/d430rmm.png + :target: http://i.imgur.com/lwED3aD.png :alt: ggtags.png Config diff --git a/ggtags.el b/ggtags.el index a5a226e..96e1780 100644 --- a/ggtags.el +++ b/ggtags.el @@ -3,7 +3,7 @@ ;; Copyright (C) 2013 Free Software Foundation, Inc. ;; Author: Leo Liu sdl@gmail.com -;; Version: 0.7.0 +;; Version: 0.7.1 ;; Keywords: tools, convenience ;; Created: 2013-01-29 ;; URL: https://github.com/leoliu/ggtags commit 74fb9433202488c68ae247cc85da49fbe35a9d87 Author: Leo Liu sdl@gmail.com Date: Tue Nov 5 12:00:18 2013 +0800 Set Global's environment variables on a per-project basis New command ggtags-save-project-settings. diff --git a/ggtags.el b/ggtags.el index 3a191e2..a5a226e 100644 --- a/ggtags.el +++ b/ggtags.el @@ -86,6 +86,26 @@ Face used to highlight matched line in Global buffer. :group 'ggtags) +(defcustom ggtags-oversize-limit (* 50 1024 1024) + The over size limit for the GTAGS file. +For large source trees, running 'global -u' can be expensive. +Thus when GTAGS file is larger than this limit, ggtags +automatically switches to 'global --single-update'. + :safe 'numberp + :type '(choice (const :tag None nil) + (const :tag Always t) + number) + :group 'ggtags) + +(defcustom ggtags-process-environment nil + Similar to `process-environment' with higher precedence. +Elements are run through `substitute-env-vars' before use. +This is intended for project-wise ggtags-specific process +environment settings. + :safe 'ggtags-list-of-string-p + :type '(repeat string) + :group 'ggtags) + (defcustom ggtags-auto-jump-to-first-match t Non-nil to automatically jump to the first match. :type 'boolean @@ -105,13 +125,6 @@ If an integer abbreviate only names longer than that number. integer) :group 'ggtags) -(defcustom ggtags-oversize-limit (* 50 1024 1024) - The over size limit for the GTAGS file. - :type '(choice (const :tag None nil) - (const :tag Always t) - number
[ELPA-diffs] ELPA branch, master, updated. 5a3d6b937f455e75253f6736ba58a4dfb786721a
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project ELPA. The branch, master has been updated via 5a3d6b937f455e75253f6736ba58a4dfb786721a (commit) via 8cc4ff9ea47d264ba9641a60bcdb71a085aebf9b (commit) via 9558ce187af9fc691a70f24c32451ee7c9f9367f (commit) via 83b9cd31f5bc481907a35e4a3ba4e0c25b033c43 (commit) via 2ea72495010241cb7226da02410d1f0a47155b8f (commit) via 183b5ace2f20820cf0f149d720fdfb65a818d94d (commit) via ed850b0addb1d1bcabeefac962753247762a07ac (commit) via ef8a5a32879310352ad47ede55b828ebbe21d7b0 (commit) via c715ba62b542d2a4ad131ab2e9f0756cfa5bc65a (commit) from 76e545724e00d7874cc9b0ca01269b9e6cc8e493 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log - commit 5a3d6b937f455e75253f6736ba58a4dfb786721a Merge: 76e5457 8cc4ff9 Author: Leo Liu sdl@gmail.com Date: Tue Dec 3 16:33:46 2013 +0800 Merge branch 'master' of github.com:leoliu/ggtags commit 8cc4ff9ea47d264ba9641a60bcdb71a085aebf9b Author: Leo Liu sdl@gmail.com Date: Tue Dec 3 10:30:35 2013 +0800 Also remove Using default configuration. in the output diff --git a/ggtags.el b/ggtags.el index 2678943..f01400c 100644 --- a/ggtags.el +++ b/ggtags.el @@ -907,9 +907,11 @@ Global and Emacs. (defun ggtags-global-filter () Called from `compilation-filter-hook' (which see). - ;; Get rid of line Using config file '/PATH/TO/.globalrc'. - (when (re-search-backward ^ *Using config file '.*\n -compilation-filter-start t) + ;; Get rid of line Using config file '/PATH/TO/.globalrc'. or + ;; Using default configuration. + (when (re-search-backward + ^ *Using \\(?:config file '.*\\|default configuration.\\)\n + compilation-filter-start t) (replace-match )) (ansi-color-apply-on-region compilation-filter-start (point)) (incf ggtags-global-output-lines commit 9558ce187af9fc691a70f24c32451ee7c9f9367f Author: Leo Liu sdl@gmail.com Date: Tue Dec 3 10:23:41 2013 +0800 Fix due to renaming no-display-ok to allow-no-window diff --git a/README.rst b/README.rst index bf02638..21595df 100644 --- a/README.rst +++ b/README.rst @@ -38,9 +38,9 @@ between a few tools. Screenshot ~~ -.. figure:: http://i.imgur.com/lwED3aD.png +.. figure:: http://i.imgur.com/E5Gr56m.png :width: 500px - :target: http://i.imgur.com/lwED3aD.png + :target: http://i.imgur.com/E5Gr56m.png :alt: ggtags.png Config diff --git a/ggtags.el b/ggtags.el index 403e690..2678943 100644 --- a/ggtags.el +++ b/ggtags.el @@ -530,12 +530,10 @@ non-nil. (display-buffer-overriding-action (if (not ggtags-auto-jump-to-first-match) display-buffer-overriding-action -(cons (lambda (buf action) -(and (assq 'no-display-ok (cdr action)) - (with-current-buffer buf - (derived-mode-p 'ggtags-global-mode - ;; Suppress `display-buffer'. - (list (lambda (rest _) 'dont-display)) +(cons (lambda (buf _action) +(with-current-buffer buf + (derived-mode-p 'ggtags-global-mode))) + (list #'display-buffer-no-window) (setq ggtags-global-start-marker (point-marker)) (ggtags-navigation-mode +1) (setq ggtags-global-exit-status 0 @@ -919,7 +917,7 @@ Global and Emacs. (when (and ( ggtags-global-output-lines 5) (not (get-buffer-window (current-buffer (let* ((split-window-preferred-function ggtags-split-window-function) - (w (display-buffer (current-buffer) '(nil (no-display-ok . t) + (w (display-buffer (current-buffer) '(nil (allow-no-window . t) (and w (compilation-set-window-height w (make-local-variable 'ggtags-global-large-output) (when ( ggtags-global-output-lines ggtags-global-large-output) commit 83b9cd31f5bc481907a35e4a3ba4e0c25b033c43 Author: Leo Liu sdl@gmail.com Date: Wed Nov 20 22:52:34 2013 +0800 Customisable use of tag table for completion at point diff --git a/ggtags.el b/ggtags.el index 6dbe59e..403e690 100644 --- a/ggtags.el +++ b/ggtags.el @@ -189,6 +189,12 @@ properly update `ggtags-mode-map'. :type 'key-sequence :group 'ggtags) +(defcustom ggtags-enable-completion-at-point t + Non-nil to enable completion at point using the tag table. + :safe 'booleanp + :type 'boolean + :group 'ggtags) + (defcustom ggtags-completing-read-function completing-read-function Ggtags specific `completing-read-function' (which see). :type 'function @@ -463,6 +469,12 @@ non-nil. \n t
[elpa] 09/09: Merge remote-tracking branch 'ggtags/master'
leoliu pushed a commit to branch master in repository elpa. commit 2e6b4f66cf6bc14868f23a350063922de3b37d0c Merge: 29cc746 3686751 Author: Leo Liu sdl@gmail.com Date: Tue Feb 18 10:55:23 2014 +0800 Merge remote-tracking branch 'ggtags/master' packages/ggtags/ggtags.el | 129 +--- 1 files changed, 73 insertions(+), 56 deletions(-)
[elpa] branch master updated (29cc746 - 2e6b4f6)
leoliu pushed a change to branch master in repository elpa. from 29cc746 Merge commit '10258cb25d28c49198cc50a79cc3825d8ad5db22' from diff-hl new 6f464be Force ggtags-update-tags when called interactively new cc1a00e Fix misuse of display-buffer-overriding-action new 5cdfab7 Fix #31: Avoid `-d' switch for compatibility new e2f0d3b Expire project info in ggtags-update-tags new 493a7a3 Remove side-effect from ggtags-with-process-environment new 5a3c24a Fix last change new ef17941 Rename ggtags-with-process-environment new 3686751 Fix #32: handle upstream change in query-replace-read-args new 2e6b4f6 Merge remote-tracking branch 'ggtags/master' The 9 revisions listed above as new are entirely new to this repository and will be described in separate emails. The revisions listed as adds were already present in the repository and have only been added to this reference. Summary of changes: packages/ggtags/ggtags.el | 129 +--- 1 files changed, 73 insertions(+), 56 deletions(-)
[elpa] 08/09: Fix #32: handle upstream change in query-replace-read-args
leoliu pushed a commit to branch master in repository elpa. commit 3686751d64c3b61c7c62639ae5fdea02d0fca1d0 Author: Leo Liu sdl@gmail.com Date: Tue Feb 18 00:18:15 2014 +0800 Fix #32: handle upstream change in query-replace-read-args --- ggtags.el |5 - 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/ggtags.el b/ggtags.el index c381c3c..1cd40bf 100644 --- a/ggtags.el +++ b/ggtags.el @@ -657,7 +657,10 @@ If not in navigation mode, do a grep on FROM first. Note: the regular expression FROM must be supported by both Global and Emacs. - (interactive (query-replace-read-args Query replace (regexp) t t)) + (interactive + ;; Note: in 24.4 query-replace-read-args returns a list of 4 elements. + (let ((args (query-replace-read-args Query replace (regexp) t t))) + (list (nth 0 args) (nth 1 args) (nth 2 args (unless (bound-and-true-p ggtags-navigation-mode) (let ((ggtags-auto-jump-to-first-match nil)) (ggtags-grep from)))
[elpa] 07/09: Rename ggtags-with-process-environment
leoliu pushed a commit to branch master in repository elpa. commit ef1794153540f46d2d7e294932547c6eeff3b5a4 Author: Leo Liu sdl@gmail.com Date: Mon Feb 17 11:00:22 2014 +0800 Rename ggtags-with-process-environment to ggtags-with-current-project. --- ggtags.el | 19 ++- 1 files changed, 10 insertions(+), 9 deletions(-) diff --git a/ggtags.el b/ggtags.el index 87d7127..c381c3c 100644 --- a/ggtags.el +++ b/ggtags.el @@ -355,7 +355,7 @@ properly update `ggtags-mode-map'. (ggtags-check-project) (let* ((inhibit-read-only t) ; for `add-dir-local-variable' (default-directory (ggtags-current-project-root)) - ;; Not using `ggtags-with-process-environment' to preserve + ;; Not using `ggtags-with-current-project' to preserve ;; environment variables that may be present in ;; `ggtags-process-environment'. (process-environment @@ -402,7 +402,8 @@ properly update `ggtags-mode-map'. (message Project read-only-mode is %s (if val on off))) val)) -(defmacro ggtags-with-process-environment (rest body) +(defmacro ggtags-with-current-project (rest body) + Eval BODY in current project's `process-environment'. (declare (debug t)) (let ((gtagsroot (make-symbol -gtagsroot-)) (ggproj (make-symbol -ggtags-project-))) @@ -432,7 +433,7 @@ properly update `ggtags-mode-map'. (when (zerop (length root)) (error No root directory provided)) (setenv GTAGSROOT (directory-file-name (file-name-as-directory root))) -(ggtags-with-process-environment +(ggtags-with-current-project (and (not (getenv GTAGSLABEL)) (yes-or-no-p Use `ctags' backend? ) (setenv GTAGSLABEL ctags)) @@ -455,7 +456,7 @@ non-nil. (when (or force (and (ggtags-find-project) (not (ggtags-project-oversize-p)) (ggtags-project-dirty-p (ggtags-find-project -(ggtags-with-process-environment +(ggtags-with-current-project (with-temp-message `global -u' in progress... (ggtags-process-string global -u) (setf (ggtags-project-dirty-p (ggtags-find-project)) nil) @@ -468,7 +469,7 @@ non-nil. (unless (equal prefix (car ggtags-completion-cache)) (setq ggtags-completion-cache (cons prefix - (ggtags-with-process-environment + (ggtags-with-current-project (split-string (apply #'ggtags-process-string global @@ -548,7 +549,7 @@ non-nil. (setq ggtags-global-exit-status 0 ggtags-global-match-count 0) (ggtags-update-tags) -(ggtags-with-process-environment +(ggtags-with-current-project (setq ggtags-global-last-buffer (compilation-start command 'ggtags-global-mode) @@ -716,7 +717,7 @@ Global and Emacs. (or (file-exists-p (expand-file-name HTML (ggtags-current-project-root))) (if (yes-or-no-p No hypertext form exists; run htags? ) (let ((default-directory (ggtags-current-project-root))) -(ggtags-with-process-environment (ggtags-process-string htags))) +(ggtags-with-current-project (ggtags-process-string htags))) (user-error Aborted))) (let ((url (ggtags-process-string gozilla -p (format +%d line) (file-relative-name file @@ -1192,7 +1193,7 @@ Global and Emacs. (setf (ggtags-project-dirty-p (ggtags-find-project)) t) ;; When oversize update on a per-save basis. (when (and buffer-file-name (ggtags-project-oversize-p)) - (ggtags-with-process-environment + (ggtags-with-current-project (process-file global nil 0 nil --single-update (file-relative-name buffer-file-name)) @@ -1366,7 +1367,7 @@ Global and Emacs. (when-let (file (and buffer-file-name (file-relative-name buffer-file-name))) (with-temp-buffer (when (with-demoted-errors - (zerop (ggtags-with-process-environment + (zerop (ggtags-with-current-project (process-file global nil t nil -x -f file (goto-char (point-min)) (loop while (re-search-forward
[elpa] 03/09: Fix #31: Avoid `-d' switch for compatibility
leoliu pushed a commit to branch master in repository elpa. commit 5cdfab7df655c3fbcf2ade02322db0860be27aeb Author: Leo Liu sdl@gmail.com Date: Thu Feb 13 10:44:35 2014 +0800 Fix #31: Avoid `-d' switch for compatibility --- ggtags.el |6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ggtags.el b/ggtags.el index 509db78..a511d25 100644 --- a/ggtags.el +++ b/ggtags.el @@ -1,6 +1,6 @@ ;;; ggtags.el --- emacs frontend to GNU Global source code tagging system -*- lexical-binding: t; -*- -;; Copyright (C) 2013 Free Software Foundation, Inc. +;; Copyright (C) 2013-2014 Free Software Foundation, Inc. ;; Author: Leo Liu sdl@gmail.com ;; Version: 0.7.9 @@ -495,7 +495,7 @@ non-nil. (and ggtags-global-treat-text --other) (pcase cmd ((pred stringp) cmd) -(`definition -d) +(`definition ) ;-d not supported by Global 5.7.1 (`reference -r) (`symbol -s) (`path --path) @@ -844,7 +844,7 @@ Global and Emacs. (`GSYMS '(symbol symbols)) (`GRTAGS '(reference references)) (`ID '(identifier identifiers)) - (_'(match matches)) + (_ '(match matches)) exit-status))) ;;; NOTE: Must not match the 'Global started at Mon Jun 3 10:24:13'
[elpa] 05/09: Remove side-effect from ggtags-with-process-environment
leoliu pushed a commit to branch master in repository elpa. commit 493a7a3cd5224e61cece7db5d382aabd5879d7e5 Author: Leo Liu sdl@gmail.com Date: Sat Feb 15 12:57:07 2014 +0800 Remove side-effect from ggtags-with-process-environment Make ggtags-ensure-project generate an error if project not found. --- ggtags.el | 44 +--- 1 files changed, 25 insertions(+), 19 deletions(-) diff --git a/ggtags.el b/ggtags.el index 1b64973..94e9374 100644 --- a/ggtags.el +++ b/ggtags.el @@ -244,22 +244,6 @@ properly update `ggtags-mode-map'. (error No global buffer found)) (with-current-buffer ggtags-global-last-buffer ,@body))) -(defmacro ggtags-with-process-environment (rest body) - (declare (debug t)) - (let ((gtagsroot (make-symbol -gtagsroot-))) -`(let* ((,gtagsroot (when (ggtags-find-project) - (directory-file-name (ggtags-current-project-root -(process-environment - (append (let ((process-environment process-environment)) - (and ,gtagsroot (setenv GTAGSROOT ,gtagsroot)) - (mapcar #'substitute-env-vars ggtags-process-environment)) - process-environment - (and ,gtagsroot (list (concat GTAGSROOT= ,gtagsroot))) - (and (ggtags-find-project) - (not (ggtags-project-has-rtags (ggtags-find-project))) - (list GTAGSLABEL=ctags) - ,@body))) - (defun ggtags-list-of-string-p (xs) Return non-nil if XS is a list of strings. (if (null xs) @@ -347,7 +331,7 @@ properly update `ggtags-mode-map'. ;; let's help it out. (when-let (gtags (locate-dominating-file default-directory GTAGS)) - (file-truename gtags) + (file-truename gtags) (setq ggtags-project (and root (or (gethash root ggtags-projects) (ggtags-make-project root @@ -365,7 +349,9 @@ properly update `ggtags-mode-map'. (when (or (yes-or-no-p File GTAGS not found; run gtags? ) (user-error Aborted)) (call-interactively #'ggtags-create-tags) -(ggtags-find-project +;; Need checking because `ggtags-create-tags' can create tags +;; in any directory. +(ggtags-check-project (defun ggtags-save-project-settings (optional noconfirm) Save Gnu Global's specific environment variables. @@ -420,6 +406,25 @@ properly update `ggtags-mode-map'. (message Project read-only-mode is %s (if val on off))) val)) +(defmacro ggtags-with-process-environment (rest body) + (declare (debug t)) + (let ((gtagsroot (make-symbol -gtagsroot-)) +(ggproj (make-symbol -ggtags-project-))) +`(let* ((,ggproj ggtags-project) +(,gtagsroot (when (ggtags-find-project) + (directory-file-name (ggtags-current-project-root +(process-environment + (append (let ((process-environment process-environment)) + (and ,gtagsroot (setenv GTAGSROOT ,gtagsroot)) + (mapcar #'substitute-env-vars ggtags-process-environment)) + process-environment + (and ,gtagsroot (list (concat GTAGSROOT= ,gtagsroot))) + (and (ggtags-find-project) + (not (ggtags-project-has-rtags (ggtags-find-project))) + (list GTAGSLABEL=ctags) + (unwind-protect (save-current-buffer ,@body) + (setq ggtags-project ,ggproj) + (defun ggtags-create-tags (root) Run `gtags' in directory ROOT to create tag files. (interactive DRoot directory: ) @@ -565,6 +570,7 @@ non-nil. If point is at a definition tag, find references, and vice versa. With a prefix arg (non-nil DEFINITION) always find definitions. (interactive (list (ggtags-read-tag) current-prefix-arg)) + (ggtags-check-project) ; for `ggtags-current-project-root' below (if (or definition (not buffer-file-name) (and (ggtags-find-project) @@ -673,7 +679,7 @@ Global and Emacs. (defun ggtags-delete-tag-files () Delete the tag files generated by gtags. - (interactive) + (interactive (ignore (ggtags-check-project))) (when (ggtags-current-project-root) (let ((files (directory-files (ggtags-current-project-root) t
[elpa] 02/09: Fix misuse of display-buffer-overriding-action
leoliu pushed a commit to branch master in repository elpa. commit cc1a00e15647fb949cfd3ca0f315fd66b419f9ff Author: Leo Liu sdl@gmail.com Date: Sat Dec 21 16:36:23 2013 +0800 Fix misuse of display-buffer-overriding-action --- ggtags.el |5 + 1 files changed, 1 insertions(+), 4 deletions(-) diff --git a/ggtags.el b/ggtags.el index 0869916..509db78 100644 --- a/ggtags.el +++ b/ggtags.el @@ -526,10 +526,7 @@ non-nil. (if (and ggtags-auto-jump-to-first-match ;; Appeared in emacs 24.4. (fboundp 'display-buffer-no-window)) - (cons (lambda (buf _action) - (with-current-buffer buf -(derived-mode-p 'ggtags-global-mode))) -(list #'display-buffer-no-window)) + (list #'display-buffer-no-window) display-buffer-overriding-action))) (setq ggtags-global-start-marker (point-marker)) (ggtags-navigation-mode +1)
[elpa] branch master updated (cae1efc - 2b0d5df)
leoliu pushed a change to branch master in repository elpa. from cae1efc Merge commit '119822078ee3024c2d27017d45ef4578fa36040f' from company new ae512f5 Small fixes to ggtags-find-tag-regexp new a282c66 Fix #30: Remove M-o key binding in ggtags-global-mode new 945f64e Make buffer cache project root directory instead new 597c329 Fix #33: support running ggtags on remote hosts (via tramp) new 3d7f273 Teach ggtags-create-tags to retry if mkid is missing new a5843af Stricter search for GTAGS file in ggtags-find-project new f0a2f76 Store 'global' options per project new 2b0d5df Merge remote-tracking branch 'ggtags/master' The 8 revisions listed above as new are entirely new to this repository and will be described in separate emails. The revisions listed as adds were already present in the repository and have only been added to this reference. Summary of changes: packages/ggtags/README.rst |1 + packages/ggtags/ggtags.el | 188 2 files changed, 104 insertions(+), 85 deletions(-)
[elpa] 05/09: Make use of colored output to calulate column
leoliu pushed a commit to branch master in repository elpa. commit 8a13fc8f5cc1c6101e56b8ba8b8f48dd5df2b851 Author: Leo Liu sdl@gmail.com Date: Mon Feb 24 23:40:56 2014 +0800 Make use of colored output to calulate column and enable it for grep and ctags-x output formats. The cscope output format doesn't include leading blank from the source text so cannot calculate column without support from compile. --- ggtags.el | 23 +++ 1 files changed, 19 insertions(+), 4 deletions(-) diff --git a/ggtags.el b/ggtags.el index 44fdc80..4aa1073 100644 --- a/ggtags.el +++ b/ggtags.el @@ -897,22 +897,29 @@ Global and Emacs. (_ '(match matches)) exit-status))) +(defun ggtags-global-column (start) + ;; START is the beginning position of source text. + (when-let (mbeg (text-property-any start (line-end-position) 'global-color t)) +(setq ggtags-current-tag-name nil) +(- mbeg start))) + ;;; NOTE: Must not match the 'Global started at Mon Jun 3 10:24:13' ;;; line or `compilation-auto-jump' will jump there and fail. See ;;; comments before the 'gnu' entry in ;;; `compilation-error-regexp-alist-alist'. (defvar ggtags-global-error-regexp-alist-alist (append - '((path ^\\(?:[^/\n]*/\\)?[^ )\t\n]+$ 0) + `((path ^\\(?:[^/\n]*/\\)?[^ )\t\n]+$ 0) ;; ACTIVE_ESCAPE src/dialog.cc 172 (ctags ^\\([^ \t\n]+\\)[ \t]+\\(.*?\\)[ \t]+\\([0-9]+\\)$ 2 3 nil nil 2 (1 font-lock-function-name-face)) ;; ACTIVE_ESCAPE 172 src/dialog.cc#undef ACTIVE_ESCAPE (ctags-x ^\\([^ \t\n]+\\)[ \t]+\\([0-9]+\\)[ \t]+\\(\\(?:[^/\n]*/\\)?[^ \t\n]+\\) - 3 2 nil nil 3 (1 font-lock-function-name-face)) + 3 2 (,(lambda () (ggtags-global-column (1+ (match-end 0) + nil 3 (1 font-lock-function-name-face)) ;; src/dialog.cc:172:#undef ACTIVE_ESCAPE (grep ^\\(.+?\\):\\([0-9]+\\):\\(?:$\\|[^0-9\n]\\|[0-9][^0-9\n]\\|[0-9][0-9].\\) - 1 2 nil nil 1) + 1 2 (,(lambda () (ggtags-global-column (1+ (match-end 2) nil 1) ;; src/dialog.cc ACTIVE_ESCAPE 172 #undef ACTIVE_ESCAPE (cscope ^\\(.+?\\)[ \t]+\\([^ \t\n]+\\)[ \t]+\\([0-9]+\\).*\\(?:[^0-9\n]\\|[^0-9\n][0-9]\\|[^:\n][0-9][0-9]\\)$ 1 3 nil nil 1 (2 font-lock-function-name-face))) @@ -962,7 +969,12 @@ Global and Emacs. (defun ggtags-global-filter () Called from `compilation-filter-hook' (which see). - (ansi-color-apply-on-region compilation-filter-start (point)) + (let ((ansi-color-apply-face-function + (lambda (beg end face) + (when face + (ansi-color-apply-overlay-face beg end face) + (put-text-property beg end 'global-color t) +(ansi-color-apply-on-region compilation-filter-start (point))) ;; Get rid of line Using config file '/PATH/TO/.globalrc'. or ;; Using default configuration. (when (re-search-backward @@ -1016,6 +1028,9 @@ Global and Emacs. (setq-local compilation-auto-jump-to-first-error ggtags-auto-jump-to-first-match) (setq-local compilation-scroll-output 'first-error) + ;; See `compilation-move-to-column' for details. + (setq-local compilation-first-column 0) + (setq-local compilation-error-screen-columns nil) (setq-local compilation-disable-input t) (setq-local compilation-always-kill t) (setq-local compilation-error-face 'compilation-info)
[elpa] branch master updated (ea514e1 - c4cfb77)
leoliu pushed a change to branch master in repository elpa. from ea514e1 [gnugo] Release: 2.3.1 new 2abd618 Trigger ggtags-update-tags based on visited file modtime new 6281e46 Use --color=always in ggtags-global-build-command new 1971c9f New customizable variable ggtags-mode-sticky new 288ae43 Doc fix new c4cfb77 Merge remote-tracking branch 'ggtags/master' The 5 revisions listed above as new are entirely new to this repository and will be described in separate emails. The revisions listed as adds were already present in the repository and have only been added to this reference. Summary of changes: packages/ggtags/README.rst |1 + packages/ggtags/ggtags.el | 108 +++ 2 files changed, 69 insertions(+), 40 deletions(-)
[elpa] 04/05: Doc fix
leoliu pushed a commit to branch master in repository elpa. commit 288ae435fbcb2d04ac7bfae468d35182d5776693 Author: Leo Liu sdl@gmail.com Date: Sat Mar 1 17:53:31 2014 +0800 Doc fix --- README.rst |1 + ggtags.el |5 - 2 files changed, 5 insertions(+), 1 deletions(-) diff --git a/README.rst b/README.rst index ca30391..8a6783a 100644 --- a/README.rst +++ b/README.rst @@ -14,6 +14,7 @@ Features #. Automatically update Global's tag files when needed with tuning for large source trees. +#. Read tag with completion. #. Build on ``compile.el`` for asynchronicity and its large feature-set. #. Intuitive navigation among multiple matches with mode-line display diff --git a/ggtags.el b/ggtags.el index 946684c..32a069e 100644 --- a/ggtags.el +++ b/ggtags.el @@ -472,7 +472,10 @@ Value is new modtime if updated. (split-string path (regexp-quote path-separator) t (defun ggtags-create-tags (root) - Run `gtags' in directory ROOT to create tag files. + Create tag files (e.g. GTAGS) in directory ROOT. +If file gtags.files exists in ROOT, it should be a list of source +files to index, which can be used to speed gtags up in large +source trees. See Info node `(global)gtags' for details. (interactive DRoot directory: ) (let ((process-environment process-environment)) (when (zerop (length root)) (error No root directory provided))
[elpa] 05/05: Merge remote-tracking branch 'ggtags/master'
leoliu pushed a commit to branch master in repository elpa. commit c4cfb77e99c090562179c8f8afb9ee93392312dc Merge: ea514e1 288ae43 Author: Leo Liu sdl@gmail.com Date: Sat Mar 1 17:55:20 2014 +0800 Merge remote-tracking branch 'ggtags/master' packages/ggtags/README.rst |1 + packages/ggtags/ggtags.el | 108 +++ 2 files changed, 69 insertions(+), 40 deletions(-)
[elpa] 01/05: Trigger ggtags-update-tags based on visited file modtime
leoliu pushed a commit to branch master in repository elpa. commit 2abd61884ee42a9c61f6958530ab15e5247098ad Author: Leo Liu sdl@gmail.com Date: Wed Feb 26 10:20:07 2014 +0800 Trigger ggtags-update-tags based on visited file modtime --- ggtags.el | 94 1 files changed, 56 insertions(+), 38 deletions(-) diff --git a/ggtags.el b/ggtags.el index 4034978..9cce122 100644 --- a/ggtags.el +++ b/ggtags.el @@ -3,7 +3,7 @@ ;; Copyright (C) 2013-2014 Free Software Foundation, Inc. ;; Author: Leo Liu sdl@gmail.com -;; Version: 0.7.11 +;; Version: 0.7.12 ;; Keywords: tools, convenience ;; Created: 2013-01-29 ;; URL: https://github.com/leoliu/ggtags @@ -271,38 +271,40 @@ properly update `ggtags-mode-map'. (:copier nil) (:type vector) :named) - root tag-size has-refs has-path-style has-color dirty-p timestamp) + root tag-size has-refs has-path-style has-color dirty-p mtime timestamp) (defun ggtags-make-project (root) (check-type root string) - (when-let (tag-size (nth 7 (file-attributes (expand-file-name GTAGS root -(let* ((default-directory (file-name-as-directory root)) - (rtags-size (nth 7 (file-attributes GRTAGS))) - (has-refs -(when rtags-size - (and (or ( rtags-size (* 32 1024)) - (with-demoted-errors - (not (equal (ggtags-process-string global -crs) - 'has-refs))) - ;; http://thread.gmane.org/gmane.comp.gnu.global.bugs/1518 - (has-path-style -(with-demoted-errors; in case `global' not found - (and (zerop (process-file global nil nil nil ---path-style shorter --help)) - 'has-path-style))) - ;; http://thread.gmane.org/gmane.comp.gnu.global.bugs/1542 - (has-color -(with-demoted-errors - (and (zerop (process-file global nil nil nil --color --help)) - 'has-color - (puthash default-directory - (ggtags-project--make :root default-directory - :tag-size tag-size - :has-refs has-refs - :has-path-style has-path-style - :has-color has-color - :timestamp (float-time)) - ggtags-projects + (pcase (nthcdr 5 (file-attributes (expand-file-name GTAGS root))) +(`(,mtime ,_ ,tag-size . ,_) + (let* ((default-directory (file-name-as-directory root)) +(rtags-size (nth 7 (file-attributes GRTAGS))) +(has-refs + (when rtags-size + (and (or ( rtags-size (* 32 1024)) +(with-demoted-errors + (not (equal (ggtags-process-string global -crs) +'has-refs))) +;; http://thread.gmane.org/gmane.comp.gnu.global.bugs/1518 +(has-path-style + (with-demoted-errors ; in case `global' not found + (and (zerop (process-file global nil nil nil + --path-style shorter --help)) +'has-path-style))) +;; http://thread.gmane.org/gmane.comp.gnu.global.bugs/1542 +(has-color + (with-demoted-errors + (and (zerop (process-file global nil nil nil --color --help)) +'has-color + (puthash default-directory +(ggtags-project--make :root default-directory + :tag-size tag-size + :has-refs has-refs + :has-path-style has-path-style + :has-color has-color + :mtime (float-time mtime) + :timestamp (float-time)) +ggtags-projects) (defun ggtags-project-expired-p (project) (or ( (ggtags-project-timestamp project) 0) @@ -310,6 +312,18 @@ properly update `ggtags-mode-map'. (ggtags-project-timestamp project)) ggtags-project-duration))) +(defun ggtags-project-update-mtime-maybe (optional project) + Update PROJECT's modtime and if current file is newer. +Value is new modtime if updated. + (let ((project (or project (ggtags-find-project +(when (and (ggtags-project-p project) + (consp (visited-file-modtime)) + ( (float-time (visited-file-modtime)) + (ggtags-project-mtime project))) + (setf (ggtags-project-dirty-p project) t) + (setf (ggtags-project-mtime project) +(float-time (visited-file-modtime)) + (defun ggtags
[elpa] 23/38: Simplify ggtags-save-to-register by always re-do the search
leoliu pushed a commit to branch master in repository elpa. commit 927bc05e970d844f577576f49e8b2bc5ce2d544a Author: Leo Liu sdl@gmail.com Date: Tue Mar 18 15:21:31 2014 +0800 Simplify ggtags-save-to-register by always re-do the search Fix error in ggtags-global--display-buffer. --- ggtags.el | 66 ++-- 1 files changed, 29 insertions(+), 37 deletions(-) diff --git a/ggtags.el b/ggtags.el index f588331..789982a 100644 --- a/ggtags.el +++ b/ggtags.el @@ -673,8 +673,8 @@ non-nil. (ring-insert find-tag-marker-ring ggtags-global-start-marker) (setq ggtags-global-start-marker t))) -(defun ggtags-global-start (command optional root) - (let* ((default-directory (or root (ggtags-current-project-root))) +(defun ggtags-global-start (command optional directory) + (let* ((default-directory (or directory (ggtags-current-project-root))) (split-window-preferred-function ggtags-split-window-function) ;; See http://debbugs.gnu.org/13594 (display-buffer-overriding-action @@ -831,41 +831,33 @@ Global and Emacs. Save current search session to register R. Use \\[jump-to-register] to restore the search session. (interactive (list (ggtags-ensure-global-buffer - (register-read-with-preview - (format Save search in `%s' to register: (buffer-name)) + (register-read-with-preview Save search to register: (ggtags-ensure-global-buffer - (rename-buffer (format *ggtags %s* ggtags-current-tag-name) t) - (cl-labels ((move-to-error (buf line) - (with-current-buffer buf -(goto-char (point-min)) -(forward-line (1- line)) -(setq ggtags-global-last-buffer (current-buffer)) -(ggtags-navigation-mode 1) -(setq compilation-current-error (point)) -(compile-goto-error))) - (jump (data) +(cl-labels ((jump (data) + (pcase data +(`(,command ,root ,line) + (with-current-buffer + (let ((ggtags-auto-jump-to-first-match nil) + ;; Switch current project to ROOT. + (default-directory root) + (ggtags-project-root root)) + (ggtags-global-start command root)) + (add-hook 'compilation-finish-functions + (lambda (buf _msg) + (with-current-buffer buf + (goto-char (point-min)) + (forward-line (1- line)) + (compile-goto-error))) + nil t) +(prn (data) (pcase data - (`(,buf ,line ,command ,root) -(if (get-buffer buf) -(progn - (ggtags-global--display-buffer buf) - (move-to-error buf line)) - (with-current-buffer - (let ((ggtags-auto-jump-to-first-match nil)) -(ggtags-global-start command root)) -(add-hook 'compilation-finish-functions - (lambda (buf _msg) (move-to-error buf line)) - nil t) -(rename-buffer buf)) - (prn (data) -(pcase data - (`(,_buf ,line ,command ,root) - (princ (format a ggtags search session `%s' in directory `%s' at line %d. - command root line)) - (set-register r (registerv-make - (list (buffer-name) (line-number-at-pos) -(car compilation-arguments) default-directory) - :jump-func #'jump :print-func #'prn) + (`(,command ,root ,line) +(princ (format a ggtags search session `%s' in directory `%s' at line %d. + command root line)) + (set-register r (registerv-make + (list (car compilation-arguments) default-directory + (line-number-at-pos)) + :jump-func #'jump :print-func #'prn) (defun ggtags-delete-tag-files () Delete the tag files generated by gtags. @@ -1120,7 +1112,7 @@ Use \\[jump-to-register] to restore the search session. (let ((buffer (or buffer (current-buffer
[elpa] 07/38: Fix some errors in ggtags-global-output
leoliu pushed a commit to branch master in repository elpa. commit 1702db56a16ec3b12665bb412714503f06a14dbe Author: Leo Liu sdl@gmail.com Date: Wed Mar 5 11:56:18 2014 +0800 Fix some errors in ggtags-global-output --- ggtags.el | 25 + 1 files changed, 13 insertions(+), 12 deletions(-) diff --git a/ggtags.el b/ggtags.el index 0fe7cae..fd0f195 100644 --- a/ggtags.el +++ b/ggtags.el @@ -1311,17 +1311,16 @@ Global and Emacs. (process-file global nil 0 nil --single-update (file-relative-name buffer-file-name)) -(defun ggtags-global-output (cmds buffer callback optional cutoff) - Asynchrously pipe the output of CMDS to BUFFER. -Invoke CALLBACK in BUFFER with process exit status when finished. +(defun ggtags-global-output (buffer cmds callback optional cutoff) + Asynchrously pipe the output of running CMDS to BUFFER. +When finished invoke CALLBACK in BUFFER with process exit status. (or buffer (error Output buffer required)) - (let* ((default-directory (or (ggtags-current-project-root) default-directory)) - (program (car cmds)) + (let* ((program (car cmds)) (args (cdr cmds)) - (cutoff (+ cutoff (if (get-buffer buffer) - (with-current-buffer buffer - (line-number-at-pos (point-max))) - 0))) + (cutoff (and cutoff (+ cutoff (if (get-buffer buffer) + (with-current-buffer buffer + (line-number-at-pos (point-max))) + 0 (proc (apply #'start-file-process program buffer program args)) (filter (lambda (proc string) (and (buffer-live-p (process-buffer proc)) @@ -1335,7 +1334,7 @@ Invoke CALLBACK in BUFFER with process exit status when finished. (when (memq (process-status proc) '(exit signal)) (with-current-buffer (process-buffer proc) (set-process-buffer proc nil) - (funcall callback (process-status proc))) + (funcall callback (process-exit-status proc))) (set-process-query-on-exit-flag proc nil) (and cutoff (set-process-filter proc filter)) (set-process-sentinel proc sentinel) @@ -1347,8 +1346,9 @@ Invoke CALLBACK in BUFFER with process exit status when finished. (defun ggtags-show-definition (name) (interactive (list (ggtags-read-tag 'definition current-prefix-arg))) + (ggtags-check-project) (let* ((re (cadr (assq 'grep ggtags-global-error-regexp-alist-alist))) - (buffer (get-buffer-create *ggtags-output*)) + (buffer (get-buffer-create *ggtags-definition*)) (fn ggtags-show-definition-function) (show (lambda (_status) (goto-char (point-min)) @@ -1360,8 +1360,9 @@ Invoke CALLBACK in BUFFER with process exit status when finished. (string-to-number (match-string 2) (kill-buffer buffer (ggtags-global-output + buffer (list global --result=grep --path-style=absolute name) - buffer show 100))) + show 100))) (defvar ggtags-mode-prefix-map (let ((m (make-sparse-keymap)))
[elpa] 09/38: Replace ignore-errors with condition-case-unless-debug
leoliu pushed a commit to branch master in repository elpa. commit 5fea7f111a010d05cc32ab43e569c4c17ff760a8 Author: Leo Liu sdl@gmail.com Date: Thu Mar 6 11:47:02 2014 +0800 Replace ignore-errors with condition-case-unless-debug --- ggtags.el | 34 +- 1 files changed, 17 insertions(+), 17 deletions(-) diff --git a/ggtags.el b/ggtags.el index 1ed2846..6eb3ee7 100644 --- a/ggtags.el +++ b/ggtags.el @@ -535,6 +535,8 @@ non-nil. (defvar-local ggtags-completion-cache nil) +;; See global/libutil/char.c +;; (defconst ggtags-regexp-metachars [][$()*+.?\\{}|^]) (defvar ggtags-completion-flag ) ;internal use (defvar ggtags-completion-table @@ -544,17 +546,18 @@ non-nil. (unless (equal cache-key (car ggtags-completion-cache)) (setq ggtags-completion-cache (cons cache-key - (ignore-errors - ;; May throw global: only name char is allowed - ;; with -c option. - (ggtags-with-current-project -(split-string - (apply #'ggtags-process-string -global -(append (and completion-ignore-case '(--ignore-case)) -;; Note -c alone returns only definitions -(list (concat -c ggtags-completion-flag) prefix))) - \n t))) + (condition-case-unless-debug nil + ;; May throw global: only name char is + ;; allowed with -c option. + (ggtags-with-current-project + (split-string + (apply #'ggtags-process-string + global + (append (and completion-ignore-case '(--ignore-case)) + ;; Note -c alone returns only definitions + (list (concat -c ggtags-completion-flag) prefix))) + \n t)) + (error nil)) (cdr ggtags-completion-cache (defun ggtags-completion-at-point () @@ -1518,12 +1521,9 @@ When finished invoke CALLBACK in BUFFER with process exit status. ;; Overlay matches current tag so do nothing. nil) ((and bounds (let ((completion-ignore-case nil)) - (ignore-errors -;; May throw: global: only name char is -;; allowed with -c option -(test-completion - (buffer-substring (car bounds) (cdr bounds)) - ggtags-completion-table + (test-completion + (buffer-substring (car bounds) (cdr bounds)) + ggtags-completion-table))) (move-overlay o (car bounds) (cdr bounds) (current-buffer)) (overlay-put o 'category 'ggtags-active-tag)) (t (move-overlay o
[elpa] 17/38: Fix ggtags-with-current-project to include GTAGSCONF
leoliu pushed a commit to branch master in repository elpa. commit e7c5371028912e07c37de2bf1c80c88bf51a1fea Author: Leo Liu sdl@gmail.com Date: Wed Mar 12 17:48:43 2014 +0800 Fix ggtags-with-current-project to include GTAGSCONF --- ggtags.el | 13 +++-- 1 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ggtags.el b/ggtags.el index 18f10b9..fa007a9 100644 --- a/ggtags.el +++ b/ggtags.el @@ -295,13 +295,15 @@ properly update `ggtags-mode-map'. (:copier nil) (:type vector) :named) - root tag-size has-refs has-path-style has-color dirty-p mtime timestamp) + root config tag-size has-refs has-path-style has-color dirty-p mtime timestamp) (defun ggtags-make-project (root) (cl-check-type root string) (pcase (nthcdr 5 (file-attributes (expand-file-name GTAGS root))) (`(,mtime ,_ ,tag-size . ,_) (let* ((default-directory (file-name-as-directory root)) +(config (cl-some (lambda (c) (and (file-exists-p c) c)) + '(.globalrc gtags.conf))) (rtags-size (nth 7 (file-attributes GRTAGS))) (has-refs (when rtags-size @@ -322,6 +324,7 @@ properly update `ggtags-mode-map'. 'has-color (puthash default-directory (ggtags-project--make :root default-directory + :config config :tag-size tag-size :has-refs has-refs :has-path-style has-path-style @@ -481,7 +484,13 @@ Value is new modtime if updated. (and ,gtagsroot (list (concat GTAGSROOT= ,gtagsroot))) (and (ggtags-find-project) (not (ggtags-project-has-refs (ggtags-find-project))) - (list GTAGSLABEL=ctags) + (list GTAGSLABEL=ctags)) + (and ggtags-use-project-gtagsconf ,gtagsroot + (ggtags-project-config (ggtags-find-project)) + (list (concat GTAGSCONF= +(expand-file-name (ggtags-project-config + (ggtags-find-project)) + ,gtagsroot))) (unwind-protect (save-current-buffer ,@body) (setq ggtags-project-root ,root)
[elpa] 08/38: Call ggtags-show-definition-function in the original buffer
leoliu pushed a commit to branch master in repository elpa. commit 22bca183cd838933690e7bc668886073036d63b9 Author: Leo Liu sdl@gmail.com Date: Thu Mar 6 01:14:09 2014 +0800 Call ggtags-show-definition-function in the original buffer --- ggtags.el | 12 1 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ggtags.el b/ggtags.el index fd0f195..1ed2846 100644 --- a/ggtags.el +++ b/ggtags.el @@ -1342,23 +1342,27 @@ When finished invoke CALLBACK in BUFFER with process exit status. (defun ggtags-show-definition-default (defs) (let (message-log-max) -(message %s (or (caar defs) [definition not found] +(message %s%s (or (caar defs) [definition not found]) + (if (cdr defs) [guess] (defun ggtags-show-definition (name) (interactive (list (ggtags-read-tag 'definition current-prefix-arg))) (ggtags-check-project) (let* ((re (cadr (assq 'grep ggtags-global-error-regexp-alist-alist))) + (current (current-buffer)) (buffer (get-buffer-create *ggtags-definition*)) (fn ggtags-show-definition-function) (show (lambda (_status) (goto-char (point-min)) - (funcall fn (loop while (re-search-forward re nil t) + (let ((defs (loop while (re-search-forward re nil t) collect (list (buffer-substring (1+ (match-end 2)) (line-end-position)) name (match-string 1) - (string-to-number (match-string 2) - (kill-buffer buffer + (string-to-number (match-string 2)) + (kill-buffer buffer) + (with-current-buffer current + (funcall fn defs)) (ggtags-global-output buffer (list global --result=grep --path-style=absolute name)
[elpa] 33/38: Disable ggtags-navigation-mode in ggtags-global-rerun-search
leoliu pushed a commit to branch master in repository elpa. commit 21b368599ce54687e60d89d4178cae946f9d45eb Author: Leo Liu sdl@gmail.com Date: Fri Mar 21 18:11:06 2014 +0800 Disable ggtags-navigation-mode in ggtags-global-rerun-search --- ggtags.el |8 +--- 1 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ggtags.el b/ggtags.el index 8732349..6c002d8 100644 --- a/ggtags.el +++ b/ggtags.el @@ -896,6 +896,7 @@ Global and Emacs. (interactive) (let ((node (ewoc-locate ggtags-global-search-ewoc))) (when node + (save) (quit) (ggtags-global-rerun-search-1 (cdr (ewoc-data node))) (let ((m (make-sparse-keymap))) @@ -909,6 +910,8 @@ Global and Emacs. (define-key m \r #'done) m))) +(defvar ggtags-navigation-mode) + (defun ggtags-global-rerun-search () Pop up a buffer to choose a past search to re-run. @@ -921,6 +924,7 @@ Global and Emacs. (erase-buffer) (special-mode) (use-local-map ggtags-global-rerun-search-map) +(setq-local ggtags-navigation-mode nil) (setq truncate-lines t) (cl-labels ((prop (s) (propertize s 'face 'minibuffer-prompt)) (pp (data) @@ -1214,8 +1218,6 @@ Use \\[jump-to-register] to restore the search session. (w (display-buffer buffer '(nil (allow-no-window . t) (and w (compilation-set-window-height w)) -(defvar ggtags-navigation-mode) - (defun ggtags-global-filter () Called from `compilation-filter-hook' (which see). (let ((ansi-color-apply-face-function @@ -1379,7 +1381,7 @@ Use \\[jump-to-register] to restore the search session. (kill-compilation)) (when (and (derived-mode-p 'ggtags-global-mode) (get-buffer-window)) - (quit-window nil (get-buffer-window))) + (quit-windows-on (current-buffer))) (and time (run-with-idle-timer time nil #'kill-buffer buf)) (defun ggtags-navigation-mode-done ()
[elpa] 27/38: Cosmetic change: Fix indentation
leoliu pushed a commit to branch master in repository elpa. commit 6628680ef45b7ffa96d160d7f0ef5327141d7b2b Author: Leo Liu sdl@gmail.com Date: Thu Mar 20 11:04:20 2014 +0800 Cosmetic change: Fix indentation --- ggtags.el | 42 +- 1 files changed, 21 insertions(+), 21 deletions(-) diff --git a/ggtags.el b/ggtags.el index 1b1dc84..e7e8552 100644 --- a/ggtags.el +++ b/ggtags.el @@ -836,7 +836,7 @@ Global and Emacs. Save current search session to register R. Use \\[jump-to-register] to restore the search session. (interactive (list (ggtags-ensure-global-buffer - (register-read-with-preview Save search to register: + (register-read-with-preview Save search to register: (ggtags-ensure-global-buffer (cl-labels ((jump (data) (pcase data @@ -1333,13 +1333,13 @@ Use \\[jump-to-register] to restore the search session. (defun ggtags-navigation-isearch-forward (optional regexp-p) (interactive P) (ggtags-ensure-global-buffer - (let ((saved (if visible-mode 1 -1))) - (visible-mode 1) - (with-selected-window (get-buffer-window (current-buffer)) - (isearch-forward regexp-p) - (beginning-of-line) - (visible-mode saved) - (compile-goto-error) +(let ((saved (if visible-mode 1 -1))) + (visible-mode 1) + (with-selected-window (get-buffer-window (current-buffer)) +(isearch-forward regexp-p) +(beginning-of-line) +(visible-mode saved) +(compile-goto-error) (defun ggtags-navigation-visible-mode (optional arg) (interactive (list (or current-prefix-arg 'toggle))) @@ -1357,12 +1357,12 @@ Use \\[jump-to-register] to restore the search session. (and ggtags-mode-sticky (ggtags-mode 1)) (ignore-errors (ggtags-ensure-global-buffer - (unless (overlayp ggtags-global-line-overlay) - (setq ggtags-global-line-overlay (make-overlay (point) (point))) - (overlay-put ggtags-global-line-overlay 'face 'ggtags-global-line)) - (move-overlay ggtags-global-line-overlay - (line-beginning-position) (line-end-position) - (current-buffer + (unless (overlayp ggtags-global-line-overlay) +(setq ggtags-global-line-overlay (make-overlay (point) (point))) +(overlay-put ggtags-global-line-overlay 'face 'ggtags-global-line)) + (move-overlay ggtags-global-line-overlay +(line-beginning-position) (line-end-position) +(current-buffer (run-hooks 'ggtags-find-tag-hook)) (define-minor-mode ggtags-navigation-mode nil @@ -1370,13 +1370,13 @@ Use \\[jump-to-register] to restore the search session. ( GG[ (:eval (ignore-errors (ggtags-ensure-global-buffer - (let ((index (when (get-text-property (line-beginning-position) -'compilation-message) - ;; Assume the first match appears at line 5 - (- (line-number-at-pos) 4 -`((:propertize ,(if index -(number-to-string (max index 0)) - ?) face success) /) + (let ((index (when (get-text-property (line-beginning-position) + 'compilation-message) + ;; Assume the first match appears at line 5 + (- (line-number-at-pos) 4 + `((:propertize ,(if index + (number-to-string (max index 0)) + ?) face success) /) (:propertize (:eval (number-to-string ggtags-global-match-count)) face success) (:eval
[elpa] 02/38: Give ggtags-show-definition-function full information
leoliu pushed a commit to branch master in repository elpa. commit 0dc9b57935b1b018a89253bd0a3f42e65dbbbc46 Author: Leo Liu sdl@gmail.com Date: Mon Mar 3 18:09:33 2014 +0800 Give ggtags-show-definition-function full information of the definition candidates. --- ggtags.el | 19 ++- 1 files changed, 14 insertions(+), 5 deletions(-) diff --git a/ggtags.el b/ggtags.el index 542affe..b5dd77f 100644 --- a/ggtags.el +++ b/ggtags.el @@ -185,7 +185,11 @@ If an integer abbreviate only names longer than that number. (defcustom ggtags-show-definition-function #'ggtags-show-definition-default Function called by `ggtags-show-definition' to show definition. -It is passed a list of definnition candidates. +It is passed a list of definnition candidates of the form: + + (TEXT NAME FILE LINE) + +where TEXT is usually the source line of the definition. :type 'function :group 'ggtags) @@ -1319,7 +1323,7 @@ Invoke CALLBACK in BUFFER with process exit status when finished. (defun ggtags-show-definition-default (defs) (let (message-log-max) -(message %s (or (car defs) [definition not found] +(message %s (or (caar defs) [definition not found] (defun ggtags-show-definition (name) (interactive (list (ggtags-read-tag))) @@ -1329,10 +1333,15 @@ Invoke CALLBACK in BUFFER with process exit status when finished. (show (lambda (_status) (goto-char (point-min)) (funcall fn (loop while (re-search-forward re nil t) - collect (buffer-substring (1+ (match-end 2)) - (line-end-position + collect (list (buffer-substring (1+ (match-end 2)) + (line-end-position)) + name + (match-string 1) + (string-to-number (match-string 2) (kill-buffer buffer -(ggtags-global-output (list global --result=grep name) buffer show 30))) +(ggtags-global-output + (list global --result=grep --path-style=absolute name) + buffer show 100))) (defvar ggtags-mode-prefix-map (let ((m (make-sparse-keymap)))
[elpa] 36/38: Doc fix: Update README.rst and doc-strings
leoliu pushed a commit to branch master in repository elpa. commit 2e94e1ed0fde92acc87ab720508dc379dd53f22a Author: Leo Liu sdl@gmail.com Date: Sun Mar 23 18:27:11 2014 +0800 Doc fix: Update README.rst and doc-strings --- README.rst | 238 ggtags.el | 101 -- 2 files changed, 237 insertions(+), 102 deletions(-) diff --git a/README.rst b/README.rst index 8a6783a..ae9766a 100644 --- a/README.rst +++ b/README.rst @@ -1,34 +1,47 @@ = Emacs frontend to GNU Global source code tagging system = - + This package is part of `GNU ELPA http://elpa.gnu.org`_ (``M-x list-packages``) and is also available on `MELPA http://melpa.milkbox.net/#/ggtags`_. -``ggtags.el`` is tested in emacs 24.1, 24.2, 24.3 and trunk. Patches, -feature requests and bug reports are welcome. Thanks. +The goal is to make working with GNU Global in Emacs as effortlessly +and intuitively as possible and to integrate tightly with standard +emacs packages. ``ggtags.el`` is tested in emacs 24.1, 24.2, 24.3 and +trunk. Patches, feature requests and bug reports are welcome. Thanks. Features -#. Automatically update Global's tag files when needed with tuning for - large source trees. -#. Read tag with completion. #. Build on ``compile.el`` for asynchronicity and its large feature-set. +#. Automatically update Global's tag files when needed with tuning for + large source trees. #. Intuitive navigation among multiple matches with mode-line display of current match, total matches and exit status. -#. Manage Global's environment variables on a per-project basis. -#. Support all Global search backends: ``grep``, ``idutils`` etc. +#. Read tag with completion. +#. Show definition at point. +#. Jump to #include files. +#. Support search history and saving a search to register/bookmark. #. Query replace. +#. Manage Global's environment variables on a per-project basis. #. Highlight (definition) tag at point. #. Abbreviated display of file names. +#. Support all Global search backends: ``grep``, ``idutils`` etc. #. Support `exuberant ctags http://ctags.sourceforge.net/`_ backend. #. Support all Global's output formats: ``grep``, ``ctags-x``, ``cscope`` etc. #. Support projects on remote hosts (e.g. via ``tramp``) +Screenshot +~~ + +.. figure:: http://i.imgur.com/LX7PVc3.png + :width: 500px + :target: http://i.imgur.com/LX7PVc3.png + :alt: ggtags.png + Why GNU Global ~~ @@ -36,68 +49,197 @@ The opengrok project composed a feature comparison `table https://github.com/OpenGrok/OpenGrok/wiki/Comparison-with-Similar-Tools`_ between a few tools. -Screenshot -~~ +Install Global and plugins +~~ -.. figure:: http://i.imgur.com/r9nz3ss.png - :width: 500px - :target: http://i.imgur.com/r9nz3ss.png - :alt: ggtags.png +1. Compile and install Global with ``exuberant-ctags`` +:: + + ./configure --prefix=PREFIX --with-exuberant-ctags=/usr/local/bin/ctags + make make install + +The executable ``ctags`` is unfortunately named because ``emacs`` also +includes a command of the same name. So make sure it is from +http://ctags.sourceforge.net. See ``plugin-factory/README`` in GNU +Global source for further information. + +2. Install ``pygments`` plugin +:: + + pip install pygments + git clone https://github.com/yoshizow/global-pygments-plugin.git + sh reconf.sh + ./configure --prefix=PREFIX --with-exuberant-ctags=/usr/local/bin/ctags + make make install + cp sample.globalrc $HOME/.globalrc + +Make sure the value of ``PREFIX`` agree with step 1. Config ~~ -Enable ``ggtags-mode`` for C/C++/Java modes:: +Global with ``exuberant-ctags`` and ``pygments`` plugins can support +dozens of programming languages. For example, to enable +``ggtags-mode`` for C/C++/Java modes:: (add-hook 'c-mode-common-hook (lambda () (when (derived-mode-p 'c-mode 'c++-mode 'java-mode) (ggtags-mode 1 -More languages/modes are supported if `GNU Global -http://www.gnu.org/software/global`_ is compiled with -``--with-exuberant-ctags`` to support `exuberant ctags -http://ctags.sourceforge.net/`_. Also set the environment variable -``GTAGSCONF`` to the correct location of ``gtags.conf``. For example:: +Also see https://github.com/leoliu/ggtags/wiki for more examples. - export GTAGSCONF=/usr/local/share/gtags/gtags.conf +Usage +~ -See ``plugin-factory/README`` in GNU Global source for further -information. +Open any file in a project and type ``M-x ggtags-mode``. Use ``M-.`` +(``ggtags-find-tag-dwim``) to find the tag at point. If the project +has not been indexed (i.e. no ``GTAGS`` file exists), ``ggtags`` will +ask for the project root directory and index it recursively. +Alternatively
[elpa] 37/38: Rename try-complete-ggtags-tag to ggtags-try-complete-tag
leoliu pushed a commit to branch master in repository elpa. commit 50fd757af3cec4588d35afb137a28b5f44a20d56 Author: Leo Liu sdl@gmail.com Date: Mon Mar 24 16:38:04 2014 +0800 Rename try-complete-ggtags-tag to ggtags-try-complete-tag Update README.rst. --- README.rst | 17 + ggtags.el |2 +- 2 files changed, 18 insertions(+), 1 deletions(-) diff --git a/README.rst b/README.rst index ae9766a..6296c54 100644 --- a/README.rst +++ b/README.rst @@ -241,6 +241,23 @@ ggtags-browse-file-as-hypertext Use ``htags`` to generate HTML of the source tree. This allows browsing the porject in a browser with cross-references. +Integration with other packages + +* imenu + + Emacs major modes usually have excellent support for ``imenu`` so + this is not enabled by default. To use: + :: + +(setq-local imenu-create-index-function #'ggtags-build-imenu-index) + +* hippie-exp + :: + + (setq-local hippie-expand-try-functions-list + (cons 'ggtags-try-complete-tag hippie-expand-try-functions-list)) + Bugs diff --git a/ggtags.el b/ggtags.el index 64b4613..541025a 100644 --- a/ggtags.el +++ b/ggtags.el @@ -1831,7 +1831,7 @@ to nil disables displaying this information.) ;;; hippie-expand ;;;###autoload -(defun try-complete-ggtags-tag (old) +(defun ggtags-try-complete-tag (old) A function suitable for `hippie-expand-try-functions-list'. (with-no-warnings ; to avoid loading hippie-exp (unless old
[elpa] 03/38: Don't display buffer if ggtags-navigation-mode is exited
leoliu pushed a commit to branch master in repository elpa. commit a4ba72b12124d125e49db217603c6542fbc98a5b Author: Leo Liu sdl@gmail.com Date: Tue Mar 4 03:55:11 2014 +0800 Don't display buffer if ggtags-navigation-mode is exited or we will undo the work of ggtags-navigation-mode-done. --- ggtags.el |4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/ggtags.el b/ggtags.el index b5dd77f..a01e286 100644 --- a/ggtags.el +++ b/ggtags.el @@ -1007,6 +1007,8 @@ Global and Emacs. (w (display-buffer (current-buffer) '(nil (allow-no-window . t) (and w (compilation-set-window-height w)) +(defvar ggtags-navigation-mode) + (defun ggtags-global-filter () Called from `compilation-filter-hook' (which see). (let ((ansi-color-apply-face-function @@ -1023,7 +1025,7 @@ Global and Emacs. (replace-match )) (incf ggtags-global-output-lines (count-lines compilation-filter-start (point))) - (when ( ggtags-global-output-lines 5) + (when (and ( ggtags-global-output-lines 5) (not ggtags-navigation-mode)) (ggtags-global--display-buffer)) (make-local-variable 'ggtags-global-large-output) (when ( ggtags-global-output-lines ggtags-global-large-output)
[elpa] 10/38: Automatically use GTAGSCONF file at project root
leoliu pushed a commit to branch master in repository elpa. commit 0a1b6710acf31021b7da34076dbff019a044641d Author: Leo Liu sdl@gmail.com Date: Thu Mar 6 18:49:55 2014 +0800 Automatically use GTAGSCONF file at project root --- ggtags.el | 17 ++--- 1 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ggtags.el b/ggtags.el index 6eb3ee7..7ba1de2 100644 --- a/ggtags.el +++ b/ggtags.el @@ -111,6 +111,13 @@ automatically switches to 'global --single-update'. :type 'boolean :group 'ggtags) +(defcustom ggtags-use-project-gtagsconf t + Non-nil to automatically use GTAGSCONF file at project root. +File .globalrc and gtags.conf are checked in order. + :safe 'booleanp + :type 'boolean + :group 'ggtags) + (defcustom ggtags-project-duration 600 Seconds to keep information of a project in memory. :type 'number @@ -498,9 +505,13 @@ source trees. See Info node `(global)gtags' for details. (setenv GTAGSROOT (expand-file-name (directory-file-name (file-name-as-directory root (ggtags-with-current-project - (and (not (getenv GTAGSLABEL)) - (yes-or-no-p Use `ctags' backend? ) - (setenv GTAGSLABEL ctags)) + (let ((conf (and ggtags-use-project-gtagsconf + (or (and (file-exists-p .globalrc) .globalrc) + (and (file-exists-p gtags.conf) gtags.conf) + (cond (conf (setenv GTAGSCONF (expand-file-name conf))) + ((and (not (getenv GTAGSLABEL)) + (yes-or-no-p Use `ctags' backend? )) + (setenv GTAGSLABEL ctags (with-temp-message `gtags' in progress... (let ((default-directory (file-name-as-directory root))) (condition-case err
[elpa] 32/38: Bind ggtags-save-to-register in ggtags-global-rerun-search-map
leoliu pushed a commit to branch master in repository elpa. commit cd56d92bf2e0d679fb3a1ab6ba0ab484a85016d9 Author: Leo Liu sdl@gmail.com Date: Fri Mar 21 12:57:26 2014 +0800 Bind ggtags-save-to-register in ggtags-global-rerun-search-map --- ggtags.el | 26 ++ 1 files changed, 14 insertions(+), 12 deletions(-) diff --git a/ggtags.el b/ggtags.el index 9017d4a..8732349 100644 --- a/ggtags.el +++ b/ggtags.el @@ -904,6 +904,7 @@ Global and Emacs. (define-key m \M-p #'prev) (define-key m n#'next) (define-key m \M-n #'next) + (define-key m r#'ggtags-save-to-register) (define-key m q#'quit) (define-key m \r #'done) m))) @@ -931,7 +932,7 @@ Global and Emacs. (prop text: ) text \n (propertize (make-string 32 ?-) 'face 'shadow)) (setq ggtags-global-search-ewoc -(ewoc-create #'pp Global search history keys: n:next p:prev RET:choose\n))) +(ewoc-create #'pp Global search history keys: n:next p:prev r:register RET:choose\n))) (dolist (data ggtags-global-search-history) (ewoc-enter-last ggtags-global-search-ewoc data)) (and ggtags-global-rerun-search-last @@ -944,17 +945,18 @@ Global and Emacs. (defun ggtags-save-to-register (r) Save current search session to register R. Use \\[jump-to-register] to restore the search session. - (interactive (list (ggtags-ensure-global-buffer - (register-read-with-preview Save search to register: - (ggtags-ensure-global-buffer -(cl-labels ((prn (data) - (pcase data - (`(,command ,root ,_env ,line ,_) -(princ (format a ggtags search session `%s' in directory `%s' at line %d. - command root line)) - (set-register r (registerv-make (ggtags-global-current-search) - :jump-func #'ggtags-global-rerun-search-1 - :print-func #'prn) + (interactive (list (register-read-with-preview Save search to register: ))) + (cl-labels ((prn (data) + (pcase data + (`(,command ,root ,_env ,line ,_) + (princ (format a ggtags search session `%s' in directory `%s' at line %d. + command root line)) +(set-register r (registerv-make + (if ggtags-global-search-ewoc + (cdr (ewoc-data (ewoc-locate ggtags-global-search-ewoc))) + (ggtags-global-current-search)) + :jump-func #'ggtags-global-rerun-search-1 + :print-func #'prn (defun ggtags-delete-tag-files () Delete the tag files generated by gtags.
[elpa] 38/38: Merge branch 'master' of github.com:leoliu/ggtags
leoliu pushed a commit to branch master in repository elpa. commit f11199dbc2e6334efde4739df386ba8709151be4 Merge: 0601efd 50fd757 Author: Leo Liu sdl@gmail.com Date: Mon Mar 24 17:28:32 2014 +0800 Merge branch 'master' of github.com:leoliu/ggtags packages/ggtags/README.rst | 255 ++--- packages/ggtags/ggtags.el | 887 +++- 2 files changed, 829 insertions(+), 313 deletions(-)
[elpa] 21/38: Add new command ggtags-save-to-register for #37
leoliu pushed a commit to branch master in repository elpa. commit 339ec1069bd42d029bfd8d922beff3ca47443158 Author: Leo Liu sdl@gmail.com Date: Tue Mar 18 10:12:20 2014 +0800 Add new command ggtags-save-to-register for #37 --- ggtags.el | 51 --- 1 files changed, 48 insertions(+), 3 deletions(-) diff --git a/ggtags.el b/ggtags.el index 3f437b6..e44a592 100644 --- a/ggtags.el +++ b/ggtags.el @@ -74,10 +74,12 @@ (list 'make-variable-buffer-local (list 'quote var)) (eval-and-compile - (or (fboundp 'user-error) + (or (fboundp 'user-error) ;24.3 (defalias 'user-error 'error)) - (or (fboundp 'read-only-mode) - (defalias 'read-only-mode 'toggle-read-only))) + (or (fboundp 'read-only-mode) ;24.3 + (defalias 'read-only-mode 'toggle-read-only)) + (or (fboundp 'register-read-with-preview) ;24.4 + (defalias 'register-read-with-preview 'read-char))) (defgroup ggtags nil GNU Global source code tagging system. @@ -825,6 +827,46 @@ Global and Emacs. (nreverse files (tags-query-replace from to delimited file-form))) +(defun ggtags-save-to-register (r) + Save current search session to register R. +Use \\[jump-to-register] to restore the search session. + (interactive (list (ggtags-ensure-global-buffer + (register-read-with-preview + (format Save search in `%s' to register: (buffer-name)) + (ggtags-ensure-global-buffer + (rename-buffer (format *ggtags %s* ggtags-current-tag-name) t) + (cl-labels ((move-to-error (buf line) + (with-current-buffer buf +(goto-char (point-min)) +(forward-line (1- line)) +(setq ggtags-global-last-buffer (current-buffer)) +(ggtags-navigation-mode 1) +(setq compilation-current-error (point)) +(compile-goto-error))) + (jump (data) + (pcase data + (`(,buf ,line ,command ,root) +(if (get-buffer buf) +(progn + (ggtags-global--display-buffer buf) + (move-to-error buf line)) + (with-current-buffer + (let ((ggtags-auto-jump-to-first-match nil)) +(ggtags-global-start command root)) +(add-hook 'compilation-finish-functions + (lambda (buf _msg) (move-to-error buf line)) + nil t) +(rename-buffer buf)) + (prn (data) +(pcase data + (`(,_buf ,line ,command ,root) + (princ (format a ggtags search session `%s' in directory `%s' at line %d. + command root line)) + (set-register r (registerv-make + (list (buffer-name) (line-number-at-pos) +(car compilation-arguments) default-directory) + :jump-func #'jump :print-func #'prn) + (defun ggtags-delete-tag-files () Delete the tag files generated by gtags. (interactive (ignore (ggtags-check-project))) @@ -1445,6 +1487,7 @@ When finished invoke CALLBACK in BUFFER with process exit status. (define-key m \M-k 'ggtags-kill-file-buffers) (define-key m \M-h 'ggtags-view-tag-history) (define-key m \M-j 'ggtags-visit-project-root) +(define-key m (kbd M-SPC) 'ggtags-save-to-register) (define-key m (kbd M-%) 'ggtags-query-replace) (define-key m \M-? 'ggtags-show-definition) m)) @@ -1495,6 +1538,8 @@ When finished invoke CALLBACK in BUFFER with process exit status. (define-key menu [prev-mark] '(menu-item Previous mark ggtags-prev-mark)) (define-key menu [sep1] menu-bar-separator) +(define-key menu [save-to-register] + '(menu-item Save search session ggtags-save-to-register)) (define-key menu [previous-error] '(menu-item Previous match previous-error)) (define-key menu [next-error]
[elpa] 26/38: New macro ignore-errors-unless-debug and use it
leoliu pushed a commit to branch master in repository elpa. commit 030251c21c0f0c76d0898bc83ae5d32ee17197ba Author: Leo Liu sdl@gmail.com Date: Thu Mar 20 11:03:03 2014 +0800 New macro ignore-errors-unless-debug and use it --- ggtags.el | 39 ++- 1 files changed, 22 insertions(+), 17 deletions(-) diff --git a/ggtags.el b/ggtags.el index b3def18..1b1dc84 100644 --- a/ggtags.el +++ b/ggtags.el @@ -71,7 +71,12 @@ (defmacro defvar-local (var val optional docstring) (declare (debug defvar) (doc-string 3)) (list 'progn (list 'defvar var val docstring) -(list 'make-variable-buffer-local (list 'quote var)) +(list 'make-variable-buffer-local (list 'quote var) + + (defmacro ignore-errors-unless-debug (rest body) +Ignore all errors while executing BODY unless debug is on. +(declare (debug t) (indent 0)) +`(condition-case-unless-debug nil (progn ,@body) (error nil (eval-and-compile (or (fboundp 'user-error) ;24.3 @@ -400,10 +405,11 @@ Value is new modtime if updated. (ggtags-find-project)) project) (setq ggtags-project-root -(or (ignore-errors (file-name-as-directory -(concat (file-remote-p default-directory) -;; Resolves symbolic links -(ggtags-process-string global -pr +(or (ignore-errors-unless-debug + (file-name-as-directory + (concat (file-remote-p default-directory) + ;; Resolves symbolic links + (ggtags-process-string global -pr ;; 'global -pr' resolves symlinks before checking the ;; GTAGS file which could cause issues such as ;; https://github.com/leoliu/ggtags/issues/22, so @@ -592,18 +598,17 @@ non-nil. (unless (equal cache-key (car ggtags-completion-cache)) (setq ggtags-completion-cache (cons cache-key - (condition-case-unless-debug nil - ;; May throw global: only name char is - ;; allowed with -c option. - (ggtags-with-current-project - (split-string - (apply #'ggtags-process-string - global - (append (and completion-ignore-case '(--ignore-case)) - ;; Note -c alone returns only definitions - (list (concat -c ggtags-completion-flag) prefix))) - \n t)) - (error nil)) + (ignore-errors-unless-debug + ;; May throw global: only name char is allowed + ;; with -c option. + (ggtags-with-current-project +(split-string + (apply #'ggtags-process-string +global +(append (and completion-ignore-case '(--ignore-case)) +;; Note -c alone returns only definitions +(list (concat -c ggtags-completion-flag) prefix))) + \n t))) (cdr ggtags-completion-cache (defun ggtags-completion-at-point ()
[elpa] 01/38: New command ggtags-show-definition
leoliu pushed a commit to branch master in repository elpa. commit 9ae7b47544887344bf2a6ca8b67ca10c31e5e348 Author: Leo Liu sdl@gmail.com Date: Mon Mar 3 14:27:41 2014 +0800 New command ggtags-show-definition New function ggtags-global-output to handle global output. Rename ggtags-global-next-error-hook to ggtags-find-tag-hook. --- ggtags.el | 64 +--- 1 files changed, 60 insertions(+), 4 deletions(-) diff --git a/ggtags.el b/ggtags.el index 32a069e..542affe 100644 --- a/ggtags.el +++ b/ggtags.el @@ -3,7 +3,7 @@ ;; Copyright (C) 2013-2014 Free Software Foundation, Inc. ;; Author: Leo Liu sdl@gmail.com -;; Version: 0.7.12 +;; Version: 0.8.0 ;; Keywords: tools, convenience ;; Created: 2013-01-29 ;; URL: https://github.com/leoliu/ggtags @@ -177,12 +177,18 @@ If an integer abbreviate only names longer than that number. :type 'number :group 'ggtags) -(defcustom ggtags-global-next-error-hook nil +(defcustom ggtags-find-tag-hook nil Hook run immediately after finding a tag. - :options '(reposition-window recenter) + :options '(recenter reposition-window) :type 'hook :group 'ggtags) +(defcustom ggtags-show-definition-function #'ggtags-show-definition-default + Function called by `ggtags-show-definition' to show definition. +It is passed a list of definnition candidates. + :type 'function + :group 'ggtags) + (defcustom ggtags-mode-sticky t If non-nil enable Ggtags Mode in files visited. :safe 'booleanp @@ -1217,7 +1223,7 @@ Global and Emacs. (move-overlay ggtags-global-line-overlay (line-beginning-position) (line-end-position) (current-buffer - (run-hooks 'ggtags-global-next-error-hook)) + (run-hooks 'ggtags-find-tag-hook)) (define-minor-mode ggtags-navigation-mode nil :lighter @@ -1281,6 +1287,53 @@ Global and Emacs. (process-file global nil 0 nil --single-update (file-relative-name buffer-file-name)) +(defun ggtags-global-output (cmds buffer callback optional cutoff) + Asynchrously pipe the output of CMDS to BUFFER. +Invoke CALLBACK in BUFFER with process exit status when finished. + (or buffer (error Output buffer required)) + (let* ((default-directory (or (ggtags-current-project-root) default-directory)) + (program (car cmds)) + (args (cdr cmds)) + (cutoff (+ cutoff (if (get-buffer buffer) + (with-current-buffer buffer + (line-number-at-pos (point-max))) + 0))) + (proc (apply #'start-file-process program buffer program args)) + (filter (lambda (proc string) + (and (buffer-live-p (process-buffer proc)) +(with-current-buffer (process-buffer proc) + (goto-char (process-mark proc)) + (insert string) + (when (and ( (line-number-at-pos (point-max)) cutoff) + (process-live-p proc)) +(interrupt-process (current-buffer))) + (sentinel (lambda (proc _msg) + (when (memq (process-status proc) '(exit signal)) + (with-current-buffer (process-buffer proc) + (set-process-buffer proc nil) + (funcall callback (process-status proc))) +(set-process-query-on-exit-flag proc nil) +(and cutoff (set-process-filter proc filter)) +(set-process-sentinel proc sentinel) +proc)) + +(defun ggtags-show-definition-default (defs) + (let (message-log-max) +(message %s (or (car defs) [definition not found] + +(defun ggtags-show-definition (name) + (interactive (list (ggtags-read-tag))) + (let* ((re (cadr (assq 'grep ggtags-global-error-regexp-alist-alist))) + (buffer (get-buffer-create *ggtags-output*)) + (fn ggtags-show-definition-function) + (show (lambda (_status) + (goto-char (point-min)) + (funcall fn (loop while (re-search-forward re nil t) + collect (buffer-substring (1+ (match-end 2)) + (line-end-position + (kill-buffer buffer +(ggtags-global-output (list global --result=grep name) buffer show 30))) + (defvar ggtags-mode-prefix-map (let ((m (make-sparse-keymap))) (define-key m \M-' 'previous-error) @@ -1296,6 +1349,7 @@ Global and Emacs. (define-key m \M-h 'ggtags-view-tag-history) (define-key m \M-j 'ggtags-visit-project-root) (define-key m (kbd M-%) 'ggtags-query-replace) +(define-key m \M-? 'ggtags-show-definition) m)) (defvar ggtags-mode-map @@ -1360,6 +1414,8 @@ Global and Emacs. '(menu-item Find other symbol ggtags-find-other-symbol)) (define-key
[elpa] 05/38: Improve completion support for all tag types
leoliu pushed a commit to branch master in repository elpa. commit 51bd905f5169fea0cd757dccbe8f2a61feb28a5f Author: Leo Liu sdl@gmail.com Date: Tue Mar 4 19:32:15 2014 +0800 Improve completion support for all tag types Make ggtags-read-tag more flexible and remove ggtags-read-string which is no longer used. --- ggtags.el | 95 - 1 files changed, 50 insertions(+), 45 deletions(-) diff --git a/ggtags.el b/ggtags.el index a68347e..379eadc 100644 --- a/ggtags.el +++ b/ggtags.el @@ -529,21 +529,26 @@ non-nil. (defvar-local ggtags-completion-cache nil) +(defvar ggtags-completion-flag ) ;internal use + (defvar ggtags-completion-table (completion-table-dynamic (lambda (prefix) - (unless (equal prefix (car ggtags-completion-cache)) - (setq ggtags-completion-cache - (cons prefix - (ggtags-with-current-project -(split-string - (apply #'ggtags-process-string -global -;; Note -c alone returns only definitions -(if completion-ignore-case -(list --ignore-case -Tc prefix) - (list -Tc prefix))) - \n t) + (let ((cache-key (concat prefix $ ggtags-completion-flag))) + (unless (equal cache-key (car ggtags-completion-cache)) + (setq ggtags-completion-cache + (cons cache-key + (ignore-errors + ;; May throw global: only name char is allowed + ;; with -c option. + (ggtags-with-current-project +(split-string + (apply #'ggtags-process-string +global +(append (and completion-ignore-case '(--ignore-case)) +;; Note -c alone returns only definitions +(list (concat -c ggtags-completion-flag) prefix))) + \n t))) (cdr ggtags-completion-cache (defun ggtags-completion-at-point () @@ -552,16 +557,25 @@ non-nil. (and ( (car bounds) (cdr bounds)) (list (car bounds) (cdr bounds) ggtags-completion-table -(defun ggtags-read-tag () +(defun ggtags-read-tag (optional type confirm prompt require-match default) (ggtags-ensure-project) - (let ((default (ggtags-tag-at-point)) -(completing-read-function ggtags-completing-read-function)) + (let ((default (or default (ggtags-tag-at-point))) +(completing-read-function ggtags-completing-read-function) +(prompt (or prompt (capitalize (symbol-name (or type 'tag) +(ggtags-completion-flag (pcase type + (`(or nil definition) T) + (`symbol s) + (`reference r) + (`id I) + (`path P) + ((pred stringp) type) + (_ ggtags-completion-flag (setq ggtags-current-tag-name - (cond (current-prefix-arg + (cond (confirm (ggtags-update-tags) (completing-read - (format (if default Tag (default %s): Tag: ) default) - ggtags-completion-table nil t nil nil default)) + (format (if default %s (default %s): %s: ) prompt default) + ggtags-completion-table nil require-match nil nil default)) ((not default) (user-error No tag at point)) (t (substring-no-properties default)) @@ -639,7 +653,8 @@ non-nil. Find definitions or references of tag NAME by context. If point is at a definition tag, find references, and vice versa. With a prefix arg (non-nil DEFINITION) always find definitions. - (interactive (list (ggtags-read-tag) current-prefix-arg)) + (interactive (list (ggtags-read-tag 'definition current-prefix-arg) + current-prefix-arg)) (ggtags-check-project) ; for `ggtags-current-project-root' below (if (or definition (not buffer-file-name) @@ -661,46 +676,36 @@ With a prefix arg (non-nil DEFINITION) always find definitions. name))) (defun ggtags-find-reference (name) - (interactive (list (ggtags-read-tag))) + (interactive (list (ggtags-read-tag 'reference current-prefix-arg))) (ggtags-find-tag 'reference name)) (defun ggtags-find-other-symbol (name) Find tag NAME that is a reference without a definition. - (interactive (list (ggtags-read-tag))) + (interactive (list (ggtags-read-tag 'symbol current-prefix-arg))) (ggtags-find-tag 'symbol name)) -(defun ggtags-read-string (prompt) - Like `read
[elpa] 16/38: Fix ggtags-show-definition to run in current project
leoliu pushed a commit to branch master in repository elpa. commit 671601355a044b15a5004cba6dab670bd0c46818 Author: Leo Liu sdl@gmail.com Date: Wed Mar 12 10:13:53 2014 +0800 Fix ggtags-show-definition to run in current project --- ggtags.el |9 + 1 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ggtags.el b/ggtags.el index 16a4a36..18f10b9 100644 --- a/ggtags.el +++ b/ggtags.el @@ -1372,10 +1372,11 @@ When finished invoke CALLBACK in BUFFER with process exit status. (kill-buffer buffer) (with-current-buffer current (funcall fn defs)) -(ggtags-global-output - buffer - (list global --result=grep --path-style=absolute name) - show 100))) +(ggtags-with-current-project + (ggtags-global-output + buffer + (list global --result=grep --path-style=absolute name) + show 100 (defvar ggtags-mode-prefix-map (let ((m (make-sparse-keymap)))
[elpa] 13/38: Require cl-lib and remove macro when-let
leoliu pushed a commit to branch master in repository elpa. commit c352dc8ca641794c9eb7e5b2371ae25030012e9c Author: Leo Liu sdl@gmail.com Date: Fri Mar 7 11:22:12 2014 +0800 Require cl-lib and remove macro when-let --- ggtags.el | 161 + 1 files changed, 77 insertions(+), 84 deletions(-) diff --git a/ggtags.el b/ggtags.el index 087a17b..c2f09e1 100644 --- a/ggtags.el +++ b/ggtags.el @@ -7,7 +7,7 @@ ;; Keywords: tools, convenience ;; Created: 2013-01-29 ;; URL: https://github.com/leoliu/ggtags -;; Package-Requires: ((emacs 24)) +;; Package-Requires: ((emacs 24) (cl-lib 0.5)) ;; 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 @@ -55,9 +55,9 @@ ;;; Code: (eval-when-compile - (require 'cl) (require 'url-parse)) +(require 'cl-lib) (require 'compile) (require 'etags) (require 'tabulated-list) ;preloaded since 24.3 @@ -71,12 +71,7 @@ (defmacro defvar-local (var val optional docstring) (declare (debug defvar) (doc-string 3)) (list 'progn (list 'defvar var val docstring) -(list 'make-variable-buffer-local (list 'quote var) - - (defmacro* when-let ((var exp) rest body) -A macro that combines `let' and `when'. -(declare (indent 1) (debug ((sexp form) body))) -`(let ((,var ,exp)) (when ,var ,@body +(list 'make-variable-buffer-local (list 'quote var)) (eval-and-compile (or (fboundp 'user-error) @@ -218,8 +213,8 @@ Users should change the value using `customize-variable' to properly update `ggtags-mode-map'. :set (lambda (sym value) (when (bound-and-true-p ggtags-mode-map) - (when-let (old (and (boundp sym) (symbol-value sym))) - (define-key ggtags-mode-map old nil)) + (let ((old (and (boundp sym) (symbol-value sym + (and old (define-key ggtags-mode-map old nil))) (and value (bound-and-true-p ggtags-mode-prefix-map) (define-key ggtags-mode-map value ggtags-mode-prefix-map))) @@ -289,21 +284,21 @@ properly update `ggtags-mode-map'. output))) (defun ggtags-tag-at-point () - (when-let (bounds (funcall ggtags-bounds-of-tag-function)) -(buffer-substring (car bounds) (cdr bounds + (pcase (funcall ggtags-bounds-of-tag-function) +(`(,beg . ,end) (buffer-substring beg end ;;; Store for project info and settings (defvar ggtags-projects (make-hash-table :size 7 :test #'equal)) -(defstruct (ggtags-project (:constructor ggtags-project--make) - (:copier nil) - (:type vector) - :named) +(cl-defstruct (ggtags-project (:constructor ggtags-project--make) + (:copier nil) + (:type vector) + :named) root tag-size has-refs has-path-style has-color dirty-p mtime timestamp) (defun ggtags-make-project (root) - (check-type root string) + (cl-check-type root string) (pcase (nthcdr 5 (file-attributes (expand-file-name GTAGS root))) (`(,mtime ,_ ,tag-size . ,_) (let* ((default-directory (file-name-as-directory root)) @@ -357,8 +352,8 @@ Value is new modtime if updated. (pcase ggtags-oversize-limit (`nil nil) (`t t) -(size (when-let (project (or project (ggtags-find-project))) -( (ggtags-project-tag-size project) size) +(size (let ((project (or project (ggtags-find-project +(and project ( (ggtags-project-tag-size project) size)) (defvar-local ggtags-project-root 'unset Internal variable for project root directory.) @@ -427,13 +422,13 @@ Value is new modtime if updated. (and (not (ggtags-project-has-refs (ggtags-find-project))) (list GTAGSLABEL=ctags (envlist (delete-dups - (loop for x in process-environment - when (string-match - ^\\(GTAGS[^=\n]*\\|MAKEOBJDIRPREFIX\\)= x) - ;; May have duplicates thus `delete-dups'. - collect (concat (match-string 1 x) - = - (getenv (match-string 1 x)) + (cl-loop for x in process-environment +when (string-match + ^\\(GTAGS[^=\n]*\\|MAKEOBJDIRPREFIX\\)= x) +;; May have duplicates thus `delete-dups'. +collect (concat (match-string 1 x) += +(getenv (match-string 1 x)) (help-form (format y: save\nn: don't save\n=: diff\n?: help\n))) (add-dir-local-variable nil 'ggtags
[elpa] 07/14: Implement feature #43: Jump to match from search history
leoliu pushed a commit to branch master in repository elpa. commit 5e0d32a10092cc940ae4c5ee902f038509f28116 Author: Leo Liu sdl@gmail.com Date: Fri Mar 28 18:22:54 2014 +0800 Implement feature #43: Jump to match from search history Rename ggtags-auto-jump-to-first-match to ggtags-auto-jump-to-match accordingly. --- ggtags.el | 48 ++-- 1 files changed, 34 insertions(+), 14 deletions(-) diff --git a/ggtags.el b/ggtags.el index 6b373e9..0f2f9fa 100644 --- a/ggtags.el +++ b/ggtags.el @@ -141,9 +141,15 @@ directory local variables is not enabled by default per :type '(repeat string) :group 'ggtags) -(defcustom ggtags-auto-jump-to-first-match t - Non-nil to automatically jump to the first match. - :type 'boolean +(defcustom ggtags-auto-jump-to-match 'first + Strategy on how to jump to match: nil, first or history. + + nil: never automatically jump to any match; +first: jump to the first match; +history: jump to the match stored in search history. + :type '(choice (const :tag First match first) + (const :tag Search History history) + (const :tag Never nil)) :group 'ggtags) (defcustom ggtags-global-window-height 8 ; ggtags-global-mode @@ -680,11 +686,12 @@ Do nothing if GTAGS exceeds the oversize limit unless FORCE. ;; takes three values: nil, t and a marker (defvar ggtags-global-start-marker nil) - (defvar ggtags-global-exit-status 0) (defvar ggtags-global-match-count 0) - (defvar ggtags-tag-ring-index nil) +(defvar ggtags-global-search-history nil) + +(defvar ggtags-auto-jump-to-match-target nil) (defun ggtags-global-save-start-marker () (when (markerp ggtags-global-start-marker) @@ -697,12 +704,15 @@ Do nothing if GTAGS exceeds the oversize limit unless FORCE. (split-window-preferred-function ggtags-split-window-function) ;; See http://debbugs.gnu.org/13594 (display-buffer-overriding-action - (if (and ggtags-auto-jump-to-first-match + (if (and ggtags-auto-jump-to-match ;; Appeared in emacs 24.4. (fboundp 'display-buffer-no-window)) (list #'display-buffer-no-window) display-buffer-overriding-action)) - (env ggtags-process-environment)) + (env ggtags-process-environment) + (ggtags-auto-jump-to-match-target + (nth 4 (assoc (ggtags-global-search-id command default-directory) +ggtags-global-search-history (setq ggtags-global-start-marker (point-marker)) (ggtags-navigation-mode +1) (setq ggtags-global-exit-status 0 @@ -834,7 +844,7 @@ Global and Emacs. (let ((args (query-replace-read-args Query replace (regexp) t t))) (list (nth 0 args) (nth 1 args) (nth 2 args (unless ggtags-navigation-mode -(let ((ggtags-auto-jump-to-first-match nil)) +(let ((ggtags-auto-jump-to-match nil)) (ggtags-grep from))) (let ((file-form '(let ((files)) @@ -853,8 +863,6 @@ Global and Emacs. (nreverse files (tags-query-replace from to delimited file-form))) -(defvar ggtags-global-search-history nil) - (defun ggtags-global-search-id (cmd directory) (sha1 (concat directory (make-string 1 0) cmd))) @@ -871,7 +879,7 @@ Global and Emacs. (defun ggtags-global-rerun-search-1 (data) (pcase data (`(,cmd ,dir ,env ,line ,_text) - (with-current-buffer (let ((ggtags-auto-jump-to-first-match nil) + (with-current-buffer (let ((ggtags-auto-jump-to-match nil) ;; Switch current project to DIR. (default-directory dir) (ggtags-project-root dir) @@ -1284,6 +1292,14 @@ commands `next-error' and `previous-error'. (count-lines compilation-filter-start (point))) (when (and ( ggtags-global-output-lines 5) ggtags-navigation-mode) (ggtags-global--display-buffer)) + (when (and (numberp ggtags-auto-jump-to-match-target) + ;; `ggtags-global-output-lines' is imprecise. + ( (line-number-at-pos (point-max)) +ggtags-auto-jump-to-match-target)) +(ggtags-forward-to-line ggtags-auto-jump-to-match-target) +(setq-local ggtags-auto-jump-to-match-target nil) +(compilation--ensure-parse (line-beginning-position 2)) +(with-demoted-errors (compile-goto-error))) (make-local-variable 'ggtags-global-large-output) (when ( ggtags-global-output-lines ggtags-global-large-output) (cl-incf ggtags-global-large-output 500) @@ -1295,7 +1311,7 @@ commands `next-error' and `previous-error'. (if (string-prefix-p exited abnormally how) ;; If exit abnormally display the buffer for inspection. (ggtags-global--display-buffer) -(when (and ggtags-auto-jump-to-first-match +(when (and ggtags-auto-jump-to-match (save-excursion (goto-char (point
[elpa] 13/14: Fix #44: New variable ggtags-enable-navigation-keys
leoliu pushed a commit to branch master in repository elpa. commit 6b7bb1ac734e9cc45fa301e4a9419c4c1fd95427 Author: Leo Liu sdl@gmail.com Date: Sun Mar 30 11:46:34 2014 +0800 Fix #44: New variable ggtags-enable-navigation-keys to control ggtags-navigation-map. Using ggtags-navigation-mode is unsafe because it is used more than controlling ggtags-navigation-map. Affect #40: ggtags-suppress-navigation-keys is removed; use ggtags-enable-navigation-keys instead. --- ggtags.el | 18 +- 1 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ggtags.el b/ggtags.el index 98c1212..faf4d06 100644 --- a/ggtags.el +++ b/ggtags.el @@ -213,8 +213,9 @@ This affects `ggtags-find-file' and `ggtags-grep'. :type 'integer :group 'ggtags) -(defcustom ggtags-suppress-navigation-keys nil - If non-nil key bindings in `ggtags-navigation-map' are suppressed. +(defcustom ggtags-enable-navigation-keys t + If non-nil key bindings in `ggtags-navigation-map' are enabled. + :safe 'booleanp :type 'boolean :group 'ggtags) @@ -942,7 +943,7 @@ Global and Emacs. (erase-buffer) (special-mode) (use-local-map ggtags-global-rerun-search-map) -(setq-local ggtags-navigation-mode nil) +(setq-local ggtags-enable-navigation-keys nil) (setq-local bookmark-make-record-function #'ggtags-make-bookmark-record) (setq truncate-lines t) (cl-labels ((prop (s) (propertize s 'face 'minibuffer-prompt)) @@ -1290,8 +1291,7 @@ commands `next-error' and `previous-error'. (cl-incf ggtags-global-output-lines (count-lines compilation-filter-start (point))) (when (and ( ggtags-global-output-lines 5) ggtags-navigation-mode) -(ggtags-global--display-buffer) -(setq-local ggtags-navigation-mode nil)) +(ggtags-global--display-buffer)) (when (and (eq ggtags-auto-jump-to-match 'history) (numberp ggtags-auto-jump-to-match-target) ;; `ggtags-global-output-lines' is imprecise. @@ -1368,6 +1368,7 @@ commands `next-error' and `previous-error'. (add-hook 'compilation-filter-hook 'ggtags-global-filter nil 'local) (add-hook 'compilation-finish-functions 'ggtags-global-handle-exit nil t) (setq-local bookmark-make-record-function #'ggtags-make-bookmark-record) + (setq-local ggtags-enable-navigation-keys nil) (add-hook 'kill-buffer-hook (lambda () (ggtags-navigation-mode -1)) nil t)) ;; NOTE: Need this to avoid putting menu items in @@ -1394,7 +1395,7 @@ commands `next-error' and `previous-error'. map)) (defvar ggtags-mode-map-alist - `((ggtags-navigation-mode . ,ggtags-navigation-map))) + `((ggtags-enable-navigation-keys . ,ggtags-navigation-map))) (defvar ggtags-navigation-mode-map (let ((map (make-sparse-keymap)) @@ -1567,8 +1568,7 @@ commands `next-error' and `previous-error'. (progn ;; Higher priority for `ggtags-navigation-mode' to avoid being ;; hijacked by modes such as `view-mode'. -(unless ggtags-suppress-navigation-keys - (add-to-list 'emulation-mode-map-alists 'ggtags-mode-map-alist)) +(add-to-list 'emulation-mode-map-alists 'ggtags-mode-map-alist) (add-hook 'next-error-hook 'ggtags-global-next-error-function) (add-hook 'minibuffer-setup-hook 'ggtags-minibuffer-setup-function)) (setq emulation-mode-map-alists @@ -1578,7 +1578,7 @@ commands `next-error' and `previous-error'. (defun ggtags-minibuffer-setup-function () ;; Disable ggtags-navigation-mode in minibuffer. - (setq-local ggtags-navigation-mode nil)) + (setq-local ggtags-enable-navigation-keys nil)) (defun ggtags-kill-file-buffers (optional interactive) Kill all buffers visiting files in current project.
[elpa] branch master updated (b8924f8 - 3dc7169)
leoliu pushed a change to branch master in repository elpa. from b8924f8 [gnugo int] Add abstraction: gnugo--move-prop new e132331 Enhance ggtags-view-tag-history to use next-/previous-error new c4f703a Fix #12: Remove ggtags-completing-read-function new 27c7037 Change ggtags-read-tag to completing-read when no default new d2f293a Fix ggtags-try-complete-tag to use ggtags-bounds-of-tag-function new a0d7e04 Fix #42: Clear ggtags-project-root in non-file buffers new aed4159 New user variable ggtags-global-use-color new 5e0d32a Implement feature #43: Jump to match from search history new 9cf2d44 Fix warning: Making variable buffer-local while let-bound! new bace0b0 Use compilation-auto-jump in ggtags-global-filter new 94d915a Disable ggtags-navigation-mode at the right time new 6515e1a Rename ggtags-handle-single-match to ggtags-global-handle-exit new 03271b3 Fix ggtags-navigation-mode-abort when pop-tag-mark errs new 6b7bb1a Fix #44: New variable ggtags-enable-navigation-keys new 3dc7169 Merge branch 'master' of github.com:leoliu/ggtags The 14 revisions listed above as new are entirely new to this repository and will be described in separate emails. The revisions listed as adds were already present in the repository and have only been added to this reference. Summary of changes: packages/ggtags/README.rst | 13 ++- packages/ggtags/ggtags.el | 266 +++- 2 files changed, 170 insertions(+), 109 deletions(-)
[elpa] 02/14: Fix #12: Remove ggtags-completing-read-function
leoliu pushed a commit to branch master in repository elpa. commit c4f703ad106e2caf303adc615516b78862449bdf Author: Leo Liu sdl@gmail.com Date: Wed Mar 26 14:33:13 2014 +0800 Fix #12: Remove ggtags-completing-read-function Not needed and may get in the way. Fix typos. --- ggtags.el | 14 -- 1 files changed, 4 insertions(+), 10 deletions(-) diff --git a/ggtags.el b/ggtags.el index 8435ccb..031cb3e 100644 --- a/ggtags.el +++ b/ggtags.el @@ -244,11 +244,6 @@ properly update `ggtags-mode-map'. :type 'key-sequence :group 'ggtags) -(defcustom ggtags-completing-read-function completing-read-function - Ggtags specific `completing-read-function' (which see). - :type 'function - :group 'ggtags) - (defcustom ggtags-highlight-tag-delay 0.25 Time in seconds before highlighting tag at point. :set (lambda (sym value) @@ -624,7 +619,6 @@ Do nothing if GTAGS exceeds the oversize limit unless FORCE. (defun ggtags-read-tag (optional type confirm prompt require-match default) (ggtags-ensure-project) (let ((default (or default (ggtags-tag-at-point))) -(completing-read-function ggtags-completing-read-function) (prompt (or prompt (capitalize (symbol-name (or type 'tag) (ggtags-completion-flag (pcase type (`(or nil definition) T) @@ -1375,10 +1369,10 @@ commands `next-error' and `previous-error'. '(menu-item Finish navigation ggtags-navigation-mode-done)) (define-key menu [abort] '(menu-item Abort ggtags-navigation-mode-abort)) -(define-key menu [last-error] - '(menu-item Last error ggtags-navigation-last-error)) -(define-key menu [fist-error] - '(menu-item Fist error ggtags-navigation-first-error)) +(define-key menu [last-match] + '(menu-item Last match ggtags-navigation-last-error)) +(define-key menu [first-match] + '(menu-item First match ggtags-navigation-first-error)) (define-key menu [previous-file] '(menu-item Previous file ggtags-navigation-previous-file)) (define-key menu [next-file]
[elpa] 04/14: Fix ggtags-try-complete-tag to use ggtags-bounds-of-tag-function
leoliu pushed a commit to branch master in repository elpa. commit d2f293a458bedf2f856c67b2c8dd202ee2b648c5 Author: Leo Liu sdl@gmail.com Date: Thu Mar 27 07:46:13 2014 +0800 Fix ggtags-try-complete-tag to use ggtags-bounds-of-tag-function --- ggtags.el | 38 ++ 1 files changed, 18 insertions(+), 20 deletions(-) diff --git a/ggtags.el b/ggtags.el index 81d807a..e31b45f 100644 --- a/ggtags.el +++ b/ggtags.el @@ -1192,7 +1192,7 @@ commands `next-error' and `previous-error'. (defvar ggtags-global-error-regexp-alist-alist (append `((path ^\\(?:[^\'\n]*/\\)?[^ )\t\n]+$ 0) - ;; ACTIVE_ESCAPE src/dialog.cc 172 + ;; ACTIVE_ESCAPE src/dialog.cc 172 (ctags ^\\([^ \t\n]+\\)[ \t]+\\(.*?\\)[ \t]+\\([0-9]+\\)$ 2 3 nil nil 2 (1 font-lock-function-name-face)) ;; ACTIVE_ESCAPE 172 src/dialog.cc#undef ACTIVE_ESCAPE @@ -1850,25 +1850,23 @@ to nil disables displaying this information.) ;;;###autoload (defun ggtags-try-complete-tag (old) A function suitable for `hippie-expand-try-functions-list'. - (with-no-warnings ; to avoid loading hippie-exp -(unless old - (he-init-string (if (looking-back \\_.* (line-beginning-position)) - (match-beginning 0) -(point)) - (point)) - (setq he-expand-list -(and (not (equal he-search-string )) - (ggtags-find-project) - (sort (all-completions he-search-string -ggtags-completion-table) - #'string-lessp -(if (null he-expand-list) -(progn - (if old (he-reset-string)) - nil) - (he-substitute-string (car he-expand-list)) - (setq he-expand-list (cdr he-expand-list)) - t))) + (eval-and-compile (require 'hippie-exp)) + (unless old +(he-init-string (or (car (funcall ggtags-bounds-of-tag-function)) (point)) +(point)) +(setq he-expand-list + (and (not (equal he-search-string )) + (ggtags-find-project) + (sort (all-completions he-search-string + ggtags-completion-table) + #'string-lessp + (if (null he-expand-list) + (progn +(if old (he-reset-string)) +nil) +(he-substitute-string (car he-expand-list)) +(setq he-expand-list (cdr he-expand-list)) +t)) (defun ggtags-reload (optional force) (interactive P)
[elpa] 09/14: Use compilation-auto-jump in ggtags-global-filter
leoliu pushed a commit to branch master in repository elpa. commit bace0b0ba21f80a9b4bf1b958b67571183d046f4 Author: Leo Liu sdl@gmail.com Date: Fri Mar 28 21:50:06 2014 +0800 Use compilation-auto-jump in ggtags-global-filter to correctly set point in that window. --- ggtags.el | 11 +-- 1 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ggtags.el b/ggtags.el index 700d16b..3347c37 100644 --- a/ggtags.el +++ b/ggtags.el @@ -1292,13 +1292,20 @@ commands `next-error' and `previous-error'. (count-lines compilation-filter-start (point))) (when (and ( ggtags-global-output-lines 5) ggtags-navigation-mode) (ggtags-global--display-buffer)) - (when (and (numberp ggtags-auto-jump-to-match-target) + (when (and (eq ggtags-auto-jump-to-match 'history) + (numberp ggtags-auto-jump-to-match-target) ;; `ggtags-global-output-lines' is imprecise. ( (line-number-at-pos (point-max)) ggtags-auto-jump-to-match-target)) (ggtags-forward-to-line ggtags-auto-jump-to-match-target) (setq-local ggtags-auto-jump-to-match-target nil) -(with-demoted-errors (compile-goto-error))) +;; +;; Can't call `compile-goto-error' here becuase +;; `compilation-filter' restores point and as a result commands +;; dependent on point such as `ggtags-navigation-next-file' and +;; `ggtags-navigation-previous-file' fail to work. +(setq-local compilation-auto-jump-to-first-error t) +(run-with-idle-timer 0 nil #'compilation-auto-jump (current-buffer) (point))) (make-local-variable 'ggtags-global-large-output) (when ( ggtags-global-output-lines ggtags-global-large-output) (cl-incf ggtags-global-large-output 500)
[elpa] 10/14: Disable ggtags-navigation-mode at the right time
leoliu pushed a commit to branch master in repository elpa. commit 94d915a43841f0b47d71110973ed668e7f1d215f Author: Leo Liu sdl@gmail.com Date: Sat Mar 29 10:54:56 2014 +0800 Disable ggtags-navigation-mode at the right time Otherwise the *ggtags-global* buffer is not displayed until compilation finishes. --- ggtags.el |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ggtags.el b/ggtags.el index 3347c37..f93955b 100644 --- a/ggtags.el +++ b/ggtags.el @@ -1291,7 +1291,8 @@ commands `next-error' and `previous-error'. (cl-incf ggtags-global-output-lines (count-lines compilation-filter-start (point))) (when (and ( ggtags-global-output-lines 5) ggtags-navigation-mode) -(ggtags-global--display-buffer)) +(ggtags-global--display-buffer) +(setq-local ggtags-navigation-mode nil)) (when (and (eq ggtags-auto-jump-to-match 'history) (numberp ggtags-auto-jump-to-match-target) ;; `ggtags-global-output-lines' is imprecise. @@ -1368,7 +1369,6 @@ commands `next-error' and `previous-error'. (add-hook 'compilation-filter-hook 'ggtags-global-filter nil 'local) (add-hook 'compilation-finish-functions 'ggtags-handle-single-match nil t) (setq-local bookmark-make-record-function #'ggtags-make-bookmark-record) - (setq-local ggtags-navigation-mode nil) (add-hook 'kill-buffer-hook (lambda () (ggtags-navigation-mode -1)) nil t)) ;; NOTE: Need this to avoid putting menu items in
[elpa] 14/14: Merge branch 'master' of github.com:leoliu/ggtags
leoliu pushed a commit to branch master in repository elpa. commit 3dc7169f617fbaeac115e8089e470fc115ae444f Merge: b8924f8 6b7bb1a Author: Leo Liu sdl@gmail.com Date: Sun Mar 30 14:59:38 2014 +0800 Merge branch 'master' of github.com:leoliu/ggtags packages/ggtags/README.rst | 13 ++- packages/ggtags/ggtags.el | 266 +++- 2 files changed, 170 insertions(+), 109 deletions(-)
[elpa] 08/14: Fix warning: Making variable buffer-local while let-bound!
leoliu pushed a commit to branch master in repository elpa. commit 9cf2d44300096d1396214e06fdfec99d873d9e20 Author: Leo Liu sdl@gmail.com Date: Fri Mar 28 19:03:44 2014 +0800 Fix warning: Making variable buffer-local while let-bound! for ggtags-auto-jump-to-match-target. Disable ggtags-navigation-mode in ggtags-global-mode. --- ggtags.el | 10 +- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ggtags.el b/ggtags.el index 0f2f9fa..700d16b 100644 --- a/ggtags.el +++ b/ggtags.el @@ -709,11 +709,11 @@ Do nothing if GTAGS exceeds the oversize limit unless FORCE. (fboundp 'display-buffer-no-window)) (list #'display-buffer-no-window) display-buffer-overriding-action)) - (env ggtags-process-environment) - (ggtags-auto-jump-to-match-target - (nth 4 (assoc (ggtags-global-search-id command default-directory) -ggtags-global-search-history + (env ggtags-process-environment)) (setq ggtags-global-start-marker (point-marker)) +(setq ggtags-auto-jump-to-match-target + (nth 4 (assoc (ggtags-global-search-id command default-directory) +ggtags-global-search-history))) (ggtags-navigation-mode +1) (setq ggtags-global-exit-status 0 ggtags-global-match-count 0) @@ -1298,7 +1298,6 @@ commands `next-error' and `previous-error'. ggtags-auto-jump-to-match-target)) (ggtags-forward-to-line ggtags-auto-jump-to-match-target) (setq-local ggtags-auto-jump-to-match-target nil) -(compilation--ensure-parse (line-beginning-position 2)) (with-demoted-errors (compile-goto-error))) (make-local-variable 'ggtags-global-large-output) (when ( ggtags-global-output-lines ggtags-global-large-output) @@ -1362,6 +1361,7 @@ commands `next-error' and `previous-error'. (add-hook 'compilation-filter-hook 'ggtags-global-filter nil 'local) (add-hook 'compilation-finish-functions 'ggtags-handle-single-match nil t) (setq-local bookmark-make-record-function #'ggtags-make-bookmark-record) + (setq-local ggtags-navigation-mode nil) (add-hook 'kill-buffer-hook (lambda () (ggtags-navigation-mode -1)) nil t)) ;; NOTE: Need this to avoid putting menu items in
[elpa] 05/14: Fix #42: Clear ggtags-project-root in non-file buffers
leoliu pushed a commit to branch master in repository elpa. commit a0d7e04fc7f63e1c0eb14b819d804f941d6b6b2f Author: Leo Liu sdl@gmail.com Date: Thu Mar 27 17:11:14 2014 +0800 Fix #42: Clear ggtags-project-root in non-file buffers --- ggtags.el | 11 +++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/ggtags.el b/ggtags.el index e31b45f..aeac34a 100644 --- a/ggtags.el +++ b/ggtags.el @@ -392,8 +392,19 @@ Value is new modtime if updated. (defvar-local ggtags-project-root 'unset Internal variable for project root directory.) +(defun ggtags-clear-project-root () + (kill-local-variable 'ggtags-project-root)) + ;;;###autoload (defun ggtags-find-project () + ;; See https://github.com/leoliu/ggtags/issues/42 + ;; + ;; It is unsafe to cache `ggtags-project-root' in non-file buffers. + ;; But we keep the cache for at this a command's duration so that + ;; multiple calls of `ggtags-find-project' has no performance + ;; impact. + (unless buffer-file-name +(add-hook 'pre-command-hook #'ggtags-clear-project-root nil t)) (let ((project (gethash ggtags-project-root ggtags-projects))) (if (ggtags-project-p project) (if (ggtags-project-expired-p project)
[elpa] 06/14: New user variable ggtags-global-use-color
leoliu pushed a commit to branch master in repository elpa. commit aed41594a91342d104c82b924aa52eff9b24ff83 Author: Leo Liu sdl@gmail.com Date: Fri Mar 28 09:52:53 2014 +0800 New user variable ggtags-global-use-color --- ggtags.el | 24 +++- 1 files changed, 15 insertions(+), 9 deletions(-) diff --git a/ggtags.el b/ggtags.el index aeac34a..6b373e9 100644 --- a/ggtags.el +++ b/ggtags.el @@ -179,6 +179,12 @@ If an integer abbreviate only names longer than that number. (const cscope)) :group 'ggtags) +(defcustom ggtags-global-use-color t + Non-nil to use color in output if supported by Global. + :type 'boolean + :safe 'booleanp + :group 'ggtags) + (defcustom ggtags-global-ignore-case nil Non-nil if Global should ignore case in the search pattern. :safe 'booleanp @@ -259,6 +265,10 @@ properly update `ggtags-mode-map'. :type 'function :group 'ggtags) +;; Used by ggtags-global-mode +(defvar ggtags-global-error match + Stem of message to print when no matches are found.) + (defconst ggtags-bug-url https://github.com/leoliu/ggtags/issues;) (defvar ggtags-global-last-buffer nil) @@ -269,10 +279,6 @@ properly update `ggtags-mode-map'. (defvar ggtags-highlight-tag-timer nil) -;; Used by ggtags-global-mode -(defvar ggtags-global-error match - Stem of message to print when no matches are found.) - (defmacro ggtags-ensure-global-buffer (rest body) (declare (indent 0)) `(progn @@ -400,9 +406,8 @@ Value is new modtime if updated. ;; See https://github.com/leoliu/ggtags/issues/42 ;; ;; It is unsafe to cache `ggtags-project-root' in non-file buffers. - ;; But we keep the cache for at this a command's duration so that - ;; multiple calls of `ggtags-find-project' has no performance - ;; impact. + ;; But we keep the cache for a command's duration so that multiple + ;; calls of `ggtags-find-project' has no performance impact. (unless buffer-file-name (add-hook 'pre-command-hook #'ggtags-clear-project-root nil t)) (let ((project (gethash ggtags-project-root ggtags-projects))) @@ -654,7 +659,8 @@ Do nothing if GTAGS exceeds the oversize limit unless FORCE. -v (format --result=%s ggtags-global-output-format) (and ggtags-global-ignore-case --ignore-case) - (and (ggtags-find-project) + (and ggtags-global-use-color + (ggtags-find-project) (ggtags-project-has-color (ggtags-find-project)) --color=always) (and (ggtags-find-project) @@ -1013,7 +1019,7 @@ Use \\[jump-to-register] to restore the search session. (list (read-file-name Browse file: nil nil t) (read-number Line: 1)) (list buffer-file-name (line-number-at-pos - (cl-check-type line integer) + (cl-check-type line (integer 1)) (or (and file (file-exists-p file)) (error File `%s' doesn't exist file)) (ggtags-check-project) (or (file-exists-p (expand-file-name HTML (ggtags-current-project-root)))
[elpa] 04/18: Add NEWS to README.rst for 0.8.0 and 0.8.1
leoliu pushed a commit to branch master in repository elpa. commit ba07f9fb04a1d9f3403f04eb2317a8efb9426218 Author: Leo Liu sdl@gmail.com Date: Tue Apr 1 10:26:41 2014 +0800 Add NEWS to README.rst for 0.8.0 and 0.8.1 --- README.rst | 33 + 1 files changed, 33 insertions(+), 0 deletions(-) diff --git a/README.rst b/README.rst index 5517daf..7014150 100644 --- a/README.rst +++ b/README.rst @@ -261,6 +261,39 @@ Integration with other packages (setq-local hippie-expand-try-functions-list (cons 'ggtags-try-complete-tag hippie-expand-try-functions-list)) +NEWS + + +[2014-03-30 Sun] 0.8.1 +++ + +#. Improve ``ggtags-view-tag-history`` and tag history navigation. +#. New customsable variable ``ggtags-global-use-color``. +#. Automatically jump to match from location stored in search history. + See ``ggtags-auto-jump-to-match``. +#. Rename ``ggtags-supress-navigation-keys`` to + ``ggtags-enable-navigation-keys`` with a better way to suppress + navigation key bindings in some buffers including + ``*ggtags-global*`` buffer. + +[2014-03-24 Mon] 0.8.0 +++ + +#. Record search history and re-run past searches. +#. Bookmark or save search to register. +#. New command ``ggtags-show-definition``. +#. Project name on mode line. +#. Automatically use ``.globalrc`` or ``gtags.conf`` file at project + root. +#. Better completion based on tag types. +#. Use colored output to get column number for jumping to tag. +#. Improve detection of stale GTAGS file based on file modification + time. +#. New customisable variables ``ggtags-executable-directory``, + ``ggtags-global-always-update``, ``ggtags-mode-sticky`` and + ``ggtags-supress-navigation-keys``. +#. Other bug fixes. + Bugs
[elpa] 10/18: Make ggtags-eldoc-function work better when no project root
leoliu pushed a commit to branch master in repository elpa. commit 8f3bd01d82f916b03227f1bbe3683be39b62280f Author: Leo Liu sdl@gmail.com Date: Thu Apr 3 08:24:50 2014 +0800 Make ggtags-eldoc-function work better when no project root Make M-. on #include line also triggers indexing project if not already. --- ggtags.el | 18 +++--- 1 files changed, 11 insertions(+), 7 deletions(-) diff --git a/ggtags.el b/ggtags.el index 8c97c49..fb9627d 100644 --- a/ggtags.el +++ b/ggtags.el @@ -778,6 +778,7 @@ When called interactively with a prefix arg, always find definition tags. (interactive (let ((include (and (not current-prefix-arg) (ggtags-include-file + (ggtags-ensure-project) (if include (list include 'include) (list (ggtags-read-tag 'definition current-prefix-arg) (and current-prefix-arg 'definition) @@ -1920,13 +1921,16 @@ to nil disables displaying this information.) (`nil nil) (tag (if (equal tag (car ggtags-eldoc-cache)) (cadr ggtags-eldoc-cache) - (setq ggtags-eldoc-cache (list tag)) ;don't come back until done - (let* ((ggtags-print-definition-function - (lambda (s) - (setq ggtags-eldoc-cache (list tag s)) - (eldoc-message s - (ggtags-show-definition tag) - nil) + (and ggtags-project-root (ggtags-find-project) +(let* ((ggtags-print-definition-function +(lambda (s) + (setq ggtags-eldoc-cache (list tag s)) + (eldoc-message s + ;; Prevent multiple runs of ggtags-show-definition + ;; for the same tag. + (setq ggtags-eldoc-cache (list tag)) + (ggtags-show-definition tag) + nil)) ;;; imenu
[elpa] 11/18: Revert Fix ggtags-with-current-project to include GTAGSCONF
leoliu pushed a commit to branch master in repository elpa. commit c16d7b2c30b5d1f57239966c98dcc1f70a4237d5 Author: Leo Liu sdl@gmail.com Date: Thu Apr 3 10:12:17 2014 +0800 Revert Fix ggtags-with-current-project to include GTAGSCONF This reverts commit e7c5371028912e07c37de2bf1c80c88bf51a1fea. --- ggtags.el | 13 ++--- 1 files changed, 2 insertions(+), 11 deletions(-) diff --git a/ggtags.el b/ggtags.el index fb9627d..e36fbb6 100644 --- a/ggtags.el +++ b/ggtags.el @@ -359,15 +359,13 @@ properly update `ggtags-mode-map'. (:copier nil) (:type vector) :named) - root config tag-size has-refs has-path-style has-color dirty-p mtime timestamp) + root tag-size has-refs has-path-style has-color dirty-p mtime timestamp) (defun ggtags-make-project (root) (cl-check-type root string) (pcase (nthcdr 5 (file-attributes (expand-file-name GTAGS root))) (`(,mtime ,_ ,tag-size . ,_) (let* ((default-directory (file-name-as-directory root)) -(config (cl-some (lambda (c) (and (file-exists-p c) c)) - '(.globalrc gtags.conf))) (rtags-size (nth 7 (file-attributes GRTAGS))) (has-refs (when rtags-size @@ -391,7 +389,6 @@ properly update `ggtags-mode-map'. 'has-color (puthash default-directory (ggtags-project--make :root default-directory - :config config :tag-size tag-size :has-refs has-refs :has-path-style has-path-style @@ -562,13 +559,7 @@ Value is new modtime if updated. (and ,gtagsroot (list (concat GTAGSROOT= ,gtagsroot))) (and (ggtags-find-project) (not (ggtags-project-has-refs (ggtags-find-project))) - (list GTAGSLABEL=ctags)) - (and ggtags-use-project-gtagsconf ,gtagsroot - (ggtags-project-config (ggtags-find-project)) - (list (concat GTAGSCONF= -(expand-file-name (ggtags-project-config - (ggtags-find-project)) - ,gtagsroot))) + (list GTAGSLABEL=ctags) (unwind-protect (save-current-buffer ,@body) (setq ggtags-project-root ,root)
[elpa] 08/18: Don't activate eldoc support by default
leoliu pushed a commit to branch master in repository elpa. commit f97d58ece0f99b39656b75fefa59921d342460a2 Author: Leo Liu sdl@gmail.com Date: Wed Apr 2 09:02:28 2014 +0800 Don't activate eldoc support by default since it is difficult to enable it without overriding users' settings for emacs = 24.3. --- README.rst | 10 +- ggtags.el | 20 +--- 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/README.rst b/README.rst index 9ea1f97..2e25678 100644 --- a/README.rst +++ b/README.rst @@ -249,13 +249,13 @@ Integration with other packages * eldoc - If ``eldoc-mode`` is enabled it can use ``ggtags`` to show - definition. An example configuration: - - :: + ``Eldoc`` support can be enabled by, for example, setting this in + the desired major mode with: - (add-hook 'ggtags-mode-hook 'eldoc-mode) + :: + (setq-local eldoc-documentation-function #'ggtags-eldoc-function) + * imenu Emacs major modes usually have excellent support for ``imenu`` so diff --git a/ggtags.el b/ggtags.el index dfe7a6e..39f0ff6 100644 --- a/ggtags.el +++ b/ggtags.el @@ -48,15 +48,6 @@ (require 'tabulated-list) ;preloaded since 24.3 (eval-when-compile - (unless (fboundp 'add-function) ;24.4 -(defmacro add-function (_where place function) - `(progn - (make-local-variable ,(cadr place)) - (set ,(cadr place) ,function - (unless (fboundp 'remove-function);24.4 -(defmacro remove-function (place _function) - `(kill-local-variable ,(cadr place - (unless (fboundp 'setq-local) (defmacro setq-local (var val) (list 'set (list 'make-local-variable (list 'quote var)) val))) @@ -1853,21 +1844,11 @@ to nil disables displaying this information.) ;; Append to serve as a fallback method. (add-hook 'completion-at-point-functions #'ggtags-completion-at-point t t) -;; `eldoc-documentation-function-default' is only good for -;; `emacs-lisp-mode'. -(when (and (eq eldoc-documentation-function - 'eldoc-documentation-function-default) - (not (derived-mode-p 'emacs-lisp-mode))) - (setq-local eldoc-documentation-function #'ignore)) -(add-function :after-until (local 'eldoc-documentation-function) - #'ggtags-eldoc-function) (unless (memq 'ggtags-mode-line-project-name mode-line-buffer-identification) (setq mode-line-buffer-identification (append mode-line-buffer-identification '(ggtags-mode-line-project-name) -(remove-function (local 'eldoc-documentation-function) - #'ggtags-eldoc-function) (remove-hook 'after-save-hook 'ggtags-after-save-function t) (remove-hook 'completion-at-point-functions #'ggtags-completion-at-point t) (setq mode-line-buffer-identification @@ -1928,6 +1909,7 @@ to nil disables displaying this information.) (declare-function eldoc-message eldoc) (defun ggtags-eldoc-function () + A function suitable for `eldoc-documentation-function' (which see). (pcase (cons (ggtags-tag-at-point) ggtags-eldoc-cache) (`(nil . ,_) nil) (`(,_x ,_x) nil)
[elpa] 06/18: Fix error in approximation to (line-number-at-pos (point-max))
leoliu pushed a commit to branch master in repository elpa. commit 9527576d414771001f90c7a37219d8cb4d7c7a43 Author: Leo Liu sdl@gmail.com Date: Wed Apr 2 08:41:12 2014 +0800 Fix error in approximation to (line-number-at-pos (point-max)) ggtags-global-output-lines = (line-number-at-pos (point-max)) is not always true. --- ggtags.el | 12 1 files changed, 4 insertions(+), 8 deletions(-) diff --git a/ggtags.el b/ggtags.el index 4ded7ba..4acf610 100644 --- a/ggtags.el +++ b/ggtags.el @@ -1317,10 +1317,7 @@ commands `next-error' and `previous-error'. compilation-filter-start t) (replace-match )) (cl-incf ggtags-global-output-lines - (count-lines (if (zerop ggtags-global-output-lines) -(point-min) - compilation-filter-start) -(point))) + (count-lines compilation-filter-start (point))) ;; If the number of output lines is small ;; `ggtags-global-handle-exit' takes care of displaying the buffer. (when (and ( ggtags-global-output-lines 30) ggtags-navigation-mode) @@ -1328,10 +1325,9 @@ commands `next-error' and `previous-error'. (when (and (eq ggtags-auto-jump-to-match 'history) (numberp ggtags-auto-jump-to-match-target) (not compilation-current-error) - ;; `ggtags-global-output-lines' is imprecise but is - ;; greater than (line-number-at-pos (point-max)) so use - ;; it as first approximation. - ( ggtags-global-output-lines ggtags-auto-jump-to-match-target) + ;; `ggtags-global-output-lines' is imprecise but use it + ;; as first approximation. + ( (+ 10 ggtags-global-output-lines) ggtags-auto-jump-to-match-target) ( (line-number-at-pos (point-max)) ggtags-auto-jump-to-match-target)) (ggtags-forward-to-line ggtags-auto-jump-to-match-target)
[elpa] 09/18: Fix multiple calls of ggtags-show-definition
leoliu pushed a commit to branch master in repository elpa. commit c091f9971116f53c104c2b251d421e114b471c2d Author: Leo Liu sdl@gmail.com Date: Wed Apr 2 11:10:10 2014 +0800 Fix multiple calls of ggtags-show-definition and misuse of pcase equality in ggtags-eldoc-function. Fix ggtags-global-output to notice the problem of running multiple processes. --- ggtags.el | 28 +--- 1 files changed, 17 insertions(+), 11 deletions(-) diff --git a/ggtags.el b/ggtags.el index 39f0ff6..8c97c49 100644 --- a/ggtags.el +++ b/ggtags.el @@ -1647,6 +1647,12 @@ commands `next-error' and `previous-error'. Asynchronously pipe the output of running CMDS to BUFFER. When finished invoke CALLBACK in BUFFER with process exit status. (or buffer (error Output buffer required)) + (when (get-buffer-process (get-buffer buffer)) +;; Notice running multiple processes in the same buffer so that we +;; can fix the caller. See for example `ggtags-eldoc-function'. +(message Warning: detected %S already running in %S; interrupting... + (get-buffer-process buffer) buffer) +(interrupt-process (get-buffer-process buffer))) (let* ((program (car cmds)) (args (cdr cmds)) (cutoff (and cutoff (+ cutoff (if (get-buffer buffer) @@ -1910,17 +1916,17 @@ to nil disables displaying this information.) (declare-function eldoc-message eldoc) (defun ggtags-eldoc-function () A function suitable for `eldoc-documentation-function' (which see). - (pcase (cons (ggtags-tag-at-point) ggtags-eldoc-cache) -(`(nil . ,_) nil) -(`(,_x ,_x) nil) -(`(,_x ,_x ,def) def) -(`(,tag . ,_) - (let* ((ggtags-print-definition-function - (lambda (s) - (setq ggtags-eldoc-cache (list tag s)) - (eldoc-message s - (ggtags-show-definition tag) - nil + (pcase (ggtags-tag-at-point) +(`nil nil) +(tag (if (equal tag (car ggtags-eldoc-cache)) + (cadr ggtags-eldoc-cache) + (setq ggtags-eldoc-cache (list tag)) ;don't come back until done + (let* ((ggtags-print-definition-function + (lambda (s) + (setq ggtags-eldoc-cache (list tag s)) + (eldoc-message s + (ggtags-show-definition tag) + nil) ;;; imenu
[elpa] 02/18: New function ggtags-echo and use it
leoliu pushed a commit to branch master in repository elpa. commit 02823de20f18b8824d4876808290afc580d2a92b Author: Leo Liu sdl@gmail.com Date: Tue Apr 1 07:35:16 2014 +0800 New function ggtags-echo and use it --- ggtags.el | 33 + 1 files changed, 17 insertions(+), 16 deletions(-) diff --git a/ggtags.el b/ggtags.el index 6f56829..d00cc08 100644 --- a/ggtags.el +++ b/ggtags.el @@ -3,7 +3,7 @@ ;; Copyright (C) 2013-2014 Free Software Foundation, Inc. ;; Author: Leo Liu sdl@gmail.com -;; Version: 0.8.1 +;; Version: 0.8.2 ;; Keywords: tools, convenience ;; Created: 2013-01-29 ;; URL: https://github.com/leoliu/ggtags @@ -309,6 +309,10 @@ properly update `ggtags-mode-map'. Return non-nil if XS is a list of strings. (cl-every #'stringp xs)) +(defsubst ggtags-echo (format-string rest args) + Print formatted text to echo area. + (let (message-log-max) (apply #'message format-string args))) + (defun ggtags-forward-to-line (line) Move to line number LINE in current buffer. (cl-check-type line (integer 1)) @@ -1062,15 +1066,14 @@ Use \\[jump-to-register] to restore the search session. 0)) (ring-length find-tag-marker-ring))) (let ((m (ring-ref find-tag-marker-ring ggtags-tag-ring-index)) -(i (- (ring-length find-tag-marker-ring) ggtags-tag-ring-index)) -(message-log-max nil)) -(message %d%s marker%s i (pcase (mod i 10) - ;; ` required for 24.1 and 24.2 - (`1 st) - (`2 nd) - (`3 rd) - (_ th)) - (if (marker-buffer m) (dead))) +(i (- (ring-length find-tag-marker-ring) ggtags-tag-ring-index))) +(ggtags-echo %d%s marker%s i (pcase (mod i 10) + ;; ` required for 24.1 and 24.2 + (`1 st) + (`2 nd) + (`3 rd) + (_ th)) + (if (marker-buffer m) (dead))) (if (not (marker-buffer m)) (ding) (switch-to-buffer (marker-buffer m)) @@ -1323,9 +1326,8 @@ commands `next-error' and `previous-error'. (make-local-variable 'ggtags-global-large-output) (when ( ggtags-global-output-lines ggtags-global-large-output) (cl-incf ggtags-global-large-output 500) -(let ((message-log-max nil)) - (message Output %d lines (Type `C-c C-k' to cancel) - ggtags-global-output-lines +(ggtags-echo Output %d lines (Type `C-c C-k' to cancel) + ggtags-global-output-lines))) (defun ggtags-global-handle-exit (buf how) A function for `compilation-finish-functions' (which see). @@ -1655,9 +1657,8 @@ When finished invoke CALLBACK in BUFFER with process exit status. proc)) (defun ggtags-show-definition-default (defs) - (let (message-log-max) -(message %s%s (or (caar defs) [definition not found]) - (if (cdr defs) [guess] + (ggtags-echo %s%s (or (caar defs) [definition not found]) + (if (cdr defs) [guess] ))) (defun ggtags-show-definition (name) (interactive (list (ggtags-read-tag 'definition current-prefix-arg)))
[elpa] 15/18: Revert Don't reply on excution order of filter and sentinel functions
leoliu pushed a commit to branch master in repository elpa. commit 7a6cc7f8065e33fe95bc6600099a761f494852c6 Author: Leo Liu sdl@gmail.com Date: Fri Apr 4 11:58:23 2014 +0800 Revert Don't reply on excution order of filter and sentinel functions This reverts commit 03345fb9a25bc2cf09bebc2b96bd867d1c979cc2. The commit appears to fix the bug because the idle timer does not run in the *ggtags-global* buffer. --- ggtags.el | 21 ++--- 1 files changed, 6 insertions(+), 15 deletions(-) diff --git a/ggtags.el b/ggtags.el index 2710e5e..1bf994a 100644 --- a/ggtags.el +++ b/ggtags.el @@ -748,7 +748,7 @@ Do nothing if GTAGS exceeds the oversize limit unless FORCE. (ggtags-update-tags) (ggtags-with-current-project (with-current-buffer (with-display-buffer-no-window -(compilation-start command 'ggtags-global-mode)) + (compilation-start command 'ggtags-global-mode)) (setq-local ggtags-process-environment env) (setq ggtags-global-last-buffer (current-buffer)) @@ -1313,12 +1313,6 @@ commands `next-error' and `previous-error'. (compilation-set-window-height w) (and desired-point (goto-char desired-point)) -(defun ggtags-auto-jump-to-match-target () - (when (functionp ggtags-auto-jump-to-match-target) -(funcall (prog1 ggtags-auto-jump-to-match-target - (setq-local ggtags-auto-jump-to-match-target nil))) -t)) - (defun ggtags-global-filter () Called from `compilation-filter-hook' (which see). (let ((ansi-color-apply-face-function @@ -1348,17 +1342,15 @@ commands `next-error' and `previous-error'. ( (line-number-at-pos (point-max)) ggtags-auto-jump-to-match-target)) (ggtags-forward-to-line ggtags-auto-jump-to-match-target) +(setq-local ggtags-auto-jump-to-match-target nil) +;; ;; Can't call `compile-goto-error' here becuase ;; `compilation-filter' restores point and as a result commands ;; dependent on point such as `ggtags-navigation-next-file' and ;; `ggtags-navigation-previous-file' fail to work. -(setq-local ggtags-auto-jump-to-match-target -(apply-partially - (lambda (buf pt) - (let ((compilation-auto-jump-to-first-error t)) - (with-display-buffer-no-window (compilation-auto-jump buf pt - (current-buffer) (point))) -(run-with-idle-timer 0 nil #'ggtags-auto-jump-to-match-target)) +(with-display-buffer-no-window + (with-demoted-errors (compile-goto-error))) +(run-with-idle-timer 0 nil #'compilation-auto-jump (current-buffer) (point))) (make-local-variable 'ggtags-global-large-output) (when ( ggtags-global-output-lines ggtags-global-large-output) (cl-incf ggtags-global-large-output 500) @@ -1372,7 +1364,6 @@ commands `next-error' and `previous-error'. ;; If exit abnormally display the buffer for inspection. (ggtags-global--display-buffer)) (ggtags-auto-jump-to-match -(ggtags-auto-jump-to-match-target) (if (pcase (compilation-next-single-property-change (point-min) 'compilation-message) ((and pt (guard pt))
[elpa] 13/18: New macro ggtags-with-temp-message that reports execution time
leoliu pushed a commit to branch master in repository elpa. commit bd619aea1d5495a77715d5a14ce40e33c43a59a2 Author: Leo Liu sdl@gmail.com Date: Thu Apr 3 10:33:01 2014 +0800 New macro ggtags-with-temp-message that reports execution time --- ggtags.el | 17 ++--- 1 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ggtags.el b/ggtags.el index 70786a0..1bf994a 100644 --- a/ggtags.el +++ b/ggtags.el @@ -305,6 +305,17 @@ properly update `ggtags-mode-map'. (defvar ggtags-highlight-tag-timer nil) +(defmacro ggtags-with-temp-message (message rest body) + (declare (debug t) (indent 1)) + (let ((init-time (make-symbol -init-time-)) +(tmp-msg (make-symbol -tmp-msg-))) +`(let ((,init-time (float-time)) + (,tmp-msg ,message)) + (with-temp-message ,tmp-msg + (prog1 (progn ,@body) + (message %sdone (%.2fs) ,(or tmp-msg ) +(- (float-time) ,init-time))) + (defmacro ggtags-ensure-global-buffer (rest body) (declare (indent 0)) `(progn @@ -594,7 +605,7 @@ source trees. See Info node `(global)gtags' for details. (unless (or conf (getenv GTAGSLABEL) (not (yes-or-no-p Use `ctags' backend? ))) (setenv GTAGSLABEL ctags)) - (with-temp-message `gtags' in progress... + (ggtags-with-temp-message `gtags' in progress... (let ((default-directory (file-name-as-directory root)) (args (cl-remove-if ;; Place --idutils first @@ -625,7 +636,7 @@ Do nothing if GTAGS exceeds the oversize limit unless FORCE. (not (ggtags-project-oversize-p)) (ggtags-project-dirty-p (ggtags-find-project (ggtags-with-current-project - (with-temp-message `global -u' in progress... + (ggtags-with-temp-message `global -u' in progress... (ggtags-process-string global -u) (setf (ggtags-project-dirty-p (ggtags-find-project)) nil) (setf (ggtags-project-mtime (ggtags-find-project)) (float-time)) @@ -875,7 +886,7 @@ Global and Emacs. (let ((file-form '(let ((files)) (ggtags-ensure-global-buffer - (with-temp-message Waiting for Grep to finish... + (ggtags-with-temp-message Waiting for Grep to finish... (while (get-buffer-process (current-buffer)) (sit-for 0.2))) (goto-char (point-min))
[elpa] 01/18: For #45: Fix popping up/down window for search with single match
leoliu pushed a commit to branch master in repository elpa. commit 65aba1399e51e69185b1a8bbf75821a5a7764655 Author: Leo Liu sdl@gmail.com Date: Mon Mar 31 17:56:53 2014 +0800 For #45: Fix popping up/down window for search with single match - New with-display-buffer-no-window and use it. - Improve calculation of ggtags-global-output-lines and use it to avoid (line-number-at-pos (point-max)) all the time. - Make ggtags-global-handle-exit display buffer for multiple matches. --- ggtags.el | 66 +--- 1 files changed, 41 insertions(+), 25 deletions(-) diff --git a/ggtags.el b/ggtags.el index faf4d06..6f56829 100644 --- a/ggtags.el +++ b/ggtags.el @@ -61,7 +61,18 @@ (defmacro ignore-errors-unless-debug (rest body) Ignore all errors while executing BODY unless debug is on. (declare (debug t) (indent 0)) -`(condition-case-unless-debug nil (progn ,@body) (error nil +`(condition-case-unless-debug nil (progn ,@body) (error nil))) + + (defmacro with-display-buffer-no-window (rest body) +(declare (debug t) (indent 0)) +;; See http://debbugs.gnu.org/13594 +`(let ((display-buffer-overriding-action +(if (and ggtags-auto-jump-to-match + ;; Appeared in emacs 24.4. + (fboundp 'display-buffer-no-window)) +(list #'display-buffer-no-window) + display-buffer-overriding-action))) + ,@body))) (eval-and-compile (or (fboundp 'user-error) ;24.3 @@ -702,13 +713,6 @@ Do nothing if GTAGS exceeds the oversize limit unless FORCE. (defun ggtags-global-start (command optional directory) (let* ((default-directory (or directory (ggtags-current-project-root))) (split-window-preferred-function ggtags-split-window-function) - ;; See http://debbugs.gnu.org/13594 - (display-buffer-overriding-action - (if (and ggtags-auto-jump-to-match - ;; Appeared in emacs 24.4. - (fboundp 'display-buffer-no-window)) - (list #'display-buffer-no-window) -display-buffer-overriding-action)) (env ggtags-process-environment)) (setq ggtags-global-start-marker (point-marker)) (setq ggtags-auto-jump-to-match-target @@ -719,7 +723,8 @@ Do nothing if GTAGS exceeds the oversize limit unless FORCE. ggtags-global-match-count 0) (ggtags-update-tags) (ggtags-with-current-project - (with-current-buffer (compilation-start command 'ggtags-global-mode) + (with-current-buffer (with-display-buffer-no-window + (compilation-start command 'ggtags-global-mode)) (setq-local ggtags-process-environment env) (setq ggtags-global-last-buffer (current-buffer)) @@ -1289,12 +1294,20 @@ commands `next-error' and `previous-error'. compilation-filter-start t) (replace-match )) (cl-incf ggtags-global-output-lines - (count-lines compilation-filter-start (point))) - (when (and ( ggtags-global-output-lines 5) ggtags-navigation-mode) + (count-lines (if (zerop ggtags-global-output-lines) +(point-min) + compilation-filter-start) +(point))) + ;; If the number of output lines is small + ;; `ggtags-global-handle-exit' takes care of displaying the buffer. + (when (and ( ggtags-global-output-lines 20) ggtags-navigation-mode) (ggtags-global--display-buffer)) (when (and (eq ggtags-auto-jump-to-match 'history) (numberp ggtags-auto-jump-to-match-target) - ;; `ggtags-global-output-lines' is imprecise. + ;; `ggtags-global-output-lines' is imprecise but is + ;; greater than (line-number-at-pos (point-max)) so use + ;; it as first approximation. + ( ggtags-global-output-lines ggtags-auto-jump-to-match-target) ( (line-number-at-pos (point-max)) ggtags-auto-jump-to-match-target)) (ggtags-forward-to-line ggtags-auto-jump-to-match-target) @@ -1304,7 +1317,8 @@ commands `next-error' and `previous-error'. ;; `compilation-filter' restores point and as a result commands ;; dependent on point such as `ggtags-navigation-next-file' and ;; `ggtags-navigation-previous-file' fail to work. -(setq-local compilation-auto-jump-to-first-error t) +(with-display-buffer-no-window + (with-demoted-errors (compile-goto-error))) (run-with-idle-timer 0 nil #'compilation-auto-jump (current-buffer) (point))) (make-local-variable 'ggtags-global-large-output) (when ( ggtags-global-output-lines ggtags-global-large-output) @@ -1319,18 +1333,20 @@ commands `next-error' and `previous-error'. ((string-prefix-p exited abnormally how) ;; If exit abnormally display the buffer for inspection. (ggtags-global--display-buffer
[elpa] 12/18: Make ggtags-use-project-gtagsconf work on remote projects
leoliu pushed a commit to branch master in repository elpa. commit 6ffc5421828984ef9b56500741779baa5bb7dbf1 Author: Leo Liu sdl@gmail.com Date: Thu Apr 3 10:17:42 2014 +0800 Make ggtags-use-project-gtagsconf work on remote projects by using --gtagsconf instead of setenv'ing GTAGSCONF which does not work on remote projects via tramp. --- ggtags.el | 45 +++-- 1 files changed, 27 insertions(+), 18 deletions(-) diff --git a/ggtags.el b/ggtags.el index e36fbb6..70786a0 100644 --- a/ggtags.el +++ b/ggtags.el @@ -318,6 +318,9 @@ properly update `ggtags-mode-map'. Return non-nil if XS is a list of strings. (cl-every #'stringp xs)) +(defun ggtags-ensure-localname (file) + (and file (or (file-remote-p file 'localname) file))) + (defun ggtags-echo (format-string rest args) Print formatted text to echo area. (let (message-log-max) (apply #'message format-string args))) @@ -550,7 +553,8 @@ Value is new modtime if updated. (root (make-symbol -ggtags-project-root-))) `(let* ((,root ggtags-project-root) (,gtagsroot (when (ggtags-find-project) - (directory-file-name (ggtags-current-project-root + (ggtags-ensure-localname + (directory-file-name (ggtags-current-project-root) (process-environment (append (let ((process-environment process-environment)) (and ,gtagsroot (setenv GTAGSROOT ,gtagsroot)) @@ -579,28 +583,33 @@ source trees. See Info node `(global)gtags' for details. (interactive DRoot directory: ) (let ((process-environment process-environment)) (when (zerop (length root)) (error No root directory provided)) -(setenv GTAGSROOT (expand-file-name - (directory-file-name (file-name-as-directory root +(setenv GTAGSROOT (ggtags-ensure-localname + (expand-file-name + (directory-file-name (file-name-as-directory root) (ggtags-with-current-project (let ((conf (and ggtags-use-project-gtagsconf (cl-loop for name in '(.globalrc gtags.conf) for full = (expand-file-name name root) thereis (and (file-exists-p full) full) - (cond (conf (setenv GTAGSCONF conf)) - ((and (not (getenv GTAGSLABEL)) - (yes-or-no-p Use `ctags' backend? )) - (setenv GTAGSLABEL ctags - (with-temp-message `gtags' in progress... - (let ((default-directory (file-name-as-directory root))) - (condition-case err - (apply #'ggtags-process-string -gtags (and ggtags-use-idutils '(--idutils))) - (error (if (and ggtags-use-idutils - (stringp (cadr err)) - (string-match-p mkid not found (cadr err))) - ;; Retry without mkid - (ggtags-process-string gtags) -(signal (car err) (cdr err + (unless (or conf (getenv GTAGSLABEL) + (not (yes-or-no-p Use `ctags' backend? ))) + (setenv GTAGSLABEL ctags)) + (with-temp-message `gtags' in progress... + (let ((default-directory (file-name-as-directory root)) + (args (cl-remove-if + ;; Place --idutils first + #'null (list (and ggtags-use-idutils --idutils) + (and conf --gtagsconf) + (and conf (ggtags-ensure-localname conf)) + (condition-case err + (apply #'ggtags-process-string gtags args) + (error (if (and ggtags-use-idutils + (stringp (cadr err)) + (string-match-p mkid not found (cadr err))) +;; Retry without mkid +(apply #'ggtags-process-string + gtags (cl-remove --idutils args)) + (signal (car err) (cdr err) (message GTAGS generated in `%s' root) root))
[elpa] 42/77: Must reference the actual object in easy-kill-candidate
leoliu pushed a commit to branch master in repository elpa. commit d10686871536575a6dbb78288309aed2da83d050 Author: Leo Liu sdl@gmail.com Date: Sat Oct 12 12:00:53 2013 +0800 Must reference the actual object in easy-kill-candidate because this-command may set easy-kill-candidate to something else. --- easy-kill.el | 14 +++--- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/easy-kill.el b/easy-kill.el index fcfae02..286d138 100644 --- a/easy-kill.el +++ b/easy-kill.el @@ -167,13 +167,13 @@ candidate property instead. (defun easy-kill-destroy-candidate () (let ((hook (make-symbol easy-kill-destroy-candidate))) -(fset hook (lambda () - (when easy-kill-candidate - (let ((i (overlay-get easy-kill-candidate 'origin-indicator))) - (and (overlayp i) (delete-overlay i))) - (delete-overlay easy-kill-candidate)) - (setq easy-kill-candidate nil) - (remove-hook 'post-command-hook hook))) +(fset hook `(lambda () + (let ((o ,easy-kill-candidate)) +(when o + (let ((i (overlay-get o 'origin-indicator))) +(and (overlayp i) (delete-overlay i))) + (delete-overlay o))) + (remove-hook 'post-command-hook ',hook))) (add-hook 'post-command-hook hook))) (defun easy-kill-expand ()
[elpa] 30/77: Merge pull request #6 from knu/usage-remap
leoliu pushed a commit to branch master in repository elpa. commit 34d8ce5b7974b07c83433ebb9910b5d45271832b Merge: b1ceb8a 7ebe4de Author: Leo Liu sdl@gmail.com Date: Wed Oct 9 09:14:12 2013 -0700 Merge pull request #6 from knu/usage-remap [remap kill-ring-save] should be a better key binding for this feature. README.rst |2 +- easy-kill.el |2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
[elpa] 59/77: Doc fix
leoliu pushed a commit to branch master in repository elpa. commit 51f455bbe718a47a8e734ffd8d114c0a24154858 Author: Leo Liu sdl@gmail.com Date: Tue Oct 22 12:46:23 2013 +0800 Doc fix --- README.rst |6 -- easy-kill.el |2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index b9614a0..c8bc9c7 100644 --- a/README.rst +++ b/README.rst @@ -32,8 +32,10 @@ active: #. ``SPC`` - turn selection into an active region #. ``C-g`` - abort -Any other keys exit the temporary keymap. See ``M-w l`` in action in -`screenshot http://i.imgur.com/8TNgPly.png`_: +Any other keys exit the temporary keymap and automatically save +selection to the ``kill-ring``. See ``M-w l`` (save list at point to +the kill ring) in action in `screenshot +http://i.imgur.com/8TNgPly.png`_: .. figure:: http://i.imgur.com/8TNgPly.png :target: http://i.imgur.com/8TNgPly.png diff --git a/easy-kill.el b/easy-kill.el index 1d10ea9..a4684d4 100644 --- a/easy-kill.el +++ b/easy-kill.el @@ -228,6 +228,8 @@ candidate property instead. (and (overlayp i) (delete-overlay i))) (delete-overlay o))) (remove-hook 'post-command-hook ',hook))) +;; Run in `post-command-hook' so that exit commands can still use +;; `easy-kill-candidate'. (add-hook 'post-command-hook hook))) (defun easy-kill-expand ()
[elpa] 43/77: Add new command easy-mark-sexp
leoliu pushed a commit to branch master in repository elpa. commit 44cb970ee71ec8852dd1c178b5d43d516ebbba29 Author: Leo Liu sdl@gmail.com Date: Sat Oct 12 12:30:11 2013 +0800 Add new command easy-mark-sexp --- easy-kill.el |9 + 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/easy-kill.el b/easy-kill.el index 286d138..7523844 100644 --- a/easy-kill.el +++ b/easy-kill.el @@ -317,6 +317,15 @@ Temporally activate additional key bindings as follows: (easy-kill-init-candidate n) (easy-kill-activate-keymap)) +;;;###autoload +(defun easy-mark-sexp (optional n) + (interactive p) + (let ((easy-kill-try-things '(sexp))) +(easy-mark n) +(unless (overlay-get easy-kill-candidate 'thing) + (overlay-put easy-kill-candidate 'thing 'sexp) + (easy-kill-thing 'sexp n + ;;; Extended things (defun easy-kill-on-buffer-file-name (n)
[elpa] 46/77: Teach easy-kill-abort to deactivate mark immediately
leoliu pushed a commit to branch master in repository elpa. commit 4e2d3735baa7446a204a4a328df00fa2b831979b Author: Leo Liu sdl@gmail.com Date: Sun Oct 13 17:22:14 2013 +0800 Teach easy-kill-abort to deactivate mark immediately since it works better with `ding'. --- easy-kill.el |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/easy-kill.el b/easy-kill.el index d422e9b..54fbf15 100644 --- a/easy-kill.el +++ b/easy-kill.el @@ -260,7 +260,7 @@ candidate property instead. (interactive) (when easy-kill-mark (goto-char (overlay-get easy-kill-candidate 'origin)) -(setq deactivate-mark t)) +(deactivate-mark)) (ding)) (put 'easy-kill-region 'easy-kill-exit t)
[elpa] 15/77: Some string and comment fixes
leoliu pushed a commit to branch master in repository elpa. commit fc448fd1efed15078c3b406915ae8ca29b76011d Author: Leo Liu sdl@gmail.com Date: Mon Oct 7 19:37:50 2013 +0800 Some string and comment fixes --- easy-kill.el | 21 ++--- 1 files changed, 10 insertions(+), 11 deletions(-) diff --git a/easy-kill.el b/easy-kill.el index 0966b2f..1571ff1 100644 --- a/easy-kill.el +++ b/easy-kill.el @@ -73,7 +73,7 @@ CHAR is used immediately following `easy-kill' to select THING. (cond ((stringp s) (if (string-match [ \t\f\r\n]*\\' s) (substring s 0 (match-beginning 0)) - (error `string-match' failed in `easy-kill-strip'))) + (error `string-match' failed in `easy-kill-strip-trailing'))) (t s))) (defvar easy-kill-exit nil @@ -148,10 +148,10 @@ candidate property instead. (interactive) (let ((beg (overlay-start easy-kill-candidate)) (end (overlay-end easy-kill-candidate))) -(if (/= beg end) -(kill-region beg end) - (easy-kill-message-nolog Region empty))) - (setq easy-kill-exit t)) +(if (= beg end) +(easy-kill-message-nolog Empty region) + (setq easy-kill-exit t) + (kill-region beg end (defun easy-kill-thing (thing optional n inhibit-handler) (interactive @@ -186,7 +186,7 @@ candidate property instead. (when easy-kill-candidate ;; Do not modify the clipboard here because it will ;; intercept pasting from other programs and - ;; `easy-kill-remember' already did the work. + ;; `easy-kill-adjust-candidate' already did the work. (let ((interprogram-cut-function nil) (interprogram-paste-function nil) (candidate (easy-kill-candidate))) @@ -199,14 +199,13 @@ candidate property instead. ;;;###autoload (defun easy-kill (optional n) Kill thing at point in the order of region, url, email and line. -Immediately following this additional key bindings are temporally -activated: +Temporally activate additional key bindings as follows: - letters = select things (according to `easy-kill-alist'); + letters = select or enlarge things according to `easy-kill-alist'; 0..9= enlarge current selection by that number; +,=/- = enlarge or shrink current selection by 1; - C-w = kill current selection - others = save current selection to kill ring and exit + C-w = kill current selection; + others = save current selection to kill ring and exit. (interactive p) (setq easy-kill-candidate (let ((o (make-overlay (point) (point
[elpa] 16/77: Make function easy-kill-candidate always return string
leoliu pushed a commit to branch master in repository elpa. commit 61b2befdd4faf857a8c61d2c076a22d337014e3a Author: Leo Liu sdl@gmail.com Date: Tue Oct 8 10:11:13 2013 +0800 Make function easy-kill-candidate always return string --- easy-kill.el | 16 1 files changed, 8 insertions(+), 8 deletions(-) diff --git a/easy-kill.el b/easy-kill.el index 1571ff1..d259e3c 100644 --- a/easy-kill.el +++ b/easy-kill.el @@ -74,7 +74,7 @@ CHAR is used immediately following `easy-kill' to select THING. (if (string-match [ \t\f\r\n]*\\' s) (substring s 0 (match-beginning 0)) (error `string-match' failed in `easy-kill-strip-trailing'))) -(t s))) +(t ))) (defvar easy-kill-exit nil Tell `set-temporary-overlay-map' to exit if non-nil.) @@ -106,6 +106,7 @@ candidate property instead. (easy-kill-message-nolog %s beg)) (move-overlay o (or beg (overlay-start o)) (or end (overlay-end 0) (and interprogram-cut-function + (not (string= (easy-kill-candidate) )) (funcall interprogram-cut-function (easy-kill-candidate (defun easy-kill-enlarge (n) @@ -145,7 +146,7 @@ candidate property instead. (defun easy-kill-region () Kill current selection and exit. - (interactive) + (interactive *) (let ((beg (overlay-start easy-kill-candidate)) (end (overlay-end easy-kill-candidate))) (if (= beg end) @@ -188,10 +189,9 @@ candidate property instead. ;; intercept pasting from other programs and ;; `easy-kill-adjust-candidate' already did the work. (let ((interprogram-cut-function nil) - (interprogram-paste-function nil) - (candidate (easy-kill-candidate))) - (unless(member candidate '(nil )) - (kill-new candidate))) + (interprogram-paste-function nil)) + (unless (string= (easy-kill-candidate) ) + (kill-new (easy-kill-candidate (delete-overlay easy-kill-candidate) (setq easy-kill-candidate nil) nil))) @@ -217,8 +217,8 @@ Temporally activate additional key bindings as follows: (setq deactivate-mark t) (dolist (thing '(region url email line)) (easy-kill-thing thing n) -(when (overlay-get easy-kill-candidate 'thing) - (return))) +(or (string= (easy-kill-candidate) ) +(return))) (when (zerop (buffer-size)) (easy-kill-message-nolog Warn: `easy-kill' activated in empty buffer)) (easy-kill-activate-keymap))
[elpa] 10/77: New function easy-kill-adjust-candidate and doc fix
leoliu pushed a commit to branch master in repository elpa. commit 605efc9ba8caf9f23770ce3691f32de68ffa6bcc Author: Leo Liu sdl@gmail.com Date: Mon Oct 7 12:29:14 2013 +0800 New function easy-kill-adjust-candidate and doc fix --- easy-kill.el | 84 +- 1 files changed, 42 insertions(+), 42 deletions(-) diff --git a/easy-kill.el b/easy-kill.el index 1b3f94b..64fe96e 100644 --- a/easy-kill.el +++ b/easy-kill.el @@ -66,9 +66,11 @@ (apply 'message format-string args))) (defun easy-kill-strip-trailing (s) - (if (string-match [ \t\f\r\n]*\\' s) - (substring s 0 (match-beginning 0)) -(error `string-match' failed in `easy-kill-strip'))) + (cond ((stringp s) + (if (string-match [ \t\f\r\n]*\\' s) + (substring s 0 (match-beginning 0)) + (error `string-match' failed in `easy-kill-strip'))) +(t s))) (defvar easy-kill-candidate nil) @@ -84,8 +86,18 @@ Otherwise, it is the value of the overlay's candidate property. (overlay-end easy-kill-candidate)) (overlay-get easy-kill-candidate 'candidate -(defun easy-kill-select-text () - Make current kill candidate available to other programs. +(defun easy-kill-adjust-candidate (thing optional beg end) + Adjust kill candidate to THING, BEG, END. +If BEG is a string, shring the overlay to zero length and set its +candidate property instead. + (let ((o easy-kill-candidate)) +(overlay-put o 'thing thing) +(if (stringp beg) +(progn + (move-overlay o (point) (point)) + (overlay-put o 'candidate beg) + (easy-kill-message-nolog %s beg)) + (move-overlay o (or beg (overlay-start o)) (or end (overlay-end 0) (and interprogram-cut-function (funcall interprogram-cut-function (easy-kill-candidate @@ -108,8 +120,7 @@ Otherwise, it is the value of the overlay's candidate property. (forward-thing thing 1) (return (when (/= end (point)) -(move-overlay easy-kill-candidate start (point)) -(easy-kill-select-text) +(easy-kill-adjust-candidate thing nil (point)) t (defun easy-kill-shrink (n) @@ -131,26 +142,19 @@ Otherwise, it is the value of the overlay's candidate property. (single-key-description last-command-event easy-kill-alist)) (prefix-numeric-value current-prefix-arg))) - ;; Return non-nil if succeed - (if (and thing - (let ((n (or n 1))) - (cond - ((and (not inhibit-handler) -(intern-soft (format easy-kill-on-%s thing))) - (funcall (intern-soft (format easy-kill-on-%s thing)) n)) - ((eq thing (overlay-get easy-kill-candidate 'thing)) - (easy-kill-enlarge n)) - (t (let ((bounds (bounds-of-thing-at-point thing))) - (when bounds - (move-overlay easy-kill-candidate (car bounds) (cdr bounds)) - (overlay-put easy-kill-candidate 'thing thing) - (easy-kill-enlarge (1- n)) - t)) - (progn -(easy-kill-select-text) -t) -(ignore (when (called-interactively-p 'interact) - (easy-kill-message-nolog No `%s' thing) + (let ((n (or n 1))) +(cond + ((and (not inhibit-handler) + (intern-soft (format easy-kill-on-%s thing))) + (funcall (intern-soft (format easy-kill-on-%s thing)) n)) + ((eq thing (overlay-get easy-kill-candidate 'thing)) + (easy-kill-enlarge n)) + (t (let ((bounds (bounds-of-thing-at-point thing))) + (if (not bounds) + (when (called-interactively-p 'interact) +(easy-kill-message-nolog No `%s' thing)) +(easy-kill-adjust-candidate thing (car bounds) (cdr bounds)) +(easy-kill-enlarge (1- n (defun easy-kill-activate-keymap () (let ((map (easy-kill-map))) @@ -173,15 +177,18 @@ Otherwise, it is the value of the overlay's candidate property. ;; intercept pasting from other programs and ;; `easy-kill-remember' already did the work. (let ((interprogram-cut-function nil) - (interprogram-paste-function nil)) - (kill-new (easy-kill-candidate))) + (interprogram-paste-function nil) + (candidate (easy-kill-candidate))) + (unless(member candidate '(nil )) + (kill-new candidate))) (delete-overlay easy-kill-candidate) (setq easy-kill-candidate nil) nil))) ;;;###autoload -(defun easy-kill () - (interactive) +(defun easy-kill (optional n) + Kill thing at point in the order of region, url, email
[elpa] 74/77: Require cl-lib
leoliu pushed a commit to branch master in repository elpa. commit a40258f397bf97f038fd17d267db0e30d2d371eb Author: Leo Liu sdl@gmail.com Date: Thu Mar 27 12:15:18 2014 +0800 Require cl-lib --- easy-kill.el | 35 +-- 1 files changed, 17 insertions(+), 18 deletions(-) diff --git a/easy-kill.el b/easy-kill.el index 07c8a37..caa59d2 100644 --- a/easy-kill.el +++ b/easy-kill.el @@ -4,7 +4,7 @@ ;; Author: Leo Liu sdl@gmail.com ;; Version: 0.9.1 -;; Package-Requires: ((emacs 24)) +;; Package-Requires: ((emacs 24) (cl-lib 0.5)) ;; Keywords: convenience ;; Created: 2013-08-12 ;; URL: https://github.com/leoliu/easy-kill @@ -39,7 +39,7 @@ ;;; Code: -(eval-when-compile (require 'cl)) +(require 'cl-lib) (require 'thingatpt) (eval-and-compile @@ -158,10 +158,10 @@ Do nothing if `easy-kill-inhibit-message' is non-nil. (narrow-to-region (max (point-min) (- (point) 1000)) (min (point-max) (+ (point) 1000))) (let ((easy-kill-inhibit-message t)) -(dolist (thing easy-kill-try-things) +(cl-dolist (thing easy-kill-try-things) (easy-kill-thing thing n) (or (string= (easy-kill-candidate) ) - (return) + (cl-return) o)) (defun easy-kill-indicate-origin () @@ -257,18 +257,18 @@ candidate property instead. ;; helper for `easy-kill-thing'. (defun easy-kill-thing-forward (n) (let ((thing (overlay-get easy-kill-candidate 'thing)) -(direction (if (minusp n) -1 +1)) +(direction (if (cl-minusp n) -1 +1)) (start (overlay-start easy-kill-candidate)) (end (overlay-end easy-kill-candidate))) (when (and thing (/= n 0)) (let ((new-end (save-excursion (goto-char end) (with-demoted-errors - (dotimes (_ (abs n)) + (cl-dotimes (_ (abs n)) (forward-thing thing direction) (when (= (point) start) (forward-thing thing 1) - (return + (cl-return (point (when (/= end new-end) (easy-kill-adjust-candidate thing nil new-end) @@ -446,21 +446,20 @@ Char properties `help-echo', `shr-url' and `w3m-href-anchor' are inspected. (if (or easy-kill-mark (bounds-of-thing-at-point 'url)) (easy-kill-thing 'url nil t) -(let ((get-url (lambda (text) - (when (stringp text) - (with-temp-buffer - (insert text) - (and (bounds-of-thing-at-point 'url) - (thing-at-point 'url))) - (dolist (p '(help-echo shr-url w3m-href-anchor)) +(cl-labels ((get-url (text) + (when (stringp text) + (with-temp-buffer + (insert text) + (and (bounds-of-thing-at-point 'url) + (thing-at-point 'url)) + (cl-dolist (p '(help-echo shr-url w3m-href-anchor)) (pcase-let* ((`(,text . ,ov) (get-char-property-and-overlay (point) p)) - (url (or (funcall get-url text) - (funcall get-url - (and ov (overlay-get ov p)) + (url (or (get-url text) + (get-url (and ov (overlay-get ov p)) (when url (easy-kill-adjust-candidate 'url url) -(return url))) +(cl-return url))) ;;; Handler for `sexp' and `list'.
[elpa] 32/77: Improve easy-kill-bounds-of-list
leoliu pushed a commit to branch master in repository elpa. commit 2735f9a572674a16772506633025dcda78a8303a Author: Leo Liu sdl@gmail.com Date: Thu Oct 10 16:39:43 2013 +0800 Improve easy-kill-bounds-of-list Stricter checking for handler in easy-kill-thing. --- easy-kill.el | 26 +++--- 1 files changed, 11 insertions(+), 15 deletions(-) diff --git a/easy-kill.el b/easy-kill.el index a208594..7674150 100644 --- a/easy-kill.el +++ b/easy-kill.el @@ -160,8 +160,8 @@ candidate property instead. (n (or n 1))) (cond ((and (not inhibit-handler) - (intern-soft (format easy-kill-on-%s thing))) - (funcall (intern-soft (format easy-kill-on-%s thing)) n)) + (fboundp (intern-soft (format easy-kill-on-%s thing + (funcall (intern (format easy-kill-on-%s thing)) n)) ((or (eq thing (overlay-get easy-kill-candidate 'thing)) (memq n '(+ -))) (easy-kill-thing-forward (pcase n @@ -304,22 +304,18 @@ inspected. (if (and (or (not bound) ( (point) bound)) (/= point (point))) (easy-kill-backward-down (point) bound) - point)) -(scan-error point))) + (goto-char point))) +(scan-error (goto-char point (defun easy-kill-bounds-of-list (n) (save-excursion -(when (pcase n -(`+ (let ((start (overlay-start easy-kill-candidate))) - (goto-char start) - (easy-kill-backward-up) - (/= start (point -(`- (let ((pt (point))) - (goto-char (easy-kill-backward-down - (point) (overlay-start easy-kill-candidate))) - (/= pt (point -(_ (error Unsupported argument `%s' n))) - (cons (point) (progn (forward-sexp 1) (point)) +(pcase n + (`+ (goto-char (overlay-start easy-kill-candidate)) + (easy-kill-backward-up)) + (`- (easy-kill-backward-down + (point) (overlay-start easy-kill-candidate))) + (_ (error Unsupported argument `%s' n))) +(bounds-of-thing-at-point 'sexp))) (defun easy-kill-on-list (n) (if (memq n '(+ -))
[elpa] 47/77: Doc fix and small tweaks
leoliu pushed a commit to branch master in repository elpa. commit 8bcdde864233b6c3060cccfc9c8cc7d36af99826 Author: Leo Liu sdl@gmail.com Date: Mon Oct 14 10:11:39 2013 +0800 Doc fix and small tweaks --- README.rst |1 + easy-kill.el | 11 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index 0c8b565..4306c63 100644 --- a/README.rst +++ b/README.rst @@ -26,6 +26,7 @@ Keys (customisable) immediately following ``easy-kill``: #. ``C-w`` - kill selection #. ``+``, ``-`` and ``0..9`` - expand/shrink selection #. ``SPC`` - turn selection into an active region +#. ``C-g`` - abort The following `screenshot http://i.imgur.com/8TNgPly.png`_ shows ``M-w l`` in action: diff --git a/easy-kill.el b/easy-kill.el index 54fbf15..778c95a 100644 --- a/easy-kill.el +++ b/easy-kill.el @@ -51,11 +51,11 @@ CHAR is used immediately following `easy-kill' to select THING. :type '(repeat symbol) :group 'killing) -(defface easy-kill-selection '((t (:inherit 'secondary-selection))) +(defface easy-kill-selection '((default (:inherit 'secondary-selection))) Faced used to highlight kill candidate. :group 'killing) -(defface easy-kill-origin '((t (:inverse-video t :inherit 'error))) +(defface easy-kill-origin '((default (:inverse-video t :inherit 'error))) Faced used to highlight the origin. :group 'killing) @@ -316,10 +316,11 @@ Temporally activate additional key bindings as follows: letters = select or expand selection according to `easy-kill-alist'; 0..9= expand selection by that number; - +,=/- = expand or shrink selection - @ = append selection to previous kill + +,=/- = expand or shrink selection; + @ = append selection to previous kill; C-w = kill selection; - SPC = turn selection into an active region + SPC = turn selection into an active region; + C-g = abort; others = save selection and exit. (interactive p) (if (use-region-p)
[elpa] 41/77: Tell easy-kill-append to deactivate-mark
leoliu pushed a commit to branch master in repository elpa. commit 60a366d7cb491e4c22035ee8399f3dfea54e3f39 Author: Leo Liu sdl@gmail.com Date: Sat Oct 12 09:26:25 2013 +0800 Tell easy-kill-append to deactivate-mark --- easy-kill.el |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/easy-kill.el b/easy-kill.el index b7bbf76..fcfae02 100644 --- a/easy-kill.el +++ b/easy-kill.el @@ -268,6 +268,7 @@ candidate property instead. (interactive) (setq easy-kill-append t) (when (easy-kill-save-candidate) +(setq deactivate-mark t) (easy-kill-message-nolog Appended))) (defun easy-kill-activate-keymap ()
[elpa] 68/77: Fix easy-kill-append to update clipboard
leoliu pushed a commit to branch master in repository elpa. commit d77fe394e16184903ce8d7d8a952898ef2570c84 Author: Leo Liu sdl@gmail.com Date: Sun Nov 10 12:42:13 2013 +0800 Fix easy-kill-append to update clipboard --- easy-kill.el |2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/easy-kill.el b/easy-kill.el index 994a5b0..c7fb903 100644 --- a/easy-kill.el +++ b/easy-kill.el @@ -331,6 +331,8 @@ candidate property instead. (interactive) (setq easy-kill-append t) (when (easy-kill-save-candidate) +(and interprogram-cut-function + (funcall interprogram-cut-function (car kill-ring))) (setq deactivate-mark t) (easy-kill-message-nolog Appended)))
[elpa] 49/77: Work with `sexp' and `list' in nxml mode
leoliu pushed a commit to branch master in repository elpa. commit c6519c0fad38cebe782df49508038d351d31e038 Author: Leo Liu sdl@gmail.com Date: Mon Oct 14 16:16:29 2013 +0800 Work with `sexp' and `list' in nxml mode --- easy-kill.el | 45 + 1 files changed, 37 insertions(+), 8 deletions(-) diff --git a/easy-kill.el b/easy-kill.el index d2338e3..37ee6c8 100644 --- a/easy-kill.el +++ b/easy-kill.el @@ -387,11 +387,13 @@ inspected. (easy-kill-adjust-candidate 'url url) (return url))) +(defvar up-list-fn) ; Dynamically bound + (defun easy-kill-backward-up () (let ((ppss (syntax-ppss))) (condition-case nil (progn - (up-list -1) + (funcall (or up-list-fn #'up-list) -1) ;; `up-list' may jump to another string. (when (and (nth 3 ppss) ( (point) (nth 8 ppss))) (goto-char (nth 8 ppss @@ -417,17 +419,44 @@ inspected. (_ (error Unsupported argument `%s' n))) (bounds-of-thing-at-point 'sexp))) -(defun easy-kill-on-list (n) - (if (memq n '(+ -)) +(defvar nxml-sexp-element-flag) + +(defun easy-kill-on-nxml-element (n) + (let ((nxml-sexp-element-flag t) +(up-list-fn (when (derived-mode-p 'nxml-mode) + #'nxml-up-element))) +(cond + ((memq n '(+ -)) (let ((bounds (easy-kill-bounds-of-list n))) (when bounds - (easy-kill-adjust-candidate 'list (car bounds) (cdr bounds -(easy-kill-thing 'list n nil t))) + (easy-kill-adjust-candidate 'list (car bounds) (cdr bounds) + ((eq 'list (overlay-get easy-kill-candidate 'thing)) + (let ((new-end (save-excursion + (goto-char (overlay-end easy-kill-candidate)) + (forward-sexp n) + (point +(when (and new-end (/= new-end (overlay-end easy-kill-candidate))) + (easy-kill-adjust-candidate 'list nil new-end + (t (save-excursion + (ignore-errors (easy-kill-backward-up)) + (easy-kill-thing 'sexp n nil t) + (overlay-put easy-kill-candidate 'thing 'list)) + +(defun easy-kill-on-list (n) + (cond + ((derived-mode-p 'nxml-mode) +(easy-kill-on-nxml-element n)) + ((memq n '(+ -)) +(let ((bounds (easy-kill-bounds-of-list n))) + (when bounds +(easy-kill-adjust-candidate 'list (car bounds) (cdr bounds) + (t (easy-kill-thing 'list n nil t (defun easy-kill-on-sexp (n) - (if (memq n '(+ -)) - (easy-kill-on-list n) -(easy-kill-thing 'sexp n nil t))) + (let ((nxml-sexp-element-flag t)) +(if (memq n '(+ -)) +(easy-kill-on-list n) + (easy-kill-thing 'sexp n nil t (provide 'easy-kill) ;;; easy-kill.el ends here
[elpa] 12/77: Tweak the definition of thing `region'
leoliu pushed a commit to branch master in repository elpa. commit 24f5de6ae99ad318b11df786060b63be1172e9c5 Author: Leo Liu sdl@gmail.com Date: Mon Oct 7 13:03:03 2013 +0800 Tweak the definition of thing `region' --- easy-kill.el |8 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/easy-kill.el b/easy-kill.el index 5861d09..1a30d10 100644 --- a/easy-kill.el +++ b/easy-kill.el @@ -197,9 +197,7 @@ candidate property instead. (overlay-put o 'priority 999) o)) (setq deactivate-mark t) - (dolist (thing (if (use-region-p) - '(region url email line) - '(url email line))) + (dolist (thing '(region url email line)) (easy-kill-thing thing n) (when (overlay-get easy-kill-candidate 'thing) (return))) @@ -208,7 +206,9 @@ candidate property instead. ;;; Extended things (put 'region 'bounds-of-thing-at-point - (lambda () (cons (region-beginning) (region-end + (lambda () + (when (use-region-p) + (cons (region-beginning) (region-end) (defun easy-kill-on-buffer-file-name (n) Get `buffer-file-name' or `default-directory'.
[elpa] 51/77: Fix quoting error in face definitions
leoliu pushed a commit to branch master in repository elpa. commit 2aad794e0b0b886556389a5bb1aa20f5ccd849a7 Author: Leo Liu sdl@gmail.com Date: Mon Oct 14 21:56:08 2013 +0800 Fix quoting error in face definitions --- easy-kill.el |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/easy-kill.el b/easy-kill.el index cb8c70b..fd70a99 100644 --- a/easy-kill.el +++ b/easy-kill.el @@ -51,11 +51,11 @@ CHAR is used immediately following `easy-kill' to select THING. :type '(repeat symbol) :group 'killing) -(defface easy-kill-selection '((default (:inherit 'secondary-selection))) +(defface easy-kill-selection '((t (:inherit secondary-selection))) Faced used to highlight kill candidate. :group 'killing) -(defface easy-kill-origin '((default (:inverse-video t :inherit 'error))) +(defface easy-kill-origin '((t (:inverse-video t :inherit error))) Faced used to highlight the origin. :group 'killing)
[elpa] 34/77: Better support for defining commands that exit easy-kill
leoliu pushed a commit to branch master in repository elpa. commit d2b1e27ebe2fdae7e2c8511dc84622f82be927dd Author: Leo Liu sdl@gmail.com Date: Thu Oct 10 19:45:57 2013 +0800 Better support for defining commands that exit easy-kill Use @ for easy-kill-append and document it. --- README.rst |1 + easy-kill.el | 104 + 2 files changed, 54 insertions(+), 51 deletions(-) diff --git a/README.rst b/README.rst index 597cc26..02aa1b0 100644 --- a/README.rst +++ b/README.rst @@ -21,6 +21,7 @@ Keys (customisable) immediately following ``M-w``: #. ``d`` - defun at point #. ``b`` - ``buffer-file-name`` or ``default-directory`` #. ``C-w`` - kill current region +#. ``@`` - append selection to previous kill #. ``+``, ``-`` and ``0..9`` - expand/shrink selection #. ``C-@`` or ``C-SPC`` - turn current selection into an active region diff --git a/easy-kill.el b/easy-kill.el index 87e323a..8f85919 100644 --- a/easy-kill.el +++ b/easy-kill.el @@ -51,7 +51,7 @@ CHAR is used immediately following `easy-kill' to select THING. (define-key map - 'easy-kill-shrink) (define-key map + 'easy-kill-expand) (define-key map = 'easy-kill-expand) -(define-key map ! 'easy-kill-append) +(define-key map @ 'easy-kill-append) (define-key map \C-w 'easy-kill-region) (define-key map (kbd C-SPC) 'easy-kill-mark-region) (define-key map (kbd C-@) 'easy-kill-mark-region) @@ -80,13 +80,10 @@ CHAR is used immediately following `easy-kill' to select THING. (error `string-match' failed in `easy-kill-strip-trailing'))) (t ))) -(defvar easy-kill-exit nil - Tell `set-temporary-overlay-map' to exit if non-nil. -Note: exit only happens right before next command per -`set-temporary-overlay-map'.) - (defvar easy-kill-candidate nil) +(defvar easy-kill-append nil) + (defun easy-kill-candidate () Get the kill candidate as a string. If the overlay specified by variable `easy-kill-candidate' has @@ -116,6 +113,29 @@ candidate property instead. (not (string= (easy-kill-candidate) )) (funcall interprogram-cut-function (easy-kill-candidate +(defun easy-kill-save-candidate () + ;; Do not modify the clipboard here because it may be called in + ;; `pre-command-hook' and will confuse `yank' if it is the next + ;; command. Also `easy-kill-adjust-candidate' already did the work. + (let ((interprogram-cut-function nil) +(interprogram-paste-function nil)) +(unless (string= (easy-kill-candidate) ) + (kill-new (if easy-kill-append +(concat (car kill-ring) \n +(easy-kill-candidate)) + (easy-kill-candidate)) +easy-kill-append) + t))) + +(defun easy-kill-destroy-candidate () + (let ((hook (make-symbol easy-kill-destroy-candidate))) +(fset hook (lambda () + (and easy-kill-candidate + (delete-overlay easy-kill-candidate)) + (setq easy-kill-candidate nil) + (remove-hook 'post-command-hook hook))) +(add-hook 'post-command-hook hook))) + (defun easy-kill-expand () (interactive) (easy-kill-thing nil '+)) @@ -176,68 +196,49 @@ candidate property instead. (easy-kill-adjust-candidate thing (car bounds) (cdr bounds)) (easy-kill-thing-forward (1- n +(put 'easy-kill-region 'easy-kill-exit t) (defun easy-kill-region () Kill current selection and exit. (interactive *) - (if (not easy-kill-candidate) ; `easy-kill' has exited - (push last-input-event unread-command-events) -(let ((beg (overlay-start easy-kill-candidate)) - (end (overlay-end easy-kill-candidate))) - (if (= beg end) - (easy-kill-message-nolog Empty region) -(setq easy-kill-exit t) -(easy-kill-adjust-candidate nil ) -(kill-region beg end) + (let ((beg (overlay-start easy-kill-candidate)) +(end (overlay-end easy-kill-candidate))) +(if (= beg end) +(easy-kill-message-nolog Empty region) + (kill-region beg end +(put 'easy-kill-mark-region 'easy-kill-exit t) (defun easy-kill-mark-region () (interactive) - (if (not easy-kill-candidate) - (push last-input-event unread-command-events) -(let ((beg (overlay-start easy-kill-candidate)) - (end (overlay-end easy-kill-candidate))) - (if (= beg end) - (easy-kill-message-nolog Empty region) -(setq easy-kill-exit t) -(easy-kill-adjust-candidate nil ) -(set-mark beg) -(goto-char end) -(activate-mark) - -(defvar easy-kill-append nil) + (let ((beg (overlay-start easy-kill-candidate)) +(end (overlay-end easy-kill-candidate))) +(if (= beg end) +(easy-kill-message-nolog Empty region) + (set-mark beg) + (goto-char end) + (activate-mark +(put 'easy-kill-append 'easy-kill
[elpa] 06/77: Various bug fixes and improvements
leoliu pushed a commit to branch master in repository elpa. commit 77b9e8fa77581672b2c21eb698f6b7abc58084b0 Author: Leo Liu sdl@gmail.com Date: Sun Oct 6 17:17:39 2013 +0800 Various bug fixes and improvements --- easy-kill.el | 120 +- 1 files changed, 68 insertions(+), 52 deletions(-) diff --git a/easy-kill.el b/easy-kill.el index a4922c2..cf853d2 100644 --- a/easy-kill.el +++ b/easy-kill.el @@ -42,6 +42,19 @@ :type '(repeat (cons character symbol)) :group 'killing) +(defun easy-kill-map () + (let ((map (make-sparse-keymap))) +(define-key map - 'easy-kill-backward) +(define-key map + 'easy-kill-forward) +(mapc (lambda (d) +(define-key map (number-to-string d) 'easy-kill-digit-argument)) + (number-sequence 0 9)) +(mapc (lambda (c) +;; (define-key map (vector meta-prefix-char c) 'easy-kill-select) +(define-key map (char-to-string c) 'easy-kill-thing)) + (mapcar 'car easy-kill-alist)) +map)) + (defface easy-kill-face '((t (:inherit 'secondary-selection))) Faced used to highlight kill candidate. :group 'killing) @@ -51,35 +64,25 @@ (let (message-log-max) (apply 'message format-string args))) +(defun easy-kill-strip-trailing (s) + (if (string-match [ \t\f\r\n]*\\' s) + (substring s 0 (match-beginning 0)) +(error `string-match' failed in `easy-kill-strip'))) + (defvar easy-kill-candidate nil) (defun easy-kill-candidate () - (when (overlayp easy-kill-candidate) -(if (eq (overlay-start easy-kill-candidate) -(overlay-end easy-kill-candidate)) -(overlay-get easy-kill-candidate 'candidate) - (buffer-substring (overlay-start easy-kill-candidate) -(overlay-end easy-kill-candidate) + (easy-kill-strip-trailing + (if (/= (overlay-start easy-kill-candidate) + (overlay-end easy-kill-candidate)) + (buffer-substring (overlay-start easy-kill-candidate) + (overlay-end easy-kill-candidate)) + (overlay-get easy-kill-candidate 'candidate (defun easy-kill-select-text () Make current kill candidate available to other programs. - (let ((candidate (easy-kill-candidate))) -(and candidate - interprogram-cut-function - (funcall interprogram-cut-function candidate - -(defun easy-kill-map () - (let ((map (make-sparse-keymap))) -(define-key map - 'easy-kill-backward) -(define-key map + 'easy-kill-forward) -(mapc (lambda (d) -(define-key map (number-to-string d) 'easy-kill-digit-argument)) - (number-sequence 0 9)) -(mapc (lambda (c) -;; (define-key map (vector meta-prefix-char c) 'easy-kill-select) -(define-key map (char-to-string c) 'easy-kill-select)) - (mapcar 'car easy-kill-alist)) -map)) + (and interprogram-cut-function + (funcall interprogram-cut-function (easy-kill-candidate (defun easy-kill-forward (n) (interactive p) @@ -105,31 +108,40 @@ (interactive p) (easy-kill-forward (- n))) +(defun easy-kill-digit-argument (optional n) + (interactive + (list (- (logand (if (integerp last-command-event) +last-command-event + (get last-command-event 'ascii-character)) +?\177) +?0))) + (easy-kill-thing (overlay-get easy-kill-candidate 'thing) n)) + (defun easy-kill-thing (thing optional n) + (interactive + (list (cdr (assoc (car (last (listify-key-sequence + (single-key-description last-command-event + easy-kill-alist)) + (prefix-numeric-value current-prefix-arg))) ;; Return non-nil if succeed - (when (and thing - (let ((n (or n 1))) - (cond -((intern-soft (format easy-kill-on-%s thing)) - (funcall (intern-soft (format easy-kill-on-%s thing)) n)) -((eq thing (overlay-get easy-kill-candidate 'thing)) - (easy-kill-forward n)) -(t (let ((bounds (bounds-of-thing-at-point thing))) - (when bounds - (move-overlay easy-kill-candidate (car bounds) (cdr bounds)) - (overlay-put easy-kill-candidate 'thing thing) - (easy-kill-forward (1- n)) - t)) -(easy-kill-select-text) -t)) - -(defun easy-kill-select (n) - (interactive p) - (let ((thing (cdr (assoc (car (last (listify-key-sequence - (single-key-description last-command-event - easy-kill-alist -(or (easy-kill-thing thing n) -(easy-kill-message-nolog No `%s' at point. thing + (if (and thing + (let ((n (or n 1))) + (cond + ((intern-soft (format easy-kill-on-%s thing)) + (funcall
[elpa] 14/77: Doc fix and release v0.7.0
leoliu pushed a commit to branch master in repository elpa. commit dfc7ff4caaba931a9556a2a850b6071c9be5dd35 Author: Leo Liu sdl@gmail.com Date: Mon Oct 7 16:37:28 2013 +0800 Doc fix and release v0.7.0 --- README.rst | 40 +++- easy-kill.el | 23 ++- 2 files changed, 49 insertions(+), 14 deletions(-) diff --git a/README.rst b/README.rst index 39263e6..abdd2ff 100644 --- a/README.rst +++ b/README.rst @@ -1,13 +1,14 @@ - - Kill Things Easily - - -Provide a more powerful command ``easy-kill`` for key ``M-w``. - -``M-w`` tries in order: += + Kill Things Easily in Emacs += + +``easy-kill`` let users kill things at point without moving point. Its +goal is to be a drop-in replacement for ``kill-ring-save``. It tries +in order: #. current region if active -#. url at point +#. url at point (snarf char properties ``help-echo``, ``shr-url``, + ``w3m-href-anchor`` etc.) #. email at point #. current line @@ -18,8 +19,16 @@ Keys (customisable) immediately following ``M-w``: #. ``f`` - file at point #. ``l`` - list at point #. ``d`` - defun at point +#. ``b`` - ``buffer-file-name`` or ``default-directory`` +#. ``C-w`` - kill current region +#. ``+``, ``-`` and ``0..9`` - enlarge/shrink selection -More features are planned. +The following `screenshot http://i.imgur.com/8TNgPly.png`_ shows +``M-w l`` in action: + +.. figure:: http://i.imgur.com/8TNgPly.png + :target: http://i.imgur.com/8TNgPly.png + :alt: ``M-w l`` To Use ~~ @@ -28,3 +37,16 @@ To Use (require 'easy-kill) (global-set-key \M-w 'easy-kill) + +Extensions +~~ + +New things can be defined by following package ``thingatpt.el``'s +convention, or by defining new functions named like +``easy-kill-on-THING-NAME``. See ``easy-kill-on-buffer-file-name`` and +``easy-kill-on-url`` for examples. + +Bugs + + +https://github.com/leoliu/easy-kill/issues diff --git a/easy-kill.el b/easy-kill.el index 98a284c..0966b2f 100644 --- a/easy-kill.el +++ b/easy-kill.el @@ -3,9 +3,10 @@ ;; Copyright (C) 2013 Leo Liu ;; Author: Leo Liu sdl@gmail.com -;; Version: 0.6.0 +;; Version: 0.7.0 ;; Keywords: convenience ;; Created: 2013-08-12 +;; URL: https://github.com/leoliu/easy-kill ;; 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 @@ -38,11 +39,13 @@ (?f . filename) (?d . defun) (?b . buffer-file-name)) - A list of (Key . THING). + A list of (CHAR . THING). +CHAR is used immediately following `easy-kill' to select THING. :type '(repeat (cons character symbol)) :group 'killing) (defun easy-kill-map () + Build the keymap according to `easy-kill-alist'. (let ((map (make-sparse-keymap))) (define-key map - 'easy-kill-shrink) (define-key map + 'easy-kill-enlarge) @@ -74,7 +77,7 @@ (t s))) (defvar easy-kill-exit nil - If non-nil tells `set-temporary-overlay-map' to exit.) + Tell `set-temporary-overlay-map' to exit if non-nil.) (defvar easy-kill-candidate nil) @@ -92,7 +95,7 @@ Otherwise, it is the value of the overlay's candidate property. (defun easy-kill-adjust-candidate (thing optional beg end) Adjust kill candidate to THING, BEG, END. -If BEG is a string, shring the overlay to zero length and set its +If BEG is a string, shrink the overlay to zero length and set its candidate property instead. (let ((o easy-kill-candidate)) (overlay-put o 'thing thing) @@ -195,7 +198,15 @@ candidate property instead. ;;;###autoload (defun easy-kill (optional n) - Kill thing at point in the order of region, url, email and line. + Kill thing at point in the order of region, url, email and line. +Immediately following this additional key bindings are temporally +activated: + + letters = select things (according to `easy-kill-alist'); + 0..9= enlarge current selection by that number; + +,=/- = enlarge or shrink current selection by 1; + C-w = kill current selection + others = save current selection to kill ring and exit (interactive p) (setq easy-kill-candidate (let ((o (make-overlay (point) (point @@ -209,6 +220,8 @@ candidate property instead. (easy-kill-thing thing n) (when (overlay-get easy-kill-candidate 'thing) (return))) + (when (zerop (buffer-size)) +(easy-kill-message-nolog Warn: `easy-kill' activated in empty buffer)) (easy-kill-activate-keymap)) ;;; Extended things
[elpa] 77/77: Merge easy-kill as packages/easy-kill
leoliu pushed a commit to branch master in repository elpa. commit 0a73626a30b81fb82ddf14c8b60d36e03e8edb1f Merge: 814b693 4e04082 Author: Leo Liu sdl@gmail.com Date: Sat Apr 5 12:05:30 2014 +0800 Merge easy-kill as packages/easy-kill packages/easy-kill/README.rst | 70 + packages/easy-kill/easy-kill.el | 568 +++ 2 files changed, 638 insertions(+), 0 deletions(-) diff --cc packages/easy-kill/README.rst index 000,427a251..427a251 mode 00,100644..100644 --- a/packages/easy-kill/README.rst +++ b/packages/easy-kill/README.rst diff --cc packages/easy-kill/easy-kill.el index 000,8365aab..8365aab mode 00,100644..100644 --- a/packages/easy-kill/easy-kill.el +++ b/packages/easy-kill/easy-kill.el
[elpa] 35/77: Doc fix and release v0.8.0
leoliu pushed a commit to branch master in repository elpa. commit eb07790c48b06186c003f92a1fc896e6e0f47f35 Author: Leo Liu sdl@gmail.com Date: Thu Oct 10 20:07:32 2013 +0800 Doc fix and release v0.8.0 --- README.rst |5 ++--- easy-kill.el | 17 - 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/README.rst b/README.rst index 02aa1b0..9192264 100644 --- a/README.rst +++ b/README.rst @@ -20,11 +20,10 @@ Keys (customisable) immediately following ``M-w``: #. ``l`` - list at point #. ``d`` - defun at point #. ``b`` - ``buffer-file-name`` or ``default-directory`` -#. ``C-w`` - kill current region #. ``@`` - append selection to previous kill +#. ``C-w`` - kill selection #. ``+``, ``-`` and ``0..9`` - expand/shrink selection -#. ``C-@`` or ``C-SPC`` - turn current selection into an active - region +#. ``SPC`` - turn selection into an active region The following `screenshot http://i.imgur.com/8TNgPly.png`_ shows ``M-w l`` in action: diff --git a/easy-kill.el b/easy-kill.el index 8f85919..552cb40 100644 --- a/easy-kill.el +++ b/easy-kill.el @@ -3,7 +3,7 @@ ;; Copyright (C) 2013 Leo Liu ;; Author: Leo Liu sdl@gmail.com -;; Version: 0.7.0 +;; Version: 0.8.0 ;; Package-Requires: ((emacs 24)) ;; Keywords: convenience ;; Created: 2013-08-12 @@ -52,9 +52,8 @@ CHAR is used immediately following `easy-kill' to select THING. (define-key map + 'easy-kill-expand) (define-key map = 'easy-kill-expand) (define-key map @ 'easy-kill-append) +(define-key map 'easy-kill-mark-region) (define-key map \C-w 'easy-kill-region) -(define-key map (kbd C-SPC) 'easy-kill-mark-region) -(define-key map (kbd C-@) 'easy-kill-mark-region) (mapc (lambda (d) (define-key map (number-to-string d) 'easy-kill-digit-argument)) (number-sequence 0 9)) @@ -245,13 +244,13 @@ candidate property instead. Kill thing at point in the order of region, url, email and line. Temporally activate additional key bindings as follows: - letters = select or expand things according to `easy-kill-alist'; - 0..9= expand current selection by that number; - +,=/- = expand or shrink current selection by 1; + letters = select or expand selection according to `easy-kill-alist'; + 0..9= expand selection by that number; + +,=/- = expand or shrink selection @ = append selection to previous kill - C-w = kill current selection; - C-SPC = turn current selection into active region - others = save current selection to kill ring and exit. + C-w = kill selection; + SPC = turn selection into an active region + others = save selection and exit. (interactive p) (if (use-region-p) (kill-ring-save (region-beginning) (region-end))
[elpa] 13/77: New command easy-kill-region to kill current selection
leoliu pushed a commit to branch master in repository elpa. commit c00060c7c9c1c97d86bdeb4ed1cd97174a0500bb Author: Leo Liu sdl@gmail.com Date: Mon Oct 7 15:40:58 2013 +0800 New command easy-kill-region to kill current selection --- easy-kill.el | 26 +- 1 files changed, 17 insertions(+), 9 deletions(-) diff --git a/easy-kill.el b/easy-kill.el index 1a30d10..98a284c 100644 --- a/easy-kill.el +++ b/easy-kill.el @@ -47,6 +47,7 @@ (define-key map - 'easy-kill-shrink) (define-key map + 'easy-kill-enlarge) (define-key map = 'easy-kill-enlarge) +(define-key map \C-w 'easy-kill-region) (mapc (lambda (d) (define-key map (number-to-string d) 'easy-kill-digit-argument)) (number-sequence 0 9)) @@ -72,6 +73,9 @@ (error `string-match' failed in `easy-kill-strip'))) (t s))) +(defvar easy-kill-exit nil + If non-nil tells `set-temporary-overlay-map' to exit.) + (defvar easy-kill-candidate nil) (defun easy-kill-candidate () @@ -136,6 +140,16 @@ candidate property instead. ?0))) (easy-kill-thing (overlay-get easy-kill-candidate 'thing) n)) +(defun easy-kill-region () + Kill current selection and exit. + (interactive) + (let ((beg (overlay-start easy-kill-candidate)) +(end (overlay-end easy-kill-candidate))) +(if (/= beg end) +(kill-region beg end) + (easy-kill-message-nolog Region empty))) + (setq easy-kill-exit t)) + (defun easy-kill-thing (thing optional n inhibit-handler) (interactive (list (cdr (assoc (car (last (listify-key-sequence @@ -163,15 +177,9 @@ candidate property instead. (lambda () ;; When any error happens the keymap is active forever. (with-demoted-errors - (or (let ((cmd (lookup-key map (this-command-keys - (eq this-command - (if (and (numberp cmd) -universal-argument-num-events -( (length (this-command-keys)) - universal-argument-num-events)) - (lookup-key map (substring (this-command-keys) - universal-argument-num-events)) - cmd))) + (or (and (not (prog1 easy-kill-exit + (setq easy-kill-exit nil))) + (eq this-command (lookup-key map (this-command-keys (when easy-kill-candidate ;; Do not modify the clipboard here because it will ;; intercept pasting from other programs and
[elpa] 61/77: Optimise easy-kill-thing-forward when n is 0
leoliu pushed a commit to branch master in repository elpa. commit 510b8435710e4895ae0ce8e3b03c32c831ce433f Author: Leo Liu sdl@gmail.com Date: Mon Oct 28 14:42:45 2013 +0800 Optimise easy-kill-thing-forward when n is 0 --- easy-kill.el |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/easy-kill.el b/easy-kill.el index a544d8c..ea0aeab 100644 --- a/easy-kill.el +++ b/easy-kill.el @@ -255,7 +255,7 @@ candidate property instead. (direction (if (minusp n) -1 +1)) (start (overlay-start easy-kill-candidate)) (end (overlay-end easy-kill-candidate))) -(when thing +(when (and thing (/= n 0)) (let ((new-end (save-excursion (goto-char end) (with-demoted-errors
[elpa] 65/77: Fix #8: Don't strip trailing blank chars
leoliu pushed a commit to branch master in repository elpa. commit c97d3dfeca601190f403d12aebcd376e39ab89f1 Author: Leo Liu sdl@gmail.com Date: Fri Nov 1 09:33:42 2013 +0800 Fix #8: Don't strip trailing blank chars --- easy-kill.el | 23 --- 1 files changed, 8 insertions(+), 15 deletions(-) diff --git a/easy-kill.el b/easy-kill.el index 9c2638d..a105777 100644 --- a/easy-kill.el +++ b/easy-kill.el @@ -126,13 +126,6 @@ Do nothing if `easy-kill-inhibit-message' is non-nil. (let (message-log-max) (apply 'message format-string args -(defun easy-kill-strip-trailing (s) - (cond ((stringp s) - (if (string-match [ \t\f\r\n]*\\' s) - (substring s 0 (match-beginning 0)) - (error `string-match' failed in `easy-kill-strip-trailing'))) -(t ))) - (defvar easy-kill-candidate nil) (defvar easy-kill-append nil) (defvar easy-kill-mark nil) @@ -176,13 +169,13 @@ Do nothing if `easy-kill-inhibit-message' is non-nil. If the overlay specified by variable `easy-kill-candidate' has non-zero length, it is the string covered by the overlay. Otherwise, it is the value of the overlay's candidate property. - (easy-kill-strip-trailing - (with-current-buffer (overlay-buffer easy-kill-candidate) - (if (/= (overlay-start easy-kill-candidate) - (overlay-end easy-kill-candidate)) - (filter-buffer-substring (overlay-start easy-kill-candidate) - (overlay-end easy-kill-candidate)) - (overlay-get easy-kill-candidate 'candidate) + (with-current-buffer (overlay-buffer easy-kill-candidate) +(or (if (/= (overlay-start easy-kill-candidate) +(overlay-end easy-kill-candidate)) +(filter-buffer-substring (overlay-start easy-kill-candidate) + (overlay-end easy-kill-candidate)) + (overlay-get easy-kill-candidate 'candidate)) +))) (defun easy-kill-adjust-candidate (thing optional beg end) Adjust kill candidate to THING, BEG, END. @@ -214,7 +207,7 @@ candidate property instead. (let ((interprogram-cut-function nil) (interprogram-paste-function nil)) (kill-new (if easy-kill-append -(concat (car kill-ring) \n (easy-kill-candidate)) +(concat (car kill-ring) (easy-kill-candidate)) (easy-kill-candidate)) easy-kill-append)) t))
[elpa] 72/77: Rename easy-kill-backward-down to easy-kill-forward-down
leoliu pushed a commit to branch master in repository elpa. commit 5f332bfafce38379d7a2789549d1846963edb28f Author: Leo Liu sdl@gmail.com Date: Wed Feb 5 01:42:21 2014 +0800 Rename easy-kill-backward-down to easy-kill-forward-down --- easy-kill.el | 10 +- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/easy-kill.el b/easy-kill.el index a42e2a4..dcbbae4 100644 --- a/easy-kill.el +++ b/easy-kill.el @@ -1,6 +1,6 @@ ;;; easy-kill.el --- kill things easily -*- lexical-binding: t; -*- -;; Copyright (C) 2013 Leo Liu +;; Copyright (C) 2013-2014 Leo Liu ;; Author: Leo Liu sdl@gmail.com ;; Version: 0.9.1 @@ -411,7 +411,7 @@ Temporally activate additional key bindings as follows: (defun easy-kill-on-buffer-file-name (n) Get `buffer-file-name' or `default-directory'. If N is zero, remove the directory part; -, remove the file name -party; +, full path. +part; +, full path. (if easy-kill-mark (easy-kill-message-nolog Not supported in `easy-mark') (let ((file (or buffer-file-name default-directory))) @@ -472,14 +472,14 @@ inspected. (goto-char (nth 8 ppss (scan-error (and (nth 3 ppss) (goto-char (nth 8 ppss))) -(defun easy-kill-backward-down (point optional bound) +(defun easy-kill-forward-down (point optional bound) (condition-case nil (progn (easy-kill-backward-up) (backward-prefix-chars) (if (and (or (not bound) ( (point) bound)) (/= point (point))) -(easy-kill-backward-down (point) bound) +(easy-kill-forward-down (point) bound) (goto-char point))) (scan-error (goto-char point @@ -488,7 +488,7 @@ inspected. (pcase n (`+ (goto-char (overlay-start easy-kill-candidate)) (easy-kill-backward-up)) - (`- (easy-kill-backward-down + (`- (easy-kill-forward-down (point) (overlay-start easy-kill-candidate))) (_ (error Unsupported argument `%s' n))) (bounds-of-thing-at-point 'sexp)))
[elpa] 18/77: Consolidate all kill features in easy-kill-thing
leoliu pushed a commit to branch master in repository elpa. commit 39b37b7489d7b3d3583b375b0d293b3926910c58 Author: Leo Liu sdl@gmail.com Date: Tue Oct 8 15:05:48 2013 +0800 Consolidate all kill features in easy-kill-thing Rename easy-kill-enlarge to easy-kill-expand. --- easy-kill.el | 111 ++--- 1 files changed, 58 insertions(+), 53 deletions(-) diff --git a/easy-kill.el b/easy-kill.el index 0185374..c81eab0 100644 --- a/easy-kill.el +++ b/easy-kill.el @@ -48,8 +48,8 @@ CHAR is used immediately following `easy-kill' to select THING. Build the keymap according to `easy-kill-alist'. (let ((map (make-sparse-keymap))) (define-key map - 'easy-kill-shrink) -(define-key map + 'easy-kill-enlarge) -(define-key map = 'easy-kill-enlarge) +(define-key map + 'easy-kill-expand) +(define-key map = 'easy-kill-expand) (define-key map \C-w 'easy-kill-region) (mapc (lambda (d) (define-key map (number-to-string d) 'easy-kill-digit-argument)) @@ -105,75 +105,82 @@ candidate property instead. (move-overlay o (point) (point)) (overlay-put o 'candidate beg) (easy-kill-message-nolog %s beg)) - (move-overlay o (or beg (overlay-start o)) (or end (overlay-end 0) + (move-overlay o (or beg (overlay-start o)) (or end (overlay-end o) (and interprogram-cut-function (not (string= (easy-kill-candidate) )) (funcall interprogram-cut-function (easy-kill-candidate -(defun easy-kill-enlarge (n) - (interactive p) - (let ((thing (overlay-get easy-kill-candidate 'thing))) -(when thing - (if (get thing 'easy-kill-enlarge) - (funcall (get thing 'easy-kill-enlarge) n) -(let ((direction (if (minusp n) -1 +1)) - (start (overlay-start easy-kill-candidate)) - (end (overlay-end easy-kill-candidate))) - (when thing -(save-excursion - (goto-char end) - (with-demoted-errors -(dotimes (_ (abs n)) - (forward-thing thing direction) - (when (= (point) start) -(forward-thing thing 1) -(return - (when (/= end (point)) -(easy-kill-adjust-candidate thing nil (point)) -t - -(defun easy-kill-shrink (n) - (interactive p) - (easy-kill-enlarge (- n))) +(defun easy-kill-expand () + (interactive) + (easy-kill-thing nil '+)) -(defun easy-kill-digit-argument (optional n) +(defun easy-kill-digit-argument (n) (interactive (list (- (logand (if (integerp last-command-event) last-command-event (get last-command-event 'ascii-character)) ?\177) ?0))) - (easy-kill-thing (overlay-get easy-kill-candidate 'thing) n)) + (easy-kill-thing nil n)) -(defun easy-kill-region () - Kill current selection and exit. - (interactive *) - (let ((beg (overlay-start easy-kill-candidate)) -(end (overlay-end easy-kill-candidate))) -(if (= beg end) -(easy-kill-message-nolog Empty region) - (setq easy-kill-exit t) - (kill-region beg end +(defun easy-kill-shrink () + (interactive) + (easy-kill-thing nil '-)) -(defun easy-kill-thing (thing optional n inhibit-handler) +;; helper for `easy-kill-thing'. +(defun easy-kill-thing-forward (n) + (let ((thing (overlay-get easy-kill-candidate 'thing)) +(direction (if (minusp n) -1 +1)) +(start (overlay-start easy-kill-candidate)) +(end (overlay-end easy-kill-candidate))) +(when thing + (save-excursion +(goto-char end) +(with-demoted-errors + (dotimes (_ (abs n)) +(forward-thing thing direction) +(when (= (point) start) + (forward-thing thing 1) + (return +(when (/= end (point)) + (easy-kill-adjust-candidate thing nil (point)) + t) + +(defun easy-kill-thing (optional thing n nomsg inhibit-handler) + ;; N can be -, + and digits (interactive (list (cdr (assoc (car (last (listify-key-sequence (single-key-description last-command-event easy-kill-alist)) (prefix-numeric-value current-prefix-arg))) - (let ((n (or n 1))) + (let ((thing (or thing (overlay-get easy-kill-candidate 'thing))) +(n (or n 1))) (cond ((and (not inhibit-handler) (intern-soft (format easy-kill-on-%s thing))) (funcall (intern-soft (format easy-kill-on-%s thing)) n)) - ((eq thing (overlay-get easy-kill-candidate 'thing)) - (easy-kill-enlarge n)) + ((or (eq thing (overlay-get easy-kill-candidate 'thing)) + (memq n '(+ -))) + (easy-kill-thing-forward (pcase n + (`+ 1) + (`- -1
[elpa] 20/77: Replace `enlarge' with `expand' in strings and comments
leoliu pushed a commit to branch master in repository elpa. commit b89aa04cd93237b49a8386968da454a367cc47f0 Author: Leo Liu sdl@gmail.com Date: Tue Oct 8 15:28:20 2013 +0800 Replace `enlarge' with `expand' in strings and comments --- README.rst |2 +- easy-kill.el |6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index abdd2ff..7ae3f96 100644 --- a/README.rst +++ b/README.rst @@ -21,7 +21,7 @@ Keys (customisable) immediately following ``M-w``: #. ``d`` - defun at point #. ``b`` - ``buffer-file-name`` or ``default-directory`` #. ``C-w`` - kill current region -#. ``+``, ``-`` and ``0..9`` - enlarge/shrink selection +#. ``+``, ``-`` and ``0..9`` - expand/shrink selection The following `screenshot http://i.imgur.com/8TNgPly.png`_ shows ``M-w l`` in action: diff --git a/easy-kill.el b/easy-kill.el index b33f43c..59554d9 100644 --- a/easy-kill.el +++ b/easy-kill.el @@ -209,9 +209,9 @@ candidate property instead. Kill thing at point in the order of region, url, email and line. Temporally activate additional key bindings as follows: - letters = select or enlarge things according to `easy-kill-alist'; - 0..9= enlarge current selection by that number; - +,=/- = enlarge or shrink current selection by 1; + letters = select or expand things according to `easy-kill-alist'; + 0..9= expand current selection by that number; + +,=/- = expand or shrink current selection by 1; C-w = kill current selection; others = save current selection to kill ring and exit. (interactive p)
[elpa] 17/77: Fix error: (args-out-of-range 1009 1035)
leoliu pushed a commit to branch master in repository elpa. commit 13bb9830819a4dd85402a8d95bd9df75c4e3a08d Author: Leo Liu sdl@gmail.com Date: Tue Oct 8 10:33:21 2013 +0800 Fix error: (args-out-of-range 1009 1035) Such errors could happen when easy-kill is active and emacsclient opens a new buffer. --- easy-kill.el | 11 ++- 1 files changed, 6 insertions(+), 5 deletions(-) diff --git a/easy-kill.el b/easy-kill.el index d259e3c..0185374 100644 --- a/easy-kill.el +++ b/easy-kill.el @@ -87,11 +87,12 @@ If the overlay specified by variable `easy-kill-candidate' has non-zero length, it is the string covered by the overlay. Otherwise, it is the value of the overlay's candidate property. (easy-kill-strip-trailing - (if (/= (overlay-start easy-kill-candidate) - (overlay-end easy-kill-candidate)) - (buffer-substring (overlay-start easy-kill-candidate) - (overlay-end easy-kill-candidate)) - (overlay-get easy-kill-candidate 'candidate + (with-current-buffer (overlay-buffer easy-kill-candidate) + (if (/= (overlay-start easy-kill-candidate) + (overlay-end easy-kill-candidate)) + (buffer-substring (overlay-start easy-kill-candidate) + (overlay-end easy-kill-candidate)) + (overlay-get easy-kill-candidate 'candidate) (defun easy-kill-adjust-candidate (thing optional beg end) Adjust kill candidate to THING, BEG, END.
[elpa] 71/77: In no case should easy-kill-activate-keymap err
leoliu pushed a commit to branch master in repository elpa. commit 81d7ca20db812d7ddd6716119bcae36c3bc4cbb6 Author: Leo Liu sdl@gmail.com Date: Thu Dec 12 17:55:55 2013 +0800 In no case should easy-kill-activate-keymap err --- easy-kill.el | 28 1 files changed, 16 insertions(+), 12 deletions(-) diff --git a/easy-kill.el b/easy-kill.el index cdb78c9..a42e2a4 100644 --- a/easy-kill.el +++ b/easy-kill.el @@ -345,18 +345,22 @@ candidate property instead. map (lambda () ;; Prevent any error from activating the keymap forever. - (with-demoted-errors - (or (and (not (and (symbolp this-command) -(get this-command 'easy-kill-exit))) - (or (eq this-command (lookup-key map (this-single-command-keys))) - (let ((cmd (key-binding (this-single-command-keys) nil t))) -(command-remapping cmd nil (list map) - (ignore - (easy-kill-destroy-candidate) - (unless (or easy-kill-mark - (and (symbolp this-command) - (get this-command 'easy-kill-exit))) -(easy-kill-save-candidate) + (condition-case err + (or (and (not (and (symbolp this-command) + (get this-command 'easy-kill-exit))) +(or (eq this-command +(lookup-key map (this-single-command-keys))) +(let ((cmd (key-binding +(this-single-command-keys) nil t))) + (command-remapping cmd nil (list map) + (ignore +(easy-kill-destroy-candidate) +(unless (or easy-kill-mark +(and (symbolp this-command) + (get this-command 'easy-kill-exit))) + (easy-kill-save-candidate + (error (message %s:%s this-command (error-message-string err)) +nil)) ;;;###autoload (defun easy-kill (optional n)
[elpa] 67/77: New handler for defun-name and bind it to `D'
leoliu pushed a commit to branch master in repository elpa. commit 8235069396ae5ce7901d7a6a1839ce1d0643e506 Author: Leo Liu sdl@gmail.com Date: Thu Nov 7 14:03:46 2013 +0800 New handler for defun-name and bind it to `D' --- README.rst |1 + easy-kill.el | 14 +- 2 files changed, 14 insertions(+), 1 deletions(-) diff --git a/README.rst b/README.rst index d953a13..f5fb6e6 100644 --- a/README.rst +++ b/README.rst @@ -25,6 +25,7 @@ active: #. ``f`` - file at point #. ``l`` - list at point #. ``d`` - defun at point +#. ``D`` - defun-name; works even when in a diff hunk #. ``b`` - ``buffer-file-name`` or ``default-directory`` #. ``@`` - append selection to previous kill #. ``C-w`` - kill selection diff --git a/easy-kill.el b/easy-kill.el index f8db73f..994a5b0 100644 --- a/easy-kill.el +++ b/easy-kill.el @@ -74,7 +74,8 @@ (?f . filename) (?d . defun) (?e . line) -(?b . buffer-file-name)) +(?b . buffer-file-name) +(?D . defun-name)) A list of (CHAR . THING). CHAR is used immediately following `easy-kill' to select THING. :type '(repeat (cons character symbol)) @@ -414,6 +415,17 @@ party; +, full path. (_ file (easy-kill-adjust-candidate 'buffer-file-name text)) +;;; Handler for `defun-name'. + +(defun easy-kill-on-defun-name (_n) + Get current defun name. + (if easy-kill-mark + (easy-kill-message-nolog Not supported in `easy-mark') +(let ((defun-name (add-log-current-defun))) + (if defun-name + (easy-kill-adjust-candidate 'defun-name defun-name) +(easy-kill-message-nolog No `defun-name' at point) + ;;; Handler for `url'. (defun easy-kill-on-url (optional _n)
[elpa] 50/77: Fix last change to easy-kill-backward-up
leoliu pushed a commit to branch master in repository elpa. commit 4b9c146fc82424e9e90d1632f2c0ff73fe917880 Author: Leo Liu sdl@gmail.com Date: Mon Oct 14 16:29:32 2013 +0800 Fix last change to easy-kill-backward-up --- easy-kill.el | 10 -- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/easy-kill.el b/easy-kill.el index 37ee6c8..cb8c70b 100644 --- a/easy-kill.el +++ b/easy-kill.el @@ -350,7 +350,9 @@ Temporally activate additional key bindings as follows: (overlay-put easy-kill-candidate 'thing 'sexp) (easy-kill-thing 'sexp n -;;; Extended things + Extended things + +;;; Handler for `buffer-file-name'. (defun easy-kill-on-buffer-file-name (n) Get `buffer-file-name' or `default-directory'. @@ -365,6 +367,8 @@ party; +, full path. (_ file (easy-kill-adjust-candidate 'buffer-file-name text) +;;; Handler for `url'. + (defun easy-kill-on-url (optional _n) Get url at point or from char properties. Char properties `help-echo', `shr-url' and `w3m-href-anchor' are @@ -387,13 +391,15 @@ inspected. (easy-kill-adjust-candidate 'url url) (return url))) +;;; Handler for `list'. + (defvar up-list-fn) ; Dynamically bound (defun easy-kill-backward-up () (let ((ppss (syntax-ppss))) (condition-case nil (progn - (funcall (or up-list-fn #'up-list) -1) + (funcall (or (bound-and-true-p up-list-fn) #'up-list) -1) ;; `up-list' may jump to another string. (when (and (nth 3 ppss) ( (point) (nth 8 ppss))) (goto-char (nth 8 ppss
[elpa] 48/77: Make command easy-kill-append work for easy-mark
leoliu pushed a commit to branch master in repository elpa. commit 0b658c85f25e312e39cfb418d821326159b86afc Author: Leo Liu sdl@gmail.com Date: Mon Oct 14 11:57:40 2013 +0800 Make command easy-kill-append work for easy-mark --- README.rst |3 +++ easy-kill.el |7 --- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index 4306c63..3ab89b8 100644 --- a/README.rst +++ b/README.rst @@ -38,6 +38,9 @@ The following `screenshot http://i.imgur.com/8TNgPly.png`_ shows To Use ~~ +``easy-kill`` is available on `MELPA +http://melpa.milkbox.net/#/easy-kill`_. + :: (require 'easy-kill) diff --git a/easy-kill.el b/easy-kill.el index 778c95a..d2338e3 100644 --- a/easy-kill.el +++ b/easy-kill.el @@ -166,7 +166,7 @@ candidate property instead. (funcall interprogram-cut-function (easy-kill-candidate)) (defun easy-kill-save-candidate () - (unless (or easy-kill-mark (string= (easy-kill-candidate) )) + (unless (string= (easy-kill-candidate) ) ;; Do not modify the clipboard here because this may be called in ;; `pre-command-hook' and will confuse `yank' if it is the next ;; command. Also `easy-kill-adjust-candidate' already did the @@ -305,8 +305,9 @@ candidate property instead. (eq this-command (lookup-key map (this-command-keys-vector (ignore (easy-kill-destroy-candidate) - (unless (and (symbolp this-command) - (get this-command 'easy-kill-exit)) + (unless (or easy-kill-mark + (and (symbolp this-command) + (get this-command 'easy-kill-exit))) (easy-kill-save-candidate) ;;;###autoload
[elpa] 58/77: Emacs 24.x compatibility
leoliu pushed a commit to branch master in repository elpa. commit b49c2f114cd8b7454c7cc6f2bae789aa346f2948 Author: Leo Liu sdl@gmail.com Date: Thu Oct 17 15:01:02 2013 +0800 Emacs 24.x compatibility --- easy-kill.el | 23 +++ 1 files changed, 23 insertions(+), 0 deletions(-) diff --git a/easy-kill.el b/easy-kill.el index 1728f41..1d10ea9 100644 --- a/easy-kill.el +++ b/easy-kill.el @@ -44,6 +44,29 @@ (eval-when-compile (require 'cl)) (require 'thingatpt) +(eval-and-compile + (or (fboundp 'set-temporary-overlay-map) ; new in 24.3 + (defun set-temporary-overlay-map (map optional keep-pred) +(let* ((clearfunsym (make-symbol clear-temporary-overlay-map)) + (overlaysym (make-symbol t)) + (alist (list (cons overlaysym map))) + (clearfun +`(lambda () + (unless ,(cond ((null keep-pred) nil) + ((eq t keep-pred) + `(eq this-command +(lookup-key ',map + (this-command-keys-vector + (t `(funcall ',keep-pred))) + (set ',overlaysym nil) ;Just in case. + (remove-hook 'pre-command-hook ',clearfunsym) + (setq emulation-mode-map-alists + (delq ',alist emulation-mode-map-alists)) + (set overlaysym overlaysym) + (fset clearfunsym clearfun) + (add-hook 'pre-command-hook clearfunsym) + (push alist emulation-mode-map-alists) + (defcustom easy-kill-alist '((?w . word) (?s . sexp)
[elpa] 39/77: Fix doc and buglets in last change
leoliu pushed a commit to branch master in repository elpa. commit 9752842b9db1cf6f27518a7ed1d67a36259083f3 Author: Leo Liu sdl@gmail.com Date: Fri Oct 11 13:09:20 2013 +0800 Fix doc and buglets in last change --- README.rst | 10 ++ easy-kill.el |7 --- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/README.rst b/README.rst index 9192264..0c8b565 100644 --- a/README.rst +++ b/README.rst @@ -2,9 +2,11 @@ Kill Things Easily in Emacs = -``easy-kill`` let users kill things at point without moving point. Its -goal is to be a drop-in replacement for ``kill-ring-save``. It tries -in order: +Commands ``easy-kill`` and ``easy-mark`` let users kill/mark things at +point easily. + +``easy-kill`` is a drop-in replacement for ``kill-ring-save``. It +tries in order: #. current region if active #. url at point (snarf char properties ``help-echo``, ``shr-url``, @@ -12,7 +14,7 @@ in order: #. email at point #. current line -Keys (customisable) immediately following ``M-w``: +Keys (customisable) immediately following ``easy-kill``: #. ``w`` - word at point #. ``s`` - sexp at point diff --git a/easy-kill.el b/easy-kill.el index 3f22f17..04cb42c 100644 --- a/easy-kill.el +++ b/easy-kill.el @@ -196,8 +196,8 @@ candidate property instead. (forward-thing thing direction) (when (= (point) start) (forward-thing thing 1) - (return))) - (point) + (return + (point (when (/= end new-end) (easy-kill-adjust-candidate thing nil new-end) t) @@ -298,6 +298,7 @@ Temporally activate additional key bindings as follows: ;;;###autoload (defun easy-mark (optional n) + Like `easy-kill' (which see) but for marking. (interactive p) (setq easy-kill-mark t) (easy-kill-init-candidate n) @@ -322,7 +323,7 @@ party; +, full path. Get url at point or from char properties. Char properties `help-echo', `shr-url' and `w3m-href-anchor' are inspected. - (if (bounds-of-thing-at-point 'url) + (if (or easy-kill-mark (bounds-of-thing-at-point 'url)) (easy-kill-thing 'url nil nil t) (let ((get-url (lambda (text) (when (stringp text)
[elpa] 45/77: Better origin indicator by easy-kill-indicate-origin
leoliu pushed a commit to branch master in repository elpa. commit fcec04c90db9ba4efda6355c2c0defd31c65499c Author: Leo Liu sdl@gmail.com Date: Sun Oct 13 16:58:00 2013 +0800 Better origin indicator by easy-kill-indicate-origin --- easy-kill.el | 19 --- 1 files changed, 16 insertions(+), 3 deletions(-) diff --git a/easy-kill.el b/easy-kill.el index 15059ee..d422e9b 100644 --- a/easy-kill.el +++ b/easy-kill.el @@ -108,10 +108,10 @@ CHAR is used immediately following `easy-kill' to select THING. ;; `hl-line-mode'. (overlay-put o 'priority 999) (when easy-kill-mark - (let ((i (make-overlay (point) - (funcall (if (eolp) #'1- #'1+) (point) + (let ((i (make-overlay (point) (point (overlay-put i 'priority (1+ (overlay-get o 'priority))) (overlay-put i 'face 'easy-kill-origin) +(overlay-put i 'as (propertize 'face 'easy-kill-origin)) (overlay-put o 'origin-indicator i))) (setq easy-kill-candidate o) (dolist (thing easy-kill-try-things) @@ -120,6 +120,18 @@ CHAR is used immediately following `easy-kill' to select THING. (return))) o)) +(defun easy-kill-indicate-origin () + (let ((i (overlay-get easy-kill-candidate 'origin-indicator)) +(origin (overlay-get easy-kill-candidate 'origin))) +(cond + ((not (overlayp i)) nil) + ((= origin (point)) + (overlay-put i 'after-string nil)) + ((memq (char-after origin) '(?\t ?\n)) + (overlay-put i 'after-string (overlay-get i 'as))) + (t (move-overlay i origin (1+ origin)) +(overlay-put i 'after-string nil) + (defun easy-kill-candidate () Get the kill candidate as a string. If the overlay specified by variable `easy-kill-candidate' has @@ -147,7 +159,8 @@ candidate property instead. (overlay-put o 'candidate beg) (easy-kill-message-nolog %s beg)) (move-overlay o beg end)) -(cond (easy-kill-mark (easy-kill-mark-region)) +(cond (easy-kill-mark (easy-kill-mark-region) + (easy-kill-indicate-origin)) ((and interprogram-cut-function (not (string= (easy-kill-candidate) ))) (funcall interprogram-cut-function (easy-kill-candidate))
[elpa] 38/77: Fix #3: Add command easy-mark for marking
leoliu pushed a commit to branch master in repository elpa. commit 54fdc36479be86e5cba4dc60577ad44a5f92541a Author: Leo Liu sdl@gmail.com Date: Fri Oct 11 12:44:48 2013 +0800 Fix #3: Add command easy-mark for marking --- easy-kill.el | 94 + 1 files changed, 61 insertions(+), 33 deletions(-) diff --git a/easy-kill.el b/easy-kill.el index 9b8a658..3f22f17 100644 --- a/easy-kill.el +++ b/easy-kill.el @@ -45,7 +45,7 @@ CHAR is used immediately following `easy-kill' to select THING. :type '(repeat (cons character symbol)) :group 'killing) -(defface easy-kill-face '((t (:inherit 'secondary-selection))) +(defface easy-kill-selection '((t (:inherit 'secondary-selection))) Faced used to highlight kill candidate. :group 'killing) @@ -85,8 +85,28 @@ CHAR is used immediately following `easy-kill' to select THING. (t ))) (defvar easy-kill-candidate nil) - (defvar easy-kill-append nil) +(defvar easy-kill-mark nil) + +(defun easy-kill-init-candidate (n) + (let ((o (make-overlay (point) (point +(unless easy-kill-mark + (overlay-put o 'face 'easy-kill-selection)) +(overlay-put o 'origin (point)) +;; Use higher priority to avoid shadowing by, for example, +;; `hl-line-mode'. +(overlay-put o 'priority 999) +(when easy-kill-mark + (let ((i (make-overlay (point) (point +(overlay-put i 'priority (1+ (overlay-get o 'priority))) +(overlay-put i 'after-string (propertize _ 'face 'error)) +(overlay-put o 'origin-indicator i))) +(setq easy-kill-candidate o) +(dolist (thing '(url email line)) + (easy-kill-thing thing n 'nomsg) + (or (string= (easy-kill-candidate) ) + (return))) +o)) (defun easy-kill-candidate () Get the kill candidate as a string. @@ -105,20 +125,23 @@ Otherwise, it is the value of the overlay's candidate property. Adjust kill candidate to THING, BEG, END. If BEG is a string, shrink the overlay to zero length and set its candidate property instead. - (let ((o easy-kill-candidate)) + (let* ((o easy-kill-candidate) + (beg (or beg (overlay-start o))) + (end (or end (overlay-end o (overlay-put o 'thing thing) (if (stringp beg) (progn (move-overlay o (point) (point)) (overlay-put o 'candidate beg) (easy-kill-message-nolog %s beg)) - (move-overlay o (or beg (overlay-start o)) (or end (overlay-end o) - (and interprogram-cut-function - (not (string= (easy-kill-candidate) )) - (funcall interprogram-cut-function (easy-kill-candidate + (move-overlay o beg end)) +(cond (easy-kill-mark (easy-kill-mark-region)) + ((and interprogram-cut-function +(not (string= (easy-kill-candidate) ))) + (funcall interprogram-cut-function (easy-kill-candidate)) (defun easy-kill-save-candidate () - (unless (string= (easy-kill-candidate) ) + (unless (or easy-kill-mark (string= (easy-kill-candidate) )) ;; Do not modify the clipboard here because this may be called in ;; `pre-command-hook' and will confuse `yank' if it is the next ;; command. Also `easy-kill-adjust-candidate' already did the @@ -134,8 +157,10 @@ candidate property instead. (defun easy-kill-destroy-candidate () (let ((hook (make-symbol easy-kill-destroy-candidate))) (fset hook (lambda () - (and easy-kill-candidate - (delete-overlay easy-kill-candidate)) + (when easy-kill-candidate + (let ((i (overlay-get easy-kill-candidate 'origin-indicator))) + (and (overlayp i) (delete-overlay i))) + (delete-overlay easy-kill-candidate)) (setq easy-kill-candidate nil) (remove-hook 'post-command-hook hook))) (add-hook 'post-command-hook hook))) @@ -164,16 +189,17 @@ candidate property instead. (start (overlay-start easy-kill-candidate)) (end (overlay-end easy-kill-candidate))) (when thing - (save-excursion -(goto-char end) -(with-demoted-errors - (dotimes (_ (abs n)) -(forward-thing thing direction) -(when (= (point) start) - (forward-thing thing 1) - (return -(when (/= end (point)) - (easy-kill-adjust-candidate thing nil (point)) + (let ((new-end (save-excursion + (goto-char end) + (with-demoted-errors + (dotimes (_ (abs n)) + (forward-thing thing direction) + (when (= (point) start) + (forward-thing thing 1) + (return))) + (point) +(when (/= end new-end) + (easy-kill-adjust-candidate thing nil new-end) t
[elpa] 52/77: Use filter-buffer-substring
leoliu pushed a commit to branch master in repository elpa. commit 5fbfcbf4c60f4343f0881abbeccc1a0f82c71f04 Author: Leo Liu sdl@gmail.com Date: Tue Oct 15 17:43:43 2013 +0800 Use filter-buffer-substring --- easy-kill.el |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/easy-kill.el b/easy-kill.el index fd70a99..2cb7b3a 100644 --- a/easy-kill.el +++ b/easy-kill.el @@ -141,8 +141,8 @@ Otherwise, it is the value of the overlay's candidate property. (with-current-buffer (overlay-buffer easy-kill-candidate) (if (/= (overlay-start easy-kill-candidate) (overlay-end easy-kill-candidate)) - (buffer-substring (overlay-start easy-kill-candidate) - (overlay-end easy-kill-candidate)) + (filter-buffer-substring (overlay-start easy-kill-candidate) + (overlay-end easy-kill-candidate)) (overlay-get easy-kill-candidate 'candidate) (defun easy-kill-adjust-candidate (thing optional beg end)
[elpa] 64/77: Teach easy-kill to handle rectangle-mark from Emacs trunk
leoliu pushed a commit to branch master in repository elpa. commit 33160afb45b718f4a7d8675b5cf81299a6497309 Author: Leo Liu sdl@gmail.com Date: Wed Oct 30 01:53:14 2013 +0800 Teach easy-kill to handle rectangle-mark from Emacs trunk --- easy-kill.el |7 +-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/easy-kill.el b/easy-kill.el index 69448d9..9c2638d 100644 --- a/easy-kill.el +++ b/easy-kill.el @@ -370,7 +370,10 @@ Temporally activate additional key bindings as follows: others = save selection and exit. (interactive p) (if (use-region-p) - (kill-ring-save (region-beginning) (region-end)) + (if (fboundp 'rectangle-mark) + (with-no-warnings ; new in 24.4 +(kill-ring-save (region-beginning) (region-end) t)) +(kill-ring-save (region-beginning) (region-end))) (setq easy-kill-mark nil) (setq easy-kill-append (eq last-command 'kill-region)) (easy-kill-init-candidate n) @@ -477,7 +480,7 @@ inspected. (defun easy-kill-on-nxml-element (n) (let ((nxml-sexp-element-flag t) -(up-list-fn #'nxml-up-element)) +(up-list-fn 'nxml-up-element)) (cond ((memq n '(+ -)) (let ((bounds (easy-kill-bounds-of-list n)))