--- elscreen-1.4.6.orig/QuickStart +++ elscreen-1.4.6/QuickStart @@ -0,0 +1,13 @@ +ElScreen-GF 1.5.3 Quick Start Guide + + 1) Install ElScreen, ElScreen-GF. + 2) Make sure that the grep on your system is GNU-compatible. + 3) Visit a source code you want to read. + 4) Put the cursor on the keyword you want to search. + 5) Type `C-z C-g G', and `RET'. + 6) Select line you want to jump to. + 7) Type `O'. + +ElScreen-GF also supports GNU ID Utils, cscope and GNU GLOBAL as an +external program to search keywords. For more detail, please refer +README file in this tarball. --- elscreen-1.4.6.orig/README.gf +++ elscreen-1.4.6/README.gf @@ -0,0 +1,186 @@ +ElScreen-GF 1.5.3 README file + +This is the distribution of ElScreen-GF 1.5.3, released November 2007. +It is an Emacs interface to GNU grep (or its compatibles), GNU ID +Utils, cscope, and GNU GLOBAL. ElScreen-GF makes it easier to search +keyword or token in source codes, list the results, and jump to them. +This will help you to read or hack source codes, especially in a big +source tree. + +It works with ElScreen 1.4.0 or later, on GNU Emacs 21 or later and +XEmacs 21.4 or later. Enjoy! + + +External Programs +----------------- +ElScreen-GF supports the followings as external program: + + - GNU grep (http://www.gnu.org/software/grep/grep.html) + + grep is famous utility to print lines matching the specified + pattern. GNU grep has several extended features to traditional + grep. Nowadays major state-of-the-art OS may have GNU grep or its + compatible one. + + - GNU ID Utils (http://www.gnu.org/software/idutils/idutils.html) + + This is language-independent (but currently supports C, C++, + Assembly, text. Perl also seems to be supported in the CVS HEAD) + identifier database tool, which stores tokens, literal numbers, or + words of human-readable text. + + - cscope (http://cscope.sourceforge.net/) + + cscope is an interactive tool that allows you to browse through C + source files for specified elements of code. This provides you + the curses-based screen-oriented interface, but ElScreen-GF uses + only line-oriented interface. In addition, ElScreen-GF uses `sort' + to sort its output. + + - GNU GLOBAL (http://www.gnu.org/software/global/) + + GNU GLOBAL is an yet another source code tag system. You can + locate a symbol in the source files. In addition, ElScreen-GF + uses `sort' to sort its output. + + +Files +----- +This package should contain the following files: + + elscreen-gf.el ElScreen-GF 1.5.3 main file. + README Introduction to ElScreen-GF 1.5.3 (this file) + QuickStart Quick Start Guide + + +Installation +------------ +Make sure that you have installed ElScreen. Put elscreen-gf.el in +this directory to your load-path, and put following line just next to +ElScreen entry: + + (load "elscreen-gf" "ElScreen-GF" t) + +As mentioned above, you also have to install one of supported external +programs. Please refer their own manuals for more detail. + + +Usage +----- +The following sequences may valid on ElScreen: + + C-z ElScreen prefix key + C-z C-g ElScreen-GF prefix key + C-z C-g G Run grep + C-z C-g g Run gid (GNU ID Utils) + C-z C-g m Run mkid (GNU ID Utils) + C-z C-g c Run cscope + C-z C-g l Run global (GNU GLOBAL) + C-z C-g t Run gtags (GNU GLOBAL) + C-z C-g u Go back to the point where the previous search + was invoked. + C-z C-g v Show ElScreen-GF version. + +Although a token around the cursor is shown as default value for grep, +gid, cscope and global, you can specify other keyword. Regexp is also +accepted. Once you run grep, gid, cscope or global, ElScreen-GF +buffer is created and becomes active. In this buffer, you may use +following keys: + + n Move cursor to the next entry, vertically down. + p Move cursor to the previous entry, vertically up. + SPC Scroll entries upward full screen. + DEL Scroll entries downward full screen. + < Move cursor to the first entry. + > Move cursor to the last entry. + N Move cursor to the first entry of the next source + file. + P Move cursor to the first entry of the previous + source file. + t Toggle truncated lines. + o Jump to the file and line that the selected entry + specifies. + O Likewise, except the buffer is set to read-only. + C-g Delete running grep, gid, cscope or global process. + q Exit from ElScreen-GF mode. This deletes + ElScreen-GF buffer and its window (or screen when + there is only one window). + v Show ElScreen-GF version. + + +Setup +----- +You can set the following variables to configure ElScreen-GF. These +can be set in .emacs (or .emacs.d/init.el) file directly or "Options" +in your menu bar. + + elscreen-gf-grep-program-name + elscreen-gf-idutils-gid-program-name + elscreen-gf-idutils-mkid-program-name + elscreen-gf-cscope-program-name + elscreen-gf-global-program-name + elscreen-gf-global-gtags-program-name + + Name of external programs. + + elscreen-gf-mode-truncate-lines + + If non nil, each line of result in the ElScreen-GF mode is + shown in truncated manner by default. The default value is + `t'. + + elscreen-gf-invoke-point-history-length + + Maximum number of invoke-point stored by ElScreen-GF. + invoke-point is the location where gf searches were invoked. + + elscreen-gf-mode-selected-entry-face + + Face used for the selected entry in ElScreen-GF mode. + + elscreen-gf-mode-file-name-face + + Face used for file name in ElScreen-GF mode. + + elscreen-gf-mode-line-number-face + + Face used for line number in ElScreen-GF mode. + + elscreen-gf-mode-pattern-face + + Face used to emphasize the specified keyword in ElScreen-GF + mode. + + elscreen-gf-emphasis-after-jump-face + + Face used to emphasize the selected line after jump. + + +Automatic Database Update +------------------------- +You can update `ID' GNU ID Utils database or `GTAGS' GNU GLOBAL +database after saveing buffer with using + + elscreen-gf-idutils-mkid-setup-after-save-hook + elscreen-gf-global-gtags-setup-after-save-hook + +for GNU ID Utils and GNU GLOBAL respectively. For instance, you can +add following lines to update `ID' database when saving C source code: + + (add-hook 'c-mode-hook 'elscreen-gf-idutils-mkid-setup-after-save-hook) + + +Where Can I Get ElScreen-GF? +---------------------------- +ElScreen-GF (and ElScreen) is available from the following anonymous +ftp site. + + ftp://ftp.morishima.net/pub/morishima.net/naoto/ElScreen/ + + +Bug Reports +----------- +ElScreen-GF is maintained by Naoto Morishima. Please mail bug +reports and any comments to: + + naoto@morishima.net --- elscreen-1.4.6.orig/debian/NEWS.Debian +++ elscreen-1.4.6/debian/NEWS.Debian @@ -0,0 +1,9 @@ +elscreen (1.4.5-1) unstable; urgency=low + + From this version, elscreen will not be loaded automatically. Please + add the following to your ~/.emacs.el or such: + + (load "elscreen") + + -- Masayuki Hatta (mhatta) Sun, 29 Apr 2007 08:16:25 +0900 + --- elscreen-1.4.6.orig/debian/README.source +++ elscreen-1.4.6/debian/README.source @@ -0,0 +1 @@ +See /usr/share/doc/dpatch/README.source.gz. \ No newline at end of file --- elscreen-1.4.6.orig/debian/changelog +++ elscreen-1.4.6/debian/changelog @@ -0,0 +1,147 @@ +elscreen (1.4.6-5.3) unstable; urgency=medium + + * Non maintainer upload by the Reproducible Builds team. + * No source change upload to rebuild on buildd with .buildinfo files. + + -- Holger Levsen Tue, 05 Jan 2021 11:58:24 +0100 + +elscreen (1.4.6-5.2) unstable; urgency=low + + * Non-maintainer upload. + * Byte-compilation failed upon apel upgrade as there was no check + whether apel was available before trying to byte-compile + elscreen. Closes: #750967. + + -- Arnaud Fontaine Wed, 16 Jul 2014 13:55:45 +0900 + +elscreen (1.4.6-5.1) unstable; urgency=low + + * Non-maintainer upload. + * 04_fix_last-command-char: From emacs 24.3, last-command-char has been + removed in favor of last-command-event - closes: #705436 + + -- Arnaud Fontaine Wed, 19 Mar 2014 16:41:31 +0900 + +elscreen (1.4.6-5) unstable; urgency=low + + * 03_fix_emacs-command-line.dpatch: Fixed the problem when emacs run + with -nw - closes: #581935 + * Removed wl from Suggests - closes: #578217 + * elscreen-howm: Updated to 0.1.3. + * Bumped Standards-Version to 3.9.1. + + -- Masayuki Hatta (mhatta) Thu, 23 Sep 2010 09:26:10 +0900 + +elscreen (1.4.6-4) unstable; urgency=low + + * Added watch. + + -- Masayuki Hatta (mhatta) Sat, 19 Jul 2008 15:02:03 +0900 + +elscreen (1.4.6-3) unstable; urgency=low + + * Bumped to Standards-Version: 3.8.0. + * Fixed old elisp backquote problem. Thanks noritada - closes: #481438 + + -- Masayuki Hatta (mhatta) Mon, 14 Jul 2008 02:33:23 +0900 + +elscreen (1.4.6-2) unstable; urgency=low + + * Use dpatch. + * 01_older_emacsen_fix.dpatch: replaces "booleanp" function + (introduced in Emacs22) with home-made version - closes: #460610 + + -- Masayuki Hatta (mhatta) Mon, 14 Jan 2008 13:30:37 +0900 + +elscreen (1.4.6-1) unstable; urgency=low + + * New upstream release + + -- Masayuki Hatta (mhatta) Sun, 13 Jan 2008 01:43:06 +0900 + +elscreen (1.4.5-3) unstable; urgency=low + + * Bumped to Standards-Version: 3.7.3. + * Fixed various lintian warnings. + * elscreen-wl.el requires Wanderlust(wl). Making elscreen depend on wl is not what I want to do, so I simply removed it - closes: #454692 + + -- Masayuki Hatta (mhatta) Fri, 07 Dec 2007 14:17:24 +0900 + +elscreen (1.4.5-2) unstable; urgency=low + + * Added elscreen-color-theme.el 0.0.0. + * Added elscreen-dired.el 0.1.0. + * Added elscreen-dnd.el 0.0.0. + * Added elscreen-gf.el 1.5.3. + * Added elscreen-goby.el 0.0.0. + * Added elscreen-howm.el 0.1.0. + * Added elscreen-server.el 0.2.0. + * Added elscreen-speedbar.el 0.0.0. + * Added elscreen-w3m.el 0.2.2. + * Added elscreen-wl.el 0.8.0. + + -- Masayuki Hatta (mhatta) Wed, 05 Dec 2007 15:51:28 +0900 + +elscreen (1.4.5-1) unstable; urgency=low + + * New upstream release. + * Bumped Standards-Version: 3.7.2. + * Commented out auto loading in emacs-startup - closes: #268756 + * NEWS.Debian: Added. + * Changed Build-Depends-Indep to Build-Depends. + + -- Masayuki Hatta (mhatta) Sun, 29 Apr 2007 07:44:44 +0900 + +elscreen (1.4.3-1) unstable; urgency=low + + * Works done at Codefest in Malaysia 2006. + * New upstream release. + * Bumped to Standards-Version: 3.6.2.2 (no physical changes). + + -- Masayuki Hatta (mhatta) Sun, 5 Mar 2006 00:26:21 +0900 + +elscreen (1.3.3-1) unstable; urgency=low + + * New upstream release + * Bumped Standards-Version to 3.6.2.1 (no physical changes). + + -- Masayuki Hatta (mhatta) Wed, 14 Sep 2005 08:35:29 +0900 + +elscreen (1.3.2-1) unstable; urgency=low + + * New upstream release + - elscreen-display-screen-name-list should work now, closes: #273126 + + -- Masayuki Hatta (mhatta) Wed, 8 Dec 2004 02:29:29 +0900 + +elscreen (1.3.1-1) unstable; urgency=high + + * New upstream release + + -- Masayuki Hatta (mhatta) Sat, 14 Aug 2004 18:41:24 +0900 + +elscreen (1.2.4-3) unstable; urgency=low + + * [control] changed Maintainer field. + * Bumped to Standards-Version: 3.6.1. + + -- Masayuki Hatta (mhatta) Wed, 18 Feb 2004 00:35:17 +0900 + +elscreen (1.2.4-2) unstable; urgency=low + + * Updated to Standards-Version: 3.5.6. + + -- Masayuki Hatta Fri, 30 Aug 2002 10:10:41 +0900 + +elscreen (1.2.4-1) unstable; urgency=low + + * New upstream release + + -- Masayuki Hatta Thu, 29 Aug 2002 17:15:21 +0900 + +elscreen (1.2.2-1) unstable; urgency=low + + * Initial Release - closes: #148079 + + -- Masayuki Hatta Sun, 28 Jul 2002 10:04:46 +0900 + --- elscreen-1.4.6.orig/debian/compat +++ elscreen-1.4.6/debian/compat @@ -0,0 +1 @@ +7 --- elscreen-1.4.6.orig/debian/control +++ elscreen-1.4.6/debian/control @@ -0,0 +1,15 @@ +Source: elscreen +Section: utils +Priority: optional +Maintainer: Masayuki Hatta (mhatta) +Build-Depends: debhelper (>> 7.0.50~), dpatch +Standards-Version: 3.9.1 +Homepage: http://www.morishima.net/~naoto/software/elscreen/index.php.en + +Package: elscreen +Architecture: all +Depends: apel, ${misc:Depends} +Suggests: speedbar, w3m-el +Description: Screen for Emacsen + This Emacs Lisp enables you to have multiple screens (window-configuration) + on your Emacsen, just like GNU screen does on the shell environment. --- elscreen-1.4.6.orig/debian/copyright +++ elscreen-1.4.6/debian/copyright @@ -0,0 +1,26 @@ +This package was debianized by Masayuki Hatta on +Sun, 28 Jul 2002 10:11:32 +0900. + +It was downloaded from http://www.morishima.net/~naoto/j/software/elscreen/ + +Upstream Author: Naoto Morishima + +Copyright: Copyright (c) 1997- Naoto Morishima, All Rights Reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301, USA. + +On Debian GNU/Linux systems, the complete text of the GNU General +Public License can be found in `/usr/share/common-licenses/GPL'. --- elscreen-1.4.6.orig/debian/dirs +++ elscreen-1.4.6/debian/dirs @@ -0,0 +1 @@ +usr/share/emacs/site-lisp/elscreen --- elscreen-1.4.6.orig/debian/docs +++ elscreen-1.4.6/debian/docs @@ -0,0 +1,3 @@ +README +README.gf +QuickStart --- elscreen-1.4.6.orig/debian/emacsen-install +++ elscreen-1.4.6/debian/emacsen-install @@ -0,0 +1,46 @@ +#! /bin/sh -e +# /usr/lib/emacsen-common/packages/install/elscreen + +# Written by Jim Van Zandt , borrowing heavily +# from the install scripts for gettext by Santiago Vila +# and octave by Dirk Eddelbuettel . + +FLAVOR=$1 +PACKAGE=elscreen + +if [ ! -f "/usr/share/$FLAVOR/site-lisp/apel/alist.elc" ]; then exit 0; fi +if [ ${FLAVOR} = emacs ]; then exit 0; fi + +echo install/${PACKAGE}: Handling install for emacsen flavor ${FLAVOR} + +#FLAVORTEST=`echo $FLAVOR | cut -c-6` +#if [ ${FLAVORTEST} = xemacs ] ; then +# SITEFLAG="-no-site-file" +#else +# SITEFLAG="--no-site-file" +#fi +FLAGS="${SITEFLAG} -q -batch -l path.el -f batch-byte-compile" + +ELDIR=/usr/share/emacs/site-lisp/${PACKAGE} +ELCDIR=/usr/share/${FLAVOR}/site-lisp/${PACKAGE} + +# Install-info-altdir does not actually exist. +# Maybe somebody will write it. +if test -x /usr/sbin/install-info-altdir; then + echo install/${PACKAGE}: install Info links for ${FLAVOR} + install-info-altdir --quiet --section "" "" --dirname=${FLAVOR} /usr/info/${PACKAGE}.info.gz +fi + +install -m 755 -d ${ELCDIR} +cd ${ELDIR} +FILES=`echo *.el` +cp ${FILES} ${ELCDIR} +cd ${ELCDIR} + +cat << EOF > path.el +(setq load-path (cons "." load-path) byte-compile-warnings nil) +EOF +${FLAVOR} ${FLAGS} ${FILES} +rm -f *.el path.el + +exit 0 --- elscreen-1.4.6.orig/debian/emacsen-remove +++ elscreen-1.4.6/debian/emacsen-remove @@ -0,0 +1,15 @@ +#!/bin/sh -e +# /usr/lib/emacsen-common/packages/remove/elscreen + +FLAVOR=$1 +PACKAGE=elscreen + +if [ ${FLAVOR} != emacs ]; then + if test -x /usr/sbin/install-info-altdir; then + echo remove/${PACKAGE}: removing Info links for ${FLAVOR} + install-info-altdir --quiet --remove --dirname=${FLAVOR} /usr/info/elscreen.info.gz + fi + + echo remove/${PACKAGE}: purging byte-compiled files for ${FLAVOR} + rm -rf /usr/share/${FLAVOR}/site-lisp/${PACKAGE} +fi --- elscreen-1.4.6.orig/debian/emacsen-startup +++ elscreen-1.4.6/debian/emacsen-startup @@ -0,0 +1,17 @@ +;; -*-emacs-lisp-*- +;; +;; Emacs startup file for the Debian GNU/Linux elscreen package +;; +;; Originally contributed by Nils Naumann +;; Modified by Dirk Eddelbuettel +;; Adapted for dh-make by Jim Van Zandt + +;; The elscreen package follows the Debian/GNU Linux 'emacsen' policy and +;; byte-compiles its elisp files for each 'emacs flavor' (emacs19, +;; xemacs19, emacs20, xemacs20...). The compiled code is then +;; installed in a subdirectory of the respective site-lisp directory. +;; We have to add this to the load-path: +(setq load-path (cons (concat "/usr/share/" + (symbol-name flavor) + "/site-lisp/elscreen") load-path)) +;(load "elscreen" "ElScreen" t) --- elscreen-1.4.6.orig/debian/patches/00list +++ elscreen-1.4.6/debian/patches/00list @@ -0,0 +1,4 @@ +01_older_emacsen_fix +02_oldbackquote_fix +03_fix_emacs-command-line +04_fix_last-command-char.dpatch --- elscreen-1.4.6.orig/debian/patches/01_older_emacsen_fix.dpatch +++ elscreen-1.4.6/debian/patches/01_older_emacsen_fix.dpatch @@ -0,0 +1,31 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## 01_older_emacsen_fix.dpatch by Masayuki Hatta (mhatta) +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: Support Emacsen older than 22 + +@DPATCH@ +diff -urNad elscreen-1.4.6~/elscreen.el elscreen-1.4.6/elscreen.el +--- elscreen-1.4.6~/elscreen.el 2007-12-30 00:12:05.000000000 +0900 ++++ elscreen-1.4.6/elscreen.el 2008-01-14 13:33:37.000000000 +0900 +@@ -33,6 +33,11 @@ + (static-defconst elscreen-on-emacs (and (not elscreen-on-xemacs) + (>= emacs-major-version 21))) + ++(defun elscreen-booleanp (value) ++ "Return t if VALUE is boolean. ++ This implements GNU Emacs 22.1's `booleanp' function in earlier Emacs. ++ This function may be removed when Emacs 21 is no longer supported." ++ (or (equal value t) (equal value nil))) + + ;;; User Customizable Variables: + +@@ -133,7 +138,7 @@ + (integer :tag "Show (fixed width tab)" :size 4 :value 16) + (const :tag "Hide" nil)) + :set (lambda (symbol value) +- (when (or (booleanp value) ++ (when (or (elscreen-booleanp value) + (and (numberp value) + (> value 0))) + (custom-set-default symbol value) --- elscreen-1.4.6.orig/debian/patches/02_oldbackquote_fix.dpatch +++ elscreen-1.4.6/debian/patches/02_oldbackquote_fix.dpatch @@ -0,0 +1,33 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## 02_oldbackquote_fix.dpatch by Masayuki Hatta (mhatta) +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: No description. + +@DPATCH@ +diff -urNad elscreen-1.4.6~/elscreen-dnd.el elscreen-1.4.6/elscreen-dnd.el +--- elscreen-1.4.6~/elscreen-dnd.el 2008-01-14 13:32:20.000000000 +0900 ++++ elscreen-1.4.6/elscreen-dnd.el 2008-07-14 02:36:55.000000000 +0900 +@@ -34,10 +34,10 @@ + ;; Code: + + (defmacro elscreen-dnd-drag-n-drop (ad-do-it) +- (` (progn ++ `(progn + (elscreen-notify-screen-modification-suppress +- (, ad-do-it)) +- (elscreen-notify-screen-modification 'force)))) ++ ,ad-do-it) ++ (elscreen-notify-screen-modification 'force))) + + (defadvice dnd-handle-one-url (around elscreen-dnd-handle-open-url activate) + (if (not elscreen-dnd-open-file-new-screen) +@@ -53,6 +53,6 @@ + + (mapc + (lambda (drag-n-drop-function) +- (eval (` (defadvice (, drag-n-drop-function) (around elscreen-dnd-drag-n-drop activate) +- (elscreen-dnd-drag-n-drop ad-do-it))))) ++ (eval `(defadvice (, drag-n-drop-function) (around elscreen-dnd-drag-n-drop activate) ++ (elscreen-dnd-drag-n-drop ad-do-it)))) + (list 'x-dnd-handle-drag-n-drop-event 'mac-drag-n-drop 'w32-drag-n-drop)) --- elscreen-1.4.6.orig/debian/patches/03_fix_emacs-command-line.dpatch +++ elscreen-1.4.6/debian/patches/03_fix_emacs-command-line.dpatch @@ -0,0 +1,47 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## 03_fix_emacs-command-line.dpatch by Youhei SASAKI +## +## DP: fix handling commandline arguments, see elscreen-ml +## DP: http://www.heimat.gr.jp/pipermail/elips/2010/001976.html + +@DPATCH@ +diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' elscreen-1.4.6~/elscreen.el elscreen-1.4.6/elscreen.el +--- elscreen-1.4.6~/elscreen.el 2010-06-04 01:07:56.000000000 +0900 ++++ elscreen-1.4.6/elscreen.el 2010-06-04 01:08:57.000000000 +0900 +@@ -1691,6 +1691,8 @@ + ("-e" . elscreen-command-line-funcall)))) + + (static-when elscreen-on-emacs ++ (if (string-match "^\\(19\\|2[0-2]\\)" emacs-version) ; emacs22 or prior-to ++ (progn + (defun elscreen-e21-command-line () + (when (string-match "\\`-" argi) + (error "Unknown option `%s'" argi)) +@@ -1708,6 +1710,27 @@ + (add-hook 'after-init-hook (lambda () + (add-to-list 'command-line-functions + 'elscreen-e21-command-line t)))) ++ ; else ++ (progn ++ (defun elscreen-e23-command-line () ++ (when (string-match "\\`-" argi) ++ (error "Unknown option `%s'" argi)) ++ (setq file-count (1+ file-count)) ++ (setq inhibit-startup-buffer-menu t) ++ (let* ((file ++ (expand-file-name ++ (command-line-normalize-file-name orig-argi) ++ cl1-dir))) ++ (elscreen-command-line-find-file file file-count cl1-line cl1-column)) ++ (setq cl1-line 0) ++ (setq cl1-column 0) ++ t) ; defun ++ ++ (add-hook 'after-init-hook (lambda () ++ (add-to-list 'command-line-functions ++ 'elscreen-e23-command-line t)))) ++ ); endif ++ ) + + (static-when elscreen-on-xemacs + (defadvice command-line-1 (around elscreen-xmas-command-line-1 activate) --- elscreen-1.4.6.orig/debian/patches/04_fix_last-command-char.dpatch +++ elscreen-1.4.6/debian/patches/04_fix_last-command-char.dpatch @@ -0,0 +1,30 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## 04_fix_last-command-char.dpatch by Arnaud Fontaine +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: last-command-char has been removed in Emacs 24.3 + +@DPATCH@ +--- elscreen-1.4.6~/elscreen.el 2013-04-15 09:29:42.722789497 +0900 ++++ elscreen-1.4.6~/elscreen.el 2013-04-15 09:30:31.483311940 +0900 +@@ -306,6 +306,11 @@ + + ;;; Internal Functions: + ++(defun elscreen-last-command-char () ++ (if (featurep 'xemacs) ++ (event-to-character last-command-event) ++ last-command-event)) ++ + (defvar elscreen-frame-confs nil + "Alist that contains the information about screen configurations.") + +@@ -989,7 +994,7 @@ + (defun elscreen-jump () + "Switch to specified screen." + (interactive) +- (let ((next-screen (string-to-number (string last-command-char)))) ++ (let ((next-screen (string-to-number (string (elscreen-last-command-char))))) + (if (and (<= 0 next-screen) (<= next-screen 9)) + (elscreen-goto next-screen)))) + (defalias 'elscreen-jump-0 'elscreen-jump) --- elscreen-1.4.6.orig/debian/rules +++ elscreen-1.4.6/debian/rules @@ -0,0 +1,103 @@ +#!/usr/bin/make -f +# Sample debian/rules that uses debhelper. +# GNU copyright 1997 to 1999 by Joey Hess. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +# Include dpatch stuff. +include /usr/share/dpatch/dpatch.make + +ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS))) + CFLAGS += -g +endif +ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) + INSTALL_PROGRAM += -s +endif + +configure: configure-stamp +configure-stamp: + dh_testdir + # Add here commands to configure the package. + + touch configure-stamp + + +build: patch build-stamp + +build-stamp: configure-stamp + dh_testdir + + # Add here commands to compile the package. + #$(MAKE) + #/usr/bin/docbook-to-man debian/elscreen.sgml > elscreen.1 + + touch build-stamp + +clean: unpatch + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + + # Add here commands to clean up after the build process. + #-$(MAKE) clean + + dh_clean + +install: build + dh_testdir + dh_testroot + dh_prep + dh_installdirs + + # Add here commands to install the package into debian/elscreen. + #$(MAKE) install DESTDIR=$(CURDIR)/debian/elscreen + install -m 644 elscreen.el $(CURDIR)/debian/elscreen/usr/share/emacs/site-lisp/elscreen/ + # Add-ons + install -m 644 elscreen-color-theme.el $(CURDIR)/debian/elscreen/usr/share/emacs/site-lisp/elscreen/ + install -m 644 elscreen-dired.el $(CURDIR)/debian/elscreen/usr/share/emacs/site-lisp/elscreen/ + install -m 644 elscreen-dnd.el $(CURDIR)/debian/elscreen/usr/share/emacs/site-lisp/elscreen/ + install -m 644 elscreen-gf.el $(CURDIR)/debian/elscreen/usr/share/emacs/site-lisp/elscreen/ + install -m 644 elscreen-goby.el $(CURDIR)/debian/elscreen/usr/share/emacs/site-lisp/elscreen/ + install -m 644 elscreen-howm.el $(CURDIR)/debian/elscreen/usr/share/emacs/site-lisp/elscreen/ + install -m 644 elscreen-server.el $(CURDIR)/debian/elscreen/usr/share/emacs/site-lisp/elscreen/ + install -m 644 elscreen-speedbar.el $(CURDIR)/debian/elscreen/usr/share/emacs/site-lisp/elscreen/ + install -m 644 elscreen-w3m.el $(CURDIR)/debian/elscreen/usr/share/emacs/site-lisp/elscreen/ + + +# Build architecture-independent files here. +binary-indep: build install + dh_testdir -i + dh_testroot -i +# dh_installdebconf + dh_installdocs -i +# dh_installexamples +# dh_installmenu +# dh_installlogrotate + dh_installemacsen -i +# dh_installpam +# dh_installmime +# dh_installinit +# dh_installcron +# dh_installman +# dh_installinfo +# dh_undocumented + dh_installchangelogs -i ChangeLog + dh_link -i + dh_strip -i + dh_compress -i + dh_fixperms -i +# dh_makeshlibs + dh_installdeb -i +# dh_perl + dh_shlibdeps -i + dh_gencontrol -i + dh_md5sums -i + dh_builddeb -i + +# Build architecture-dependent files here. +binary-arch: build install +# We have nothing to do by default. + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure --- elscreen-1.4.6.orig/debian/watch +++ elscreen-1.4.6/debian/watch @@ -0,0 +1,2 @@ +version=3 +ftp://ftp.morishima.net/pub/morishima.net/naoto/ElScreen/elscreen-([\d+\.]+).tar.gz debian uupdate --- elscreen-1.4.6.orig/elscreen-color-theme.el +++ elscreen-1.4.6/elscreen-color-theme.el @@ -0,0 +1,126 @@ +;; -*- Mode: Emacs-Lisp -*- +;; +;; elscreen-color-theme.el +;; +(defconst elscreen-color-theme-version "0.0.0 (November 19, 2007)") +;; +;; Author: Naoto Morishima +;; Created: November 19, 2007 + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2, or (at your option) +;; any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program; see the file COPYING. If not, write to +;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + +(provide 'elscreen-color-theme) +(require 'elscreen) + +(defcustom elscreen-color-theme-override-theme nil + "Non-nil to override theme's faces" + :type 'boolean + :group 'color-theme) + +(defcustom elscreen-color-theme-tab-background-face-function + 'elscreen-color-theme-tab-background-face-default-function + "Function to generate a face for background of the tabs of ElScreen." + :type 'function + :group 'color-theme) + +(defcustom elscreen-color-theme-tab-control-face-function + 'elscreen-color-theme-tab-control-face-default-function + "Function to generate a face for the control tab of ElScreen." + :type 'function + :group 'color-theme) + +(defcustom elscreen-color-theme-tab-current-screen-face-function + 'elscreen-color-theme-tab-current-screen-face-default-function + "Function to generate a face for the current tab of ElScreen." + :type 'function + :group 'color-theme) + +(defcustom elscreen-color-theme-tab-other-screen-face-function + 'elscreen-color-theme-tab-other-screen-face-default-function + "Function to generate a face for inactive tabs of ElScreen." + :type 'function + :group 'color-theme) + +(defsubst elscreen-color-theme-generate-color (color weight) + (let* ((max-value (car (color-values "white"))) + (dividing-value (round (/ max-value 2))) + (unit-value (round (/ dividing-value 16)))) + (apply 'format "#%02x%02x%02x" + (mapcar + (lambda (value) + (let* ((sign (if (< dividing-value value) -1 1)) + (adjustment (* sign unit-value weight))) + (+ value adjustment))) + (color-values color))))) + +(defun elscreen-color-theme-tab-background-face-default-function (theme) + (let* ((params (color-theme-frame-params theme)) + (background (cdr (assoc 'background-color params))) + (faces + (when background + `(:background + ,(elscreen-color-theme-generate-color background 8))))) + (when faces `((t ,faces))))) + +(defun elscreen-color-theme-tab-control-face-default-function (theme) + (let* ((params (color-theme-frame-params theme)) + (foreground (cdr (assoc 'foreground-color params))) + (background (cdr (assoc 'background-color params))) + (faces (nconc + (when foreground `(:foreground ,foreground)) + (when background `(:background ,background))))) + (when faces `((t ,faces))))) + +(defalias 'elscreen-color-theme-tab-current-screen-face-default-function + 'elscreen-color-theme-tab-control-face-default-function) + +(defun elscreen-color-theme-tab-other-screen-face-default-function (theme) + (let* ((params (color-theme-frame-params theme)) + (foreground (cdr (assoc 'foreground-color params))) + (background (cdr (assoc 'background-color params))) + (faces (nconc + (when foreground + `(:foreground + ,(elscreen-color-theme-generate-color foreground 12))) + (when background + `(:background + ,(elscreen-color-theme-generate-color background 4)))))) + (when faces `((t ,faces))))) + +(defadvice color-theme-install (around elscreen-color-theme-install activate) + (let* ((theme-faces (color-theme-faces (color-theme-canonic theme))) + (elscreen-faces + (delete nil + (mapcar + (lambda (face-name) + (unless (and (not elscreen-color-theme-override-theme) + (assoc face-name theme-faces)) + (let* ((face-fn + (symbol-value + (intern + (concat (replace-regexp-in-string + "^elscreen" + "elscreen-color-theme" + (symbol-name face-name)) + "-function")))) + (faces (funcall face-fn theme))) + (when faces (list face-name faces))))) + '(elscreen-tab-background-face + elscreen-tab-control-face + elscreen-tab-current-screen-face + elscreen-tab-other-screen-face))))) + ad-do-it + (when elscreen-faces + (color-theme-install-faces elscreen-faces)))) --- elscreen-1.4.6.orig/elscreen-dired.el +++ elscreen-1.4.6/elscreen-dired.el @@ -0,0 +1,38 @@ +;; -*- Mode: Emacs-Lisp -*- +;; +;; elscreen-dired.el +;; +(defconst elscreen-dired-version "0.1.0 (November 6, 2005)") +;; +;; Author: Naoto Morishima +;; Created: August 9, 2004 +;; Revised: November 6, 2005 + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2, or (at your option) +;; any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program; see the file COPYING. If not, write to +;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + +(provide 'elscreen-dired) +(require 'elscreen) + + +;;; Code: + +(defadvice dired-find-file-other-window (around elscreen-dired-find-file-other-window activate) + (let ((window-configuration (current-window-configuration)) + (buffer nil)) + ad-do-it + (unless (eq major-mode 'dired-mode) + (setq buffer (current-buffer)) + (set-window-configuration window-configuration) + (elscreen-find-and-goto-by-buffer buffer t)))) --- elscreen-1.4.6.orig/elscreen-dnd.el +++ elscreen-1.4.6/elscreen-dnd.el @@ -0,0 +1,58 @@ +;; -*- Mode: Emacs-Lisp -*- +;; +;; elscreen-dnd.el +;; +(defconst elscreen-dnd-version "0.0.0 (December 15, 2005)") +;; +;; Author: Hideyuki Shirai +;; Naoto Morishima +;; Created: December 15, 2005 + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2, or (at your option) +;; any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program; see the file COPYING. If not, write to +;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + +(provide 'elscreen-dnd) +(require 'elscreen) + +(defcustom elscreen-dnd-open-file-new-screen t + "If non-nil, always create new screen to open dropped files." + :type 'boolean + :group 'dnd) + + +;; Code: + +(defmacro elscreen-dnd-drag-n-drop (ad-do-it) + (` (progn + (elscreen-notify-screen-modification-suppress + (, ad-do-it)) + (elscreen-notify-screen-modification 'force)))) + +(defadvice dnd-handle-one-url (around elscreen-dnd-handle-open-url activate) + (if (not elscreen-dnd-open-file-new-screen) + ad-do-it + (let ((dnd-open-file-other-window nil) + file-buffer) + (save-window-excursion + ad-do-it + (setq file-buffer (current-buffer))) + (if (elscreen-screen-modified-p 'dnd-handle-one-url) + (elscreen-find-and-goto-by-buffer file-buffer 'create) + (elscreen-find-screen-by-buffer file-buffer 'create))))) + +(mapc + (lambda (drag-n-drop-function) + (eval (` (defadvice (, drag-n-drop-function) (around elscreen-dnd-drag-n-drop activate) + (elscreen-dnd-drag-n-drop ad-do-it))))) + (list 'x-dnd-handle-drag-n-drop-event 'mac-drag-n-drop 'w32-drag-n-drop)) --- elscreen-1.4.6.orig/elscreen-gf.el +++ elscreen-1.4.6/elscreen-gf.el @@ -0,0 +1,1022 @@ +;; -*- Mode: Emacs-Lisp -*- +;; +;; elscreen-gf.el +;; +(defconst elscreen-gf-version "1.5.3 (November 07, 2007)") +;; +;; Author: Naoto Morishima +;; Based on: grep-family.el +;; by Youki Kadobayashi +;; Created: June 23, 1996 +;; Revised: November 07, 2007 + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2, or (at your option) +;; any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program; see the file COPYING. If not, write to +;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + +(provide 'elscreen-gf) +(require 'elscreen) +(require 'poe) +(eval-when-compile + (require 'static)) + +;;; User Customizable Variables: + +(defgroup elscreen-gf nil + "ElScreen-GF -- Grep Family on ElScreen" + :tag "ElScreen-GF" + :group 'tools) + +(defcustom elscreen-gf-grep-program-name "grep" + "Program invoked by \\[elscreen-gf-grep] command." + :type 'string + :group 'elscreen-gf) + +(defcustom elscreen-gf-idutils-gid-program-name "gid" + "Program invoked by \\[elscreen-gf-idutils-gid] command." + :type 'string + :group 'elscreen-gf) + +(defcustom elscreen-gf-idutils-mkid-program-name "mkid" + "Program invoked by \\[elscreen-gf-idutils-mkid] command." + :type 'string + :group 'elscreen-gf) + +(defcustom elscreen-gf-cscope-program-name "cscope" + "Program invoked by \\[elscreen-gf-cscope] command." + :type 'string + :group 'elscreen-gf) + +(defcustom elscreen-gf-global-program-name "global" + "Program invoked by \\[elscreen-gf-global] command." + :type 'string + :group 'elscreen-gf) + +(defcustom elscreen-gf-global-gtags-program-name "gtags" + "Program invoked by \\[elscreen-gf-global-gtags] command." + :type 'string + :group 'elscreen-gf) + +(defcustom elscreen-gf-mode-truncate-lines t + "If non-nil, truncate each line in ElScreen-GF mode." + :tag "Truncate lines in ElScreen-GF mode." + :type 'boolean + :group 'elscreen-gf) + +(defcustom elscreen-gf-invoke-point-history-length 8 + "Length of histories for the locations where gf searchs were invoked." + :tag "Length of histries for invoke-point." + :type '(integer :size 4) + :set (lambda (symbol value) + (when (and (numberp value) + (>= value 4) + (<= value 64)) + (custom-set-default symbol value) + (let ((old-history (when (boundp 'elscreen-gf-invoke-point-history) + elscreen-gf-invoke-point-history))) + (setq elscreen-gf-invoke-point-history (make-ring value)) + (when (and old-history (ring-p old-history)) + (while (and (not (ring-empty-p old-history)) + (< (ring-length elscreen-gf-invoke-point-history) + value)) + (ring-insert-at-beginning elscreen-gf-invoke-point-history + (ring-remove old-history 0))))))) + :group 'elscreen-gf) + +(defface elscreen-gf-mode-selected-entry-face + '((t (:underline t))) + "Face used for the selected entry in ElScreen-GF mode." + :group 'elscreen-gf) + +(defface elscreen-gf-mode-file-name-face + '((((class color) (background dark)) + (:foreground "khaki" :bold t)) + (((class color) (background light)) + (:foreground "DarkSlateBlue" :bold t)) + (t (:bold t))) + "Face used for file name in ElScreen-GF mode." + :group 'elscreen-gf) + +(defface elscreen-gf-mode-line-number-face + '((((class color) (background dark)) + (:foreground "gray" :bold t)) + (((class color) (background light)) + (:foreground "gray50" :bold t)) + (t (:bold t))) + "Face used for line number in ElScreen-GF mode." + :group 'elscreen-gf) + +(defface elscreen-gf-mode-pattern-face + '((((class color) (background dark)) + (:foreground "tomato" :bold t)) + (((class color) (background light)) + (:foreground "tomato" :bold t)) + (t (:bold t))) + "Face used to emphasize the specified keyword in ElScreen-GF mode." + :group 'elscreen-gf) + +(defface elscreen-gf-emphasis-after-jump-face + '((((class color) (background light)) + (:background "LightSteelBlue1")) + (((class color) (background dark)) + (:background "SteelBlue")) + (t (:bold t))) + "Face used to emphasize the selected line after jump." + :group 'elscreen-gf) + +;;; Key bindings: + +(defvar elscreen-gf-map (make-sparse-keymap) + "Keymap for elscreen-gf.") +(define-key elscreen-gf-map "G" 'elscreen-gf-grep) +(define-key elscreen-gf-map "m" 'elscreen-gf-idutils-mkid) +(define-key elscreen-gf-map "g" 'elscreen-gf-idutils-gid) +(define-key elscreen-gf-map "c" 'elscreen-gf-cscope) +(define-key elscreen-gf-map "t" 'elscreen-gf-global-gtags) +(define-key elscreen-gf-map "l" 'elscreen-gf-global) +(define-key elscreen-gf-map "u" 'elscreen-gf-go-back-to-latest-invoke-point) +(define-key elscreen-gf-map "v" 'elscreen-gf-display-version) + +(define-key elscreen-map "\C-g" elscreen-gf-map) + +(defvar elscreen-gf-mode-map (make-sparse-keymap) + "keymap used in elscreen-gf mode.") +(define-key elscreen-gf-mode-map "n" 'elscreen-gf-mode-next-line) +(define-key elscreen-gf-mode-map "p" 'elscreen-gf-mode-previous-line) +(define-key elscreen-gf-mode-map " " 'elscreen-gf-mode-scroll-up) +(define-key elscreen-gf-mode-map "\177" 'elscreen-gf-mode-scroll-down) +(define-key elscreen-gf-mode-map "<" 'elscreen-gf-mode-beginning-of-buffer) +(define-key elscreen-gf-mode-map ">" 'elscreen-gf-mode-end-of-buffer) +(define-key elscreen-gf-mode-map "N" 'elscreen-gf-mode-next-file) +(define-key elscreen-gf-mode-map "P" 'elscreen-gf-mode-previous-file) +(define-key elscreen-gf-mode-map "t" 'elscreen-gf-mode-truncate-lines-toggle) +(define-key elscreen-gf-mode-map "o" 'elscreen-gf-mode-jump-to-entry) +(define-key elscreen-gf-mode-map "O" 'elscreen-gf-mode-jump-to-entry-read-only) +(define-key elscreen-gf-mode-map "\C-g" 'elscreen-gf-mode-search-quit) +(define-key elscreen-gf-mode-map "q" 'elscreen-gf-mode-exit) +(define-key elscreen-gf-mode-map "v" 'elscreen-gf-display-version) + + +;;; Internal Functions and Variables: + +(defvar elscreen-gf-invoke-point-history + (make-ring elscreen-gf-invoke-point-history-length)) + +(eval-when-compile + (defun-maybe line-number-at-pos (&optional pos) + (let ((opoint (or pos (point)))) + (save-excursion + (goto-char opoint) + (forward-line 0) + (1+ (count-lines (point-min) (point))))))) + +(defsubst elscreen-gf-overlay-create (start end face) + (let ((overlay (make-overlay start end))) + (overlay-put overlay 'face face) + (overlay-put overlay 'evaporate t) + overlay)) + +(defsubst elscreen-gf-move-overlay-create (overlay-symbol start end face) + (let ((overlay (condition-case nil + (symbol-value overlay-symbol) + (error nil)))) + (if (overlayp overlay) + (move-overlay overlay start end (current-buffer)) + (set overlay-symbol (elscreen-gf-overlay-create start end face)) + (setq overlay (symbol-value overlay-symbol))) + overlay)) + +(defun elscreen-gf-define-major-mode-token (major-mode token-chars) + (let ((thing-symbol (intern (format "%s-thing" (symbol-name major-mode))))) + (put major-mode 'elscreen-gf-major-mode-thing thing-symbol) + (put thing-symbol 'token-chars token-chars) + (put thing-symbol 'end-op + `(lambda () + (re-search-forward (concat "\\=[" ,token-chars "]*") nil t))) + (put thing-symbol 'beginning-op + `(lambda () + (if (re-search-backward (concat "[^" ,token-chars "]") nil t) + (forward-char) + (goto-char (point-min))))))) + +(elscreen-gf-define-major-mode-token 'c-mode "a-zA-Z0-9_") +(elscreen-gf-define-major-mode-token 'perl-mode "a-zA-Z0-9_") +(elscreen-gf-define-major-mode-token 'emacs-lisp-mode "-a-zA-Z0-9/+:<>") + +(defsubst elscreen-gf-major-mode-token-chars (major-mode) + (get (get major-mode 'elscreen-gf-major-mode-thing) 'token-chars)) + +(defsubst elscreen-gf-db-directory (file-name &optional directory) + (let ((directory (expand-file-name + (or directory + (and (buffer-file-name) + (file-name-directory (buffer-file-name))) + default-directory))) + (previous-directory nil)) + (catch 'found + (while (and directory + (not (and previous-directory + (string= directory previous-directory)))) + (if (file-exists-p (concat directory file-name)) + (throw 'found directory)) + (setq previous-directory directory) + (setq directory (file-name-directory + (directory-file-name directory))))))) + + +;;; ElScreen-GF mode + +(defconst elscreen-gf-mode-to-nickname-alist + '(("^elscreen-gf-mode$" . (lambda () + (format "ElScreen-GF%s" + (if (and (elscreen-gf-process-exclusive-p + elscreen-gf-idutils-mkid-process + 'noerror) + (elscreen-gf-process-exclusive-p + elscreen-gf-global-gtags-process + 'noerror)) + "" " (!)"))))) + "*Alist composed of the pair of mode-name and corresponding screen-name.") +(elscreen-set-mode-to-nickname-alist 'elscreen-gf-mode-to-nickname-alist) + +(defun elscreen-gf-goto-screen-create (target-directory) + (let ((buffer (get-buffer-create "ElScreen-GF"))) + (elscreen-find-and-goto-by-buffer buffer 'create) + (switch-to-buffer buffer) + (elscreen-gf-mode target-directory) + (let ((buffer-read-only nil)) + (erase-buffer)))) + +(defvar elscreen-gf-pattern) +(defvar elscreen-gf-invoke-point) +(defvar elscreen-gf-filter-odd-string) +(defvar elscreen-gf-selected-entry-overlay) +(defun elscreen-gf-mode (target-directory) + "Major mode for jumping to the entries. + +Key bindings: +\\{elscreen-gf-mode-map}" + (setq major-mode 'elscreen-gf-mode) + (setq mode-name "ElScreen-GF") + (use-local-map elscreen-gf-mode-map) + (setq buffer-read-only t) + (setq case-fold-search nil) + (setq truncate-lines elscreen-gf-mode-truncate-lines) + (set (make-local-variable 'elscreen-gf-pattern) nil) + (set (make-local-variable 'elscreen-gf-invoke-point) nil) + (set (make-local-variable 'elscreen-gf-filter-odd-string) nil) + (set (make-local-variable 'elscreen-gf-selected-entry-overlay) nil) + (setq default-directory target-directory) + + (auto-fill-mode nil)) + +(defun elscreen-gf-mode-selected-entry-overlay () + (elscreen-gf-move-overlay-create + 'elscreen-gf-selected-entry-overlay + (point-at-bol) (point-at-eol) + 'elscreen-gf-mode-selected-entry-face)) + +(defun elscreen-gf-mode-next-line () + "Move the current entry vertically down." + (interactive) + (let ((current-line (line-number-at-pos))) + (cond + ((< current-line 4) + (goto-line 4)) + ((< current-line (line-number-at-pos (point-max))) + (forward-line 1))) + (elscreen-gf-mode-selected-entry-overlay))) + +(defun elscreen-gf-mode-previous-line () + "Move the current entry vertically up." + (interactive) + (let ((current-line (line-number-at-pos))) + (cond + ((< 4 current-line) + (forward-line -1)) + (t + (goto-line 4))) + (elscreen-gf-mode-selected-entry-overlay))) + +(defun elscreen-gf-mode-scroll-up () + "Scroll entries upward full screen." + (interactive) + (scroll-up) + (elscreen-gf-mode-selected-entry-overlay)) + +(defun elscreen-gf-mode-scroll-down () + "Scroll entries downward full screen." + (interactive) + (scroll-down) + (elscreen-gf-mode-selected-entry-overlay)) + +(defun elscreen-gf-mode-beginning-of-buffer () + "Move the current entry to the beginning of the entries." + (interactive) + (goto-line 4) + (elscreen-gf-mode-selected-entry-overlay)) + +(defun elscreen-gf-mode-end-of-buffer () + "Move the current entry to the end of the entries." + (interactive) + (goto-char (point-max)) + (forward-line -1) + (elscreen-gf-mode-selected-entry-overlay)) + +(defun elscreen-gf-mode-next-file () + (interactive) + (cond + ((save-excursion + (beginning-of-line) + (looking-at "^\\([^:\n]+\\):\\([0-9]+\\):")) + (let ((file-name (match-string 1))) + (goto-char (point-max)) + (re-search-backward (concat "^" file-name ":")) + (forward-line))) + (t + (re-search-forward "^\\([^:\n]+\\):\\([0-9]+\\):" nil t) + (beginning-of-line))) + (elscreen-gf-mode-selected-entry-overlay)) + +(defun elscreen-gf-mode-previous-file () + (interactive) + (cond + ((save-excursion + (beginning-of-line) + (looking-at "^\\([^:\n]+\\):\\([0-9]+\\):")) + (let ((file-name (match-string 1))) + (goto-char (point-min)) + (re-search-forward (concat "^" file-name ":")) + (forward-line -1) + (beginning-of-line))) + (t + (re-search-backward "^\\([^:\n]+\\):\\([0-9]+\\):" nil t))) + (when (looking-at "^\\([^:\n]+\\):\\([0-9]+\\):") + (let ((file-name (match-string 1))) + (goto-char (point-min)) + (re-search-forward (concat "^" file-name ":")) + (beginning-of-line))) + (elscreen-gf-mode-selected-entry-overlay)) + +(defun elscreen-gf-mode-truncate-lines-toggle () + "Toggle truncated lines." + (interactive) + (let ((window-start (window-start)) + (line-number-in-window 0)) + (beginning-of-line) + (save-excursion + (while (> (point) window-start) + (setq line-number-in-window (1+ line-number-in-window)) + (vertical-motion -1))) + (setq truncate-lines (not truncate-lines)) + (recenter line-number-in-window))) + +(defvar elscreen-gf-emphasis-after-jump-overlay nil) +(defun elscreen-gf-mode-jump-to-entry () + "Jump to the current entry." + (interactive) + (when (save-excursion + (beginning-of-line) + (looking-at "^\\([^:\n]+\\):\\([0-9]+\\):")) + (when (not (eq (marker-buffer (cdr elscreen-gf-invoke-point)) + (current-buffer))) + (ring-insert elscreen-gf-invoke-point-history elscreen-gf-invoke-point)) + (let ((file-name (match-string 1)) + (line (string-to-number (match-string 2))) + (pattern elscreen-gf-pattern) + token-chars nontoken-chars) + (isearch-update-ring pattern) + (elscreen-find-file file-name) + (setq token-chars + (or (elscreen-gf-major-mode-token-chars major-mode) + (elscreen-gf-major-mode-token-chars 'elscreen-gf-mode) + "a-zA-Z0-9")) + (setq nontoken-chars (format "[^%s]" token-chars)) + (goto-line line) + (let ((case-fold-search nil)) + (goto-char (or (and (re-search-forward + (format "\\(^\\|%s\\)\\(%s\\)\\(%s\\|$\\)" + nontoken-chars pattern nontoken-chars) + (point-at-eol) t) + (match-beginning 2)) + (and (search-forward pattern (point-at-eol) t) + (match-beginning 0)) + (point-at-bol)))) + (elscreen-gf-move-overlay-create 'elscreen-gf-emphasis-after-jump-overlay + (point-at-bol) (point-at-eol) + 'elscreen-gf-emphasis-after-jump-face)))) + +(defun elscreen-gf-mode-jump-to-entry-read-only () + (interactive) + (elscreen-gf-mode-jump-to-entry) + (toggle-read-only 'read-only)) + +(defun elscreen-gf-mode-search-quit (&optional force) + (interactive) + (when (and (not (elscreen-gf-process-exclusive-p + elscreen-gf-search-process 'noerror)) + (or force + (yes-or-no-p + (format "Really quit %s? " + (process-name elscreen-gf-search-process))))) + (delete-process elscreen-gf-search-process))) + +(defun elscreen-gf-mode-exit () + (interactive) + (let* ((current-screen (elscreen-get-current-screen)) + (buffer (get-buffer "ElScreen-GF")) + (screen (when (buffer-live-p buffer) + (elscreen-find-screen-by-buffer buffer)))) + (when screen + (elscreen-goto-internal screen) + (mapc + (lambda (window) + (if (one-window-p) + (elscreen-kill screen) + (delete-window window))) + (get-buffer-window-list buffer))) + (when buffer + (kill-buffer buffer)) + (when (elscreen-screen-live-p screen) + (elscreen-set-window-configuration + screen (elscreen-current-window-configuration))) + (when (elscreen-screen-live-p current-screen) + (elscreen-goto-internal current-screen)))) + +;;; Fundamental functions shared among GNU grep/GNI ID Utils/cscope/GNU global + +(defsubst elscreen-gf-process-exclusive-p (process &optional noerror) + (let ((exclusive-p (not (and (processp process) + (eq (process-status process) 'run))))) + (when (not (or exclusive-p noerror)) + (message "Sorry, %s is running now. Try again later." + (process-name process))) + exclusive-p)) + +(defsubst elscreen-gf-search-token-at-point () + (let* ((thing (or (get major-mode 'elscreen-gf-major-mode-thing) 'word)) + (thing-at-point (or (thing-at-point thing) ""))) + (set-text-properties 0 (length thing-at-point) nil thing-at-point) + thing-at-point)) + +(defvar elscreen-gf-search-pattern-history nil) +(defsubst elscreen-gf-search-read-pattern (prompt &optional pattern-default) + (let* ((pattern-default (or pattern-default + (elscreen-gf-search-token-at-point) + ""))) + (read-string prompt (cons pattern-default 0) + 'elscreen-gf-search-pattern-history))) + +(defun elscreen-gf-search-regexp-dot-to-token (regexp token) + (let ((index 0) + (token-length (length token))) + (save-match-data + (while (setq index (string-match "\\." regexp index)) + (if (and (/= index 0) + (string= (substring regexp (1- index) index) "\\")) + (setq index (1+ index)) + (setq regexp (concat (substring regexp 0 index) + token + (substring regexp (1+ index)))) + (setq index (+ index token-length)))))) + regexp) + +(defun elscreen-gf-read-selection (title prompt option-defs) + (let ((candidate-buffer (generate-new-buffer " *ElScreen-GF-Read-Selection*")) + candidate-window-height + (minibuffer-map (copy-keymap minibuffer-local-map)) + window frame-last-window mini-hist) + ;; prepare candidate buffer + (with-current-buffer candidate-buffer + (setq buffer-read-only t) + (let ((buffer-read-only nil)) + (erase-buffer) + (insert title "\n" + (mapconcat + (lambda (option-def) + (apply 'format " %s) %s\n" option-def)) + option-defs nil)) + (goto-char (point-min)) + (save-excursion + (while (not (eobp)) + (when (looking-at "^ \\([0-9a-z]\\)) .*$") + (put-text-property + (match-beginning 1) (match-end 1) 'face 'bold)) + (forward-line 1))) + (setq candidate-window-height (line-number-at-pos (point-max))) + (set-buffer-modified-p nil))) + ;; prepare candidate window + (save-window-excursion + (setq frame-last-window + (previous-window (static-if elscreen-on-xemacs + (frame-highest-window) + (frame-first-window)))) + (while (minibuffer-window-active-p frame-last-window) + (setq frame-last-window (previous-window frame-last-window))) + (while (and (not (one-window-p)) + (or (< (window-width frame-last-window) + (frame-width)) + (< (window-height frame-last-window) + (+ candidate-window-height window-min-height)))) + (setq window frame-last-window) + (setq frame-last-window (previous-window window)) + (delete-window window)) + (select-window (split-window frame-last-window)) + (shrink-window (- (window-height) candidate-window-height)) + (switch-to-buffer candidate-buffer) + ;; make keymap for minibuffer + (suppress-keymap minibuffer-map t) + (define-key minibuffer-map "\C-m" 'undefined) + (define-key minibuffer-map "\C-g" 'abort-recursive-edit) + (mapcar + (lambda (option-def) + (define-key minibuffer-map (car option-def) 'self-insert-and-exit)) + option-defs) + ;; read key from minibuffer + (unwind-protect + (assoc + (read-from-minibuffer prompt nil minibuffer-map nil 'mini-hist) + option-defs) + (kill-buffer candidate-buffer))))) + +(defvar elscreen-gf-search-process nil) +(defsubst elscreen-gf-run-search-command (command-name pattern command directory line-parser) + (put 'elscreen-gf-mode 'elscreen-gf-major-mode-thing + (or (get major-mode 'elscreen-gf-major-mode-thing) 'word)) + (let ((invoke-point (cons (elscreen-get-current-screen) (point-marker)))) + (elscreen-gf-goto-screen-create directory) + (setq elscreen-gf-pattern pattern) + (setq elscreen-gf-invoke-point invoke-point)) + (let ((buffer-read-only nil)) + (insert "DIR: " (abbreviate-file-name directory) "\n" + "CMD: " command " (reformatted by gf)\n\n")) + (message "Running %s..." command-name) + (setq elscreen-gf-search-process + (start-process command-name (current-buffer) + "sh" "-c" command "2> /dev/null")) + (process-put elscreen-gf-search-process + 'elscreen-gf-search-line-parser line-parser) + (set-process-filter elscreen-gf-search-process 'elscreen-gf-search-filter) + (set-process-sentinel elscreen-gf-search-process 'elscreen-gf-search-sentinel)) + +(defun elscreen-gf-search-filter (process string) + (set-buffer (process-buffer process)) + (save-excursion + (let* ((string (concat elscreen-gf-filter-odd-string string)) + (token-chars (or (elscreen-gf-major-mode-token-chars major-mode) + "a-zA-Z0-9")) + (nontoken-chars (format "[^%s]" token-chars)) + (line-parser (process-get process 'elscreen-gf-search-line-parser)) + (buffer-read-only nil)) + (goto-char (point-max)) + (save-excursion (insert string)) + (while (and (not (eobp)) (looking-at ".*\n")) + (beginning-of-line) + (let* ((line (buffer-substring (point-at-bol) (point-at-eol))) + (line-elms (funcall line-parser line)) + (file-name (nth 0 line-elms)) + (line-number (nth 1 line-elms)) + (source (nth 2 line-elms)) + start end) + (when line-elms + (delete-region (point-at-bol) (point-at-eol)) + (elscreen-gf-overlay-create + (point) (progn (insert (file-relative-name file-name)) (point)) + 'elscreen-gf-mode-file-name-face) + (insert ":") + (elscreen-gf-overlay-create + (point) (progn (insert line-number) (point)) + 'elscreen-gf-mode-line-number-face) + (insert ":") + (save-excursion (insert (nth 0 source))) + (forward-char (nth 1 source)) + (setq start (point) end (+ start (nth 2 source))) + (while (or (and (eq (point) start) + (save-excursion + (re-search-forward + (format "\\(%s\\)\\(%s\\|$\\)" + elscreen-gf-pattern nontoken-chars) + end t)) + (eq (match-beginning 1) start)) + (re-search-forward + (format "%s\\(%s\\)\\(%s\\|$\\)" + nontoken-chars elscreen-gf-pattern + nontoken-chars) + end t)) + (elscreen-gf-overlay-create (match-beginning 1) (match-end 1) + 'elscreen-gf-mode-pattern-face) + (goto-char (match-end 1))))) + (forward-line)) + (setq elscreen-gf-filter-odd-string + (buffer-substring (point-at-bol) (point-at-eol))) + (delete-region (point-at-bol) (point-at-eol))))) + +(defun elscreen-gf-search-sentinel (process event) + (let ((status (string-match "finished" event))) + (message "Running %s... done" (process-name elscreen-gf-search-process)) + (setq elscreen-gf-search-process nil) + (set-buffer (process-buffer process)) + (elscreen-gf-mode-selected-entry-overlay))) + +;;; GNU grep + +(defun elscreen-gf-grep (&optional pattern file-name-re) + "Run grep, with user-specified args, and collect output +in the ElScreen-GF buffer." + (interactive) + (cond + ((not (executable-find elscreen-gf-grep-program-name)) + (error "grep not found.")) + ((elscreen-gf-process-exclusive-p elscreen-gf-search-process) + (let* ((pattern (or pattern + (elscreen-gf-search-read-pattern "Run grep (pattern): "))) + (buffer-file-name (or (buffer-file-name) "")) + (file-name-re-default (concat + (file-name-directory buffer-file-name) + "*" + (when (file-name-extension buffer-file-name) + ".") + (file-name-extension buffer-file-name))) + (file-name-re (or file-name-re + (read-string + "Run grep (files): " + (cons file-name-re-default 0) nil "*"))) + (token-chars (or (elscreen-gf-major-mode-token-chars major-mode) + "a-zA-Z0-9")) + (token-chars-re (format "[%s]" token-chars)) + (nontoken-chars-re (format "[^%s]" token-chars)) + (pattern-tokenize (elscreen-gf-search-regexp-dot-to-token + pattern token-chars-re)) + (command (format "%s -IHn %s %s" + elscreen-gf-grep-program-name + (format "'\\(^\\|%s\\)\\(%s\\)\\(%s\\|$\\)'" + nontoken-chars-re + pattern-tokenize + nontoken-chars-re) + file-name-re))) + (elscreen-gf-run-search-command + "grep" pattern-tokenize command default-directory + 'elscreen-gf-grep-line-parser))))) + +(defun elscreen-gf-grep-line-parser (line) + (when (string-match "^\\([^:\n]+\\):\\([0-9]+\\):\\(.*\\)$" line) + (let ((file-name (match-string 1 line)) + (line-number (match-string 2 line)) + (source (match-string 3 line))) + (list file-name line-number (list source 0 (length source)))))) + +;;; GNU ID Utils + +(defsubst elscreen-gf-idutils-id-directory (&optional directory) + (elscreen-gf-db-directory "ID" directory)) + +(defvar elscreen-gf-idutils-mkid-process nil) + +(defun elscreen-gf-idutils-mkid (&optional directory) + "Run mkid, with user-specified args." + (interactive) + (cond + ((not (executable-find elscreen-gf-idutils-mkid-program-name)) + (error "mkid not found.")) + ((elscreen-gf-process-exclusive-p elscreen-gf-idutils-mkid-process) + (let ((default-directory + (or (and directory (file-directory-p directory) directory) + (read-directory-name "Run mkid (target): " + (or (elscreen-gf-idutils-id-directory) + default-directory) nil t))) + (command (format "%s" elscreen-gf-idutils-mkid-program-name))) + (message "Running mkid...") + (setq elscreen-gf-idutils-mkid-process + (start-process "mkid" nil "sh" "-c" command)) + (set-process-sentinel elscreen-gf-idutils-mkid-process + 'elscreen-gf-idutils-mkid-sentinel) + (elscreen-notify-screen-modification 'force-immediately))))) + +(defun elscreen-gf-idutils-mkid-sentinel (process event) + (let ((status (string-match "finished" event))) + (message "Running mkid... %s" (if status "done" "error")) + (setq elscreen-gf-idutils-mkid-process nil) + (elscreen-notify-screen-modification 'force-immediately))) + +(defun elscreen-gf-idutils-mkid-after-save () + (when (and (buffer-file-name) + (elscreen-gf-process-exclusive-p + elscreen-gf-idutils-mkid-process 'noerror)) + (let ((id-directory (elscreen-gf-idutils-id-directory))) + (when id-directory + (elscreen-gf-idutils-mkid id-directory))))) + +(defun elscreen-gf-idutils-mkid-setup-after-save-hook () + (make-local-variable 'after-save-hook) + (add-hook 'after-save-hook 'elscreen-gf-idutils-mkid-after-save)) + +(defun elscreen-gf-idutils-gid (&optional pattern) + "Run gid, with user-specified args, and collect output +in the ElScreen-GF buffer." + (interactive) + (cond + ((not (executable-find elscreen-gf-idutils-gid-program-name)) + (when (yes-or-no-p "gid not found; execute grep instead? ") + (elscreen-gf-grep))) + ((not (elscreen-gf-idutils-id-directory)) + (funcall + (nth 2 (elscreen-gf-read-selection + "Cannot locate `ID'; what instead?" + "Select action: " + '(("m" "Execute mkid to generate `ID'" elscreen-gf-idutils-mkid) + ("g" "Execute grep" elscreen-gf-grep)))))) + ((elscreen-gf-process-exclusive-p elscreen-gf-search-process) + (let* ((pattern (or pattern + (elscreen-gf-search-read-pattern "Run gid (pattern): "))) + (token-chars (or (elscreen-gf-major-mode-token-chars major-mode) + "a-zA-Z0-9")) + (token-chars-re (format "[%s]" token-chars)) + (pattern-tokenize (elscreen-gf-search-regexp-dot-to-token + pattern token-chars-re)) + (directory (elscreen-gf-idutils-id-directory)) + (command (format "%s --regexp '^(%s)$'" + elscreen-gf-idutils-gid-program-name pattern))) + ;; XXX: gid does not raise error even if given regexp starts with '*', + ;; so we should check it here. + (when (string-match "^\\*" pattern) + (error "Invalid regexp: %s" pattern)) + (elscreen-gf-run-search-command + "gid" pattern-tokenize command directory + 'elscreen-gf-grep-line-parser))))) + +;;; cscope + +(defsubst elscreen-gf-cscope-cross-ref-directory (&optional directory) + (elscreen-gf-db-directory "cscope.out" directory)) + +(defun elscreen-gf-cscope (&optional pattern directory) + "Run cscope, with user-specified args, and collect output +in the ElScreen-GF buffer." + (interactive) + (cond + ((not (executable-find elscreen-gf-cscope-program-name)) + (when (yes-or-no-p "cscope not found; execute grep instead? ") + (elscreen-gf-grep))) + ((elscreen-gf-process-exclusive-p elscreen-gf-search-process) + (let* ((pattern (or pattern + (elscreen-gf-search-read-pattern + "Run cscope (pattern): "))) + (directory (or (and directory (file-directory-p directory) directory) + (elscreen-gf-cscope-cross-ref-directory) + (read-directory-name "Run cscope (target): " + default-directory nil t))) + (token-chars (or (elscreen-gf-major-mode-token-chars major-mode) + "a-zA-Z0-9")) + (token-chars-re (format "[%s]" token-chars)) + (pattern-tokenize (elscreen-gf-search-regexp-dot-to-token + pattern token-chars-re)) + (query-type-def (elscreen-gf-read-selection + "Available query type for cscope: " + "Select query type: " + '(("0" "Find this C symbol" 0) + ("1" "Find this function definition" 1) + ("2" "Find functions calling this function" 3)))) + (query-type (nth 2 query-type-def)) + (command (format "%s -LR -%d '%s' | sort -k 1,1 -k 3,3n" + elscreen-gf-cscope-program-name query-type pattern)) + (line-parser (intern + (format "elscreen-gf-cscope-line-parser-query-type-%s" + (car query-type-def))))) + (elscreen-gf-run-search-command + "cscope" pattern-tokenize command directory line-parser))))) + +(defsubst elscreen-gf-cscope-line-parser-string-match (line) + (string-match "^\\([^ ]+\\) \\([^ ]+\\) \\([0-9]+\\) \\(.*\\)$" line)) + +(defun elscreen-gf-cscope-line-parser-common (line) + (when (elscreen-gf-cscope-line-parser-string-match line) + (let ((file-name (match-string 1 line)) + (line-number (match-string 3 line)) + (function-name (match-string 2 line)) + (source (match-string 4 line))) + (list file-name line-number + (list (format "[%s] %s" function-name source) + (+ (length function-name) 3) (length source)))))) + +(defalias 'elscreen-gf-cscope-line-parser-query-type-0 + 'elscreen-gf-cscope-line-parser-common) + +(defun elscreen-gf-cscope-line-parser-query-type-1 (line) + (when (elscreen-gf-cscope-line-parser-string-match line) + (let ((file-name (match-string 1 line)) + (line-number (match-string 3 line)) + (source (match-string 4 line))) + (list file-name line-number (list source 0 (length source)))))) + +(defalias 'elscreen-gf-cscope-line-parser-query-type-2 + 'elscreen-gf-cscope-line-parser-common) + +;;; GNU global + +(defsubst elscreen-gf-global-tags-directory (&optional directory) + (elscreen-gf-db-directory "GTAGS" directory)) + +(defvar elscreen-gf-global-gtags-process nil) + +(defun elscreen-gf-global-gtags (&optional directory) + "Run gtags, with user-specified args." + (interactive) + (cond + ((not (executable-find elscreen-gf-global-gtags-program-name)) + (error "gtags not found.")) + ((elscreen-gf-process-exclusive-p elscreen-gf-global-gtags-process) + (let ((default-directory + (or (and directory (file-directory-p directory) directory) + (read-directory-name "Run gtags (target): " + (or (elscreen-gf-global-tags-directory) + default-directory) nil t))) + (command (format "%s" elscreen-gf-global-gtags-program-name))) + (message "Running gtags...") + (setq elscreen-gf-global-gtags-process + (start-process "gtags" nil "sh" "-c" command)) + (set-process-sentinel elscreen-gf-global-gtags-process + 'elscreen-gf-global-gtags-sentinel) + (elscreen-notify-screen-modification 'force-immediately))))) + +(defun elscreen-gf-global-gtags-sentinel (process event) + (let ((status (string-match "finished" event))) + (message "Running gtags... %s" (if status "done" "error")) + (setq elscreen-gf-global-gtags-process nil) + (elscreen-notify-screen-modification 'force-immediately))) + +(defun elscreen-gf-global-gtags-after-save () + (when (and (buffer-file-name) + (elscreen-gf-process-exclusive-p + elscreen-gf-global-gtags-process 'noerror)) + (let ((tags-directory (elscreen-gf-global-tags-directory))) + (when tags-directory + (elscreen-gf-global-gtags tags-directory))))) + +(defun elscreen-gf-global-gtags-setup-after-save-hook () + (make-local-variable 'after-save-hook) + (add-hook 'after-save-hook 'elscreen-gf-global-gtags-after-save)) + +(defvar elscreen-gf-global-5.0-or-later-p) +(defsubst elscreen-gf-global-5.0-or-later-p () + (unless (boundp 'elscreen-gf-global-5.0-or-later-p) + (let (global-version) + (with-temp-buffer + (call-process elscreen-gf-global-program-name nil t nil "--version") + (setq global-version (string-to-number + (buffer-substring (point-min) (point-max))))) + (setq elscreen-gf-global-5.0-or-later-p (and global-version + (<= 5.0 global-version))))) + elscreen-gf-global-5.0-or-later-p) + +(defun elscreen-gf-global (&optional pattern directory) + "Run global, with user-specified args, and collect output +in the ElScreen-GF buffer." + (interactive) + (cond + ((not (executable-find elscreen-gf-global-program-name)) + (when (yes-or-no-p "global not found; execute grep instead? ") + (elscreen-gf-grep))) + ((not (elscreen-gf-global-tags-directory)) + (funcall + (nth 2 (elscreen-gf-read-selection + "Cannot locate `GTAGS'; what instead?" + "Select action: " + '(("t" "Execute gtags to generate `GTAGS'" elscreen-gf-global-gtags) + ("g" "Execute grep" elscreen-gf-grep)))))) + ((elscreen-gf-process-exclusive-p elscreen-gf-search-process) + (let* ((pattern (or pattern + (elscreen-gf-search-read-pattern + "Run global (pattern): "))) + (directory (or (and directory (file-directory-p directory) directory) + (elscreen-gf-global-tags-directory) + (read-directory-name "Run global (target): " + default-directory nil t))) + (token-chars (or (elscreen-gf-major-mode-token-chars major-mode) + "a-zA-Z0-9")) + (token-chars-re (format "[%s]" token-chars)) + (pattern-tokenize (elscreen-gf-search-regexp-dot-to-token + pattern token-chars-re)) + (query-type (nth 2 (elscreen-gf-read-selection + "Available query type for GNU GLOBAL: " + "Select query type: " + '(("0" "Find this object definition" "") + ("1" "Find this object references" " -r"))))) + (command (format + (cond + ((elscreen-gf-global-5.0-or-later-p) + "%s%s --result=grep -e '%s' | sort -t : -k 1,1 -k 2,2n") + (t + "%s -x%s -e '%s' | sort -k 3,3 -k 2,2n")) + elscreen-gf-global-program-name query-type pattern)) + (line-parser (if (elscreen-gf-global-5.0-or-later-p) + 'elscreen-gf-grep-line-parser + 'elscreen-gf-global-line-parser))) + (elscreen-gf-run-search-command + "global" pattern-tokenize command directory line-parser))))) + +(defun elscreen-gf-global-line-parser (line) + (when (string-match "^[^ ]+ +\\([0-9]+\\) +\\([^ ]+\\) \\(.*\\)$" line) + (let ((file-name (match-string 2 line)) + (line-number (match-string 1 line)) + (source (match-string 3 line))) + (list file-name line-number (list source 0 (length source)))))) + +;;; Going back to the latest invoke-point. + +(defun elscreen-gf-go-back-to-latest-invoke-point () + (interactive) + (while (not (or (ring-empty-p elscreen-gf-invoke-point-history) + (let ((invoke-point + (ring-ref elscreen-gf-invoke-point-history 0))) + (buffer-live-p (marker-buffer (cdr invoke-point)))))) + (ring-remove elscreen-gf-invoke-point-history 0)) + (if (ring-empty-p elscreen-gf-invoke-point-history) + (message "No more invoke-points to go back to.") + (let* ((invoke-point (ring-remove elscreen-gf-invoke-point-history 0)) + (invoke-point-screen (car invoke-point)) + (invoke-point-marker (cdr invoke-point)) + (invoke-point-buffer (marker-buffer invoke-point-marker)) + (invoke-point-position (marker-position invoke-point-marker)) + (invoke-point-buffer-screen-list + (elscreen-find-screens + `(lambda (screen) + (elscreen-goto-internal screen) + (not (null (get-buffer-window ,invoke-point-buffer)))))) + (get-marker-window + (lambda (marker) + (catch 'found + (save-window-excursion + (mapc + (lambda (window) + (select-window window) + (when (eq (point) (marker-position marker)) + (throw 'found window))) + (get-buffer-window-list (marker-buffer marker)))) + nil)))) + (cond + ((null invoke-point-buffer-screen-list) + ;; No screens showing invoke-point-buffer, so create new screen + ;; and show it. + (elscreen-create) + (switch-to-buffer invoke-point-buffer) + (goto-char invoke-point-position)) + ((memq invoke-point-screen invoke-point-buffer-screen-list) + ;; invoke-point-screen shows invoke-point-buffer, so go to the + ;; screen and select the window showing the buffer. If there are + ;; two or more window showing the buffer, we prefer the window + ;; whose buffer's point is invoke-point-position. Anyway, + ;; we are moving point to it. + (elscreen-goto invoke-point-screen) + (select-window (or (funcall get-marker-window invoke-point-marker) + (get-buffer-window invoke-point-buffer))) + (goto-char invoke-point-position)) + ((catch 'found + (mapc + (lambda (screen) + (let (window) + (when (save-window-excursion + (elscreen-goto-internal screen) + (setq window (funcall get-marker-window + invoke-point-marker))) + ;; There is (at least one) screen showing buffer whose + ;; point is invoke-point-position, so show it. + (elscreen-goto screen) + (select-window window) + (throw 'found t)))) + invoke-point-buffer-screen-list))) + (t + ;; invoke-point-screen does not show invoke-point-buffer, and + ;; the others does not show invoke-point-buffer whose point is + ;; invoke-point-position; so we're showing one of screens showing + ;; invoke-point-buffer and moving point to invoke-point-position. + (elscreen-goto (car invoke-point-buffer-screen-list)) + (select-window (get-buffer-window invoke-point-buffer)) + (goto-char (invoke-point-position))))))) + +;;; Help + +(defvar elscreen-gf-help "ElScreen-GF keys: + \\[elscreen-gf-grep] Run grep + \\[elscreen-gf-idutils-mkid] Run mkid (GNU ID Utils) + \\[elscreen-gf-idutils-gid] Run gid (GNU ID Utils) + \\[elscreen-gf-cscope] Run cscope + \\[elscreen-gf-global-gtags] Run gtags (GNU GLOBAL) + \\[elscreen-gf-global] Run global (GNU GLOBAL) + \\[elscreen-gf-go-back-to-latest-invoke-point] Go back to the latest invoke-point. + \\[elscreen-gf-display-version] Display ElScreen-GF version") +(elscreen-set-help 'elscreen-gf-help) + +(defun elscreen-gf-display-version () + "Display ElScreen-GF version." + (interactive) + (elscreen-message (concat "ElScreen-GF version " elscreen-gf-version))) --- elscreen-1.4.6.orig/elscreen-goby.el +++ elscreen-1.4.6/elscreen-goby.el @@ -0,0 +1,35 @@ +;; -*- Mode: Emacs-Lisp -*- +;; +;; elscreen-goby.el +;; +(defconst elscreen-goby-version "0.0.0 (July 14, 2005)") +;; +;; Author: Naoto Morishima +;; Nara Institute of Science and Technology, Japan +;; Created: July 14, 2005 + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2, or (at your option) +;; any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program; see the file COPYING. If not, write to +;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + +(provide 'elscreen-goby) +(require 'elscreen) + + +;;; Code: + +(defadvice goby-view-mode (before elscreen-goby-view-mode activate) + (set (make-local-variable 'elscreen-display-tab) nil)) + +(defadvice goby-view-quit (before elscreen-goby-view-quit activate) + (kill-local-variable 'elscreen-display-tab)) --- elscreen-1.4.6.orig/elscreen-howm.el +++ elscreen-1.4.6/elscreen-howm.el @@ -0,0 +1,119 @@ +;; -*- Mode: Emacs-Lisp -*- +;; +;; elscreen-howm.el +;; +(defconst elscreen-howm-version "0.1.3 (September 14, 2008)") +;; +;; Author: Naoto Morishima +;; Created: November 06, 2005 +;; Revised: September 14, 2008 + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2, or (at your option) +;; any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program; see the file COPYING. If not, write to +;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + +(provide 'elscreen-howm) +(require 'elscreen) + +;;; User Customizable Variables: + +(defcustom elscreen-howm-mode-to-nickname-alist + '(("^howm-\\(menu-mode$\\|view-\\)" . "howm(menu)")) + "*Alist composed of the pair of mode-name and corresponding screen-name." + :type '(alist :key-type string :value-type (choice string function)) + :tag "Howm major-mode to nickname alist" + :set (lambda (symbol value) + (custom-set-default symbol value) + (elscreen-rebuild-mode-to-nickname-alist)) + :group 'howm) +(elscreen-set-mode-to-nickname-alist 'elscreen-howm-mode-to-nickname-alist) + +(defcustom elscreen-howm-buffer-to-nickname-alist + '(("\\.howm$" . elscreen-howm-mode-buffer-to-nickname)) + "*Alist composed of the pair of regular expression of +buffer-name and corresponding screen-name." + :type '(alist :key-type string :value-type (choice string function)) + :tag "Howm buffer to nickname alist" + :set (lambda (symbol value) + (custom-set-default symbol value) + (elscreen-rebuild-buffer-to-nickname-alist)) + :group 'howm) +(elscreen-set-buffer-to-nickname-alist 'elscreen-howm-buffer-to-nickname-alist) + + +;;; Code: + +;; delete other windows when howm-menu is invoked +(defadvice howm-menu (around elscreen-howm-menu activate) + (delete-other-windows) + ad-do-it) + +;; create new page with new screen +(defadvice howm-create-file-with-title (around elscreen-howm-create-file-with-title activate) + (save-current-buffer + (elscreen-create)) + ad-do-it) + +;; open existing page with new screen +(defadvice howm-view-open-item (around elscreen-howm-view-open-item activate) + (let ((window-configuration (elscreen-current-window-configuration)) + howm-item-buffer) + ad-do-it + (setq howm-item-buffer (current-buffer)) + (elscreen-apply-window-configuration window-configuration) + (elscreen-find-and-goto-by-buffer howm-item-buffer 'create))) + +(eval-after-load "howm-view" + '(unless (fboundp 'howm-view-open-item) + (elscreen-message "This version of elscreen-howm does not work well with your howm. Upgrade howm to version 1.3.3 or later, or downgrade elscreen-howm to version 0.0.1."))) + +;; screen nickname +(defun elscreen-howm-mode-buffer-to-nickname () + (format "howm(%s%s%s)" + elscreen-howm-title + (if (zerop (length elscreen-howm-title)) "" ":") + (substring (buffer-name (current-buffer)) 0 -5))) + +(defun elscreen-howm-mode-update-title () + (let ((title (howm-title-at-current-point))) + (when (not (string-equal elscreen-howm-title title)) + (setq elscreen-howm-title title) + (elscreen-notify-screen-modification 'force-immediately)))) + +(defun elscreen-howm-mode-initialize () + (set (make-local-variable 'elscreen-howm-title) + (howm-title-at-current-point)) + (add-hook 'post-command-hook 'elscreen-howm-mode-update-title t t)) + +(add-hook 'howm-mode-on-hook 'elscreen-howm-mode-initialize) + +;; kill screen when exiting from howm-mode +(defun howm-save-and-kill-buffer/screen () + (interactive) + (let* ((file-name (buffer-file-name))) + (if (save-excursion + (goto-char (point-min)) + (re-search-forward "[^ \t\r\n]" nil t)) + (howm-save-buffer) + (set-buffer-modified-p nil) + (when (file-exists-p file-name) + (delete-file file-name) + (message "(Deleted %s)" (file-name-nondirectory file-name)))) + (kill-buffer nil) + (unless (elscreen-one-screen-p) + (elscreen-kill)))) + +(eval-after-load "howm-mode" + '(progn + (define-key howm-mode-map + "\C-c\C-c" 'howm-save-and-kill-buffer/screen))) --- elscreen-1.4.6.orig/elscreen-server.el +++ elscreen-1.4.6/elscreen-server.el @@ -0,0 +1,95 @@ +;; -*- Mode: Emacs-Lisp -*- +;; +;; elscreen-server.el +;; +(defconst elscreen-server-version "0.2.0 (November 23, 2007)") +;; +;; Author: Hideyuki Shirai +;; Naoto Morishima +;; Created: October 11, 2007 +;; Revised: November 23, 2007 + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2, or (at your option) +;; any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program; see the file COPYING. If not, write to +;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + +(provide 'elscreen-server) +(require 'elscreen) + +(defmacro elscreen-server-defcustom-dont-use-dedicated-frame (type) + `(defcustom elscreen-server-dont-use-dedicated-frame t + "*Non-nil to use dframe-attached-frame if frame is dedicated" + :type 'boolean + :group ,type)) + +(defsubst elscreen-server-visit-files-new-screen (buffer-list) + (let* ((selected-frame (selected-frame)) + (dframe-attached-frame (and (fboundp 'dframe-attached-frame) + (dframe-attached-frame selected-frame)))) + (when (and elscreen-server-dont-use-dedicated-frame + (framep dframe-attached-frame)) + (select-frame dframe-attached-frame)) + (elscreen-goto (car (mapcar + (lambda (buffer) + (elscreen-find-screen-by-buffer buffer 'create)) + buffer-list))) + (elscreen-notify-screen-modification 'force-immediately) + (select-frame selected-frame))) + +(eval-after-load "server" + ;; For server.el distributed with GNU Emacs + '(progn + (elscreen-server-defcustom-dont-use-dedicated-frame 'server) + + (defadvice server-visit-files (after elscreen-server-visit-files activate) + (elscreen-server-visit-files-new-screen + (if (processp (car ad-return-value)) + ;; Before multi-tty; server-visit-files returns a list of proc + ;; and client-record. + (cdr ad-return-value) + ;; After multi-tty was merged; in server.el r1.131 or later, it + ;; returns only client-record. + ad-return-value))))) + +(eval-after-load "gnuserv" + '(progn + (elscreen-server-defcustom-dont-use-dedicated-frame 'gnuserv) + + (defun elscreen-server-find-buffer-visiting (filename) + (if (file-directory-p filename) + (car (dired-buffers-for-dir filename)) + (find-buffer-visiting filename))) + + (cond + ((fboundp 'gnuserv-edit-files) + ;; For (current) gnuserv typically used with XEmacs + (defadvice gnuserv-edit-files (around elscreen-gnuserv-edit-files activate) + (let ((filename-list (mapcar 'cdr list)) + (gnuserv-frame t)) + (save-window-excursion ad-do-it) + (elscreen-server-visit-files-new-screen + (mapcar 'elscreen-server-find-buffer-visiting filename-list))))) + ((fboundp 'server-find-file) + ;; For (ancient) gnuserv typically used with Meadow + (defadvice server-edit-files (around elscreen-server-edit-files activate) + (let ((filename-list (mapcar 'cdr list)) + (gnuserv-frame (selected-frame))) + (save-window-excursion ad-do-it) + (elscreen-server-visit-files-new-screen + (mapcar 'elscreen-server-find-buffer-visiting filename-list)))) + (defadvice server-edit-files-quickly (around elscreen-server-edit-files-quickly activate) + (let ((filename-list (mapcar 'cdr list)) + (gnuserv-frame (selected-frame))) + (save-window-excursion ad-do-it) + (elscreen-server-visit-files-new-screen + (mapcar 'elscreen-server-find-buffer-visiting filename-list)))))))) --- elscreen-1.4.6.orig/elscreen-speedbar.el +++ elscreen-1.4.6/elscreen-speedbar.el @@ -0,0 +1,48 @@ +;; -*- Mode: Emacs-Lisp -*- +;; +;; elscreen-speedbar.el +;; +(defconst elscreen-speedbar-version "0.0.0 (November 18, 2007)") +;; +;; Author: Naoto Morishima +;; Created: November 18, 2007 + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2, or (at your option) +;; any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program; see the file COPYING. If not, write to +;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + +(provide 'elscreen-speedbar) +(require 'elscreen) + +(defcustom elscreen-speedbar-find-file-in-screen t + "Non-nil to use ElScreen to open file when the selected file is being +opened in the attached frame." + :type 'boolean + :group 'speedbar) + +(defadvice speedbar-frame-mode (after elscreen-speedbar-frame-mode activate) + (with-current-buffer speedbar-buffer + (set (make-local-variable 'elscreen-display-tab) nil))) + +(defadvice speedbar-find-file-in-frame (around elscreen-speedbar-find-file-in-frame activate) + (let ((buffer (find-file-noselect file))) + (if (or (get-buffer-window buffer 0) + dframe-power-click + (numberp speedbar-select-frame-method) + (not elscreen-speedbar-find-file-in-screen)) + (let ((dframe-power-click (and (not elscreen-speedbar-find-file-in-screen) + dframe-power-click))) + ad-do-it) + (dframe-select-attached-frame speedbar-frame) + (elscreen-find-and-goto-by-buffer buffer 'create)) + (elscreen-notify-screen-modification 'force-immediately))) --- elscreen-1.4.6.orig/elscreen-w3m.el +++ elscreen-1.4.6/elscreen-w3m.el @@ -0,0 +1,82 @@ +;; -*- Mode: Emacs-Lisp -*- +;; +;; elscreen-w3m.el +;; +(defconst elscreen-w3m-version "0.2.2 (July 26, 2006)") +;; +;; Author: Naoto Morishima +;; Created: August 6, 2004 +;; Revised: July 26, 2006 + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2, or (at your option) +;; any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program; see the file COPYING. If not, write to +;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + +(provide 'elscreen-w3m) +(require 'elscreen) + +;; Code: + +(defconst elscreen-w3m-mode-to-nickname-alist + '(("^w3m-mode" . + (lambda (buf) + (with-current-buffer buf + (let ((graphic (and window-system + w3m-show-graphic-icons-in-header-line))) + (concat + (when (and graphic w3m-use-favicon w3m-favicon-image) + (concat + (propertize + " " + 'display w3m-favicon-image) + (propertize + " " + 'display '(space :width 0.5)))) + (w3m-current-title))))))) + "*Alist composed of the pair of mode-name and corresponding screen-name.") +(elscreen-set-mode-to-nickname-alist 'elscreen-w3m-mode-to-nickname-alist) + +(defun elscreen-w3m-mailto-url-popup-function (buffer) + (elscreen-find-and-goto-by-buffer buffer 'create)) + +(defadvice w3m-copy-buffer (around elscreen-w3m-copy-buffer activate) + (let ((current-buffer (current-buffer))) + (if (< (elscreen-get-number-of-screens) 10) + (elscreen-create) + (split-window) + (other-window 1)) + (unless (ad-get-arg 0) + (ad-set-arg 0 current-buffer)) + ad-do-it)) + +(defadvice w3m-favicon-retrieve (around elscreen-w3m-favicon-retrieve activate) + ad-do-it + (run-at-time 1 nil 'elscreen-notify-screen-modification 'force-immediately)) + +(defun elscreen-w3m-initialize () + (setq w3m-pop-up-frames nil) + (setq w3m-pop-up-windows nil) + (setq w3m-use-tab nil) + (setq w3m-use-tab-menubar nil) + (setq w3m-use-header-line nil) + (setq w3m-mailto-url-popup-function-alist + '((cmail-mail-mode . elscreen-w3m-mailto-url-popup-function) + (mail-mode . elscreen-w3m-mailto-url-popup-function) + (message-mode . elscreen-w3m-mailto-url-popup-function) + (mew-draft-mode . elscreen-w3m-mailto-url-popup-function) + (mh-letter-mode . elscreen-w3m-mailto-url-popup-function) + (wl-draft-mode . elscreen-w3m-mailto-url-popup-function))) + (elscreen-screen-modified-hook-setup + (w3m-fontify-after-hook 'force-immediately))) + +(add-hook 'w3m-load-hook 'elscreen-w3m-initialize)