Mercurial > emacs
view lisp/resume.el @ 10219:d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
(sort-subr): Don't call autload for this--that's done in loaddefs.el.
(bibtex-mode): Add autoload cookie.
Changed keybinding for bibtex-print-help-message
(from \C-ch to \C-c?). Therefore, describe-mode is not longer on
\C-c?. Also, changed prefix \C-cn for bibtex-narrow functions to
\C-c\C-r.
(bibtex-string-files): Changed documentation.
(bibtex-mode-map): Inscriptions of menu bar changed from "Entry
Types" to "Entry-Types" and "Bibtex Edit" to "BibTeX-Edit".
(bibtex-string-files): Changed documentation.
(bibtex-mode): If environment variable BIBINPUTS isn't defined,
string files are searched in the current directory.
(bibtex-completion-candidates): Now buffer-local to allow
evaluation of different bibtex-string-files in different buffers.
(bibtex-autokey-edit-before-use, bibtex-clean-entry): New variable
that determines, if the user is allowed to edit auto-generated
reference keys before they are used.
(bibtex-generate-autokey, bibtex-clean-entry): New function to
generate an autokey if necessary.
(bibtex-autokey-names, bibtex-autokey-name-change-strings,
bibtex-autokey-name-length, bibtex-autokey-name-separator,
bibtex-autokey-year-length, bibtex-autokey-titlewords,
bibtex-autokey-title-terminators,
bibtex-autokey-titlewords-stretch,
bibtex-autokey-titleword-first-ignore,
bibtex-autokey-titleword-abbrevs,
bibtex-autokey-titleword-change-strings,
bibtex-autokey-titleword-length,
bibtex-autokey-titleword-separator,
bibtex-autokey-name-year-separator,
bibtex-autokey-year-title-separator): New variables related to
bibtex-generate-autokey.
(bibtex-find-entry-location): Optional second parameter maybedup
to tell it that entering a duplicate entry isn't to report by an
error but by the return value of the function (necessary for
bibtex-clean-entry to find the correct position of an entry with
an autogenerated key without disturbing the user with unwanted
messages).
(bibtex-help-message): New variable to avoid printing of help
messages in the echo area.
(assoc-of-regexp): New function to match an alist of regexps.
(bibtex-string-files, bibtex-completion-candidates, bibtex-mode):
New variables to allow bibtex-complete-string to work on strings
initialized from a variable and from @String definitions in a list
of files, too.
(bibtex-predefined-strings, bibtex-entry-field-alist): Changed to
user options.
(bibtex-mode): Changed doc string.
(many functions and variables): Changed documentation strings of
variables and functions to hold a complete sentence in the first
line.
(bibtex-print-help-message): Now line dependent and reports if it
is called outside a BibTeX field.
(validate-bibtex-buffer): Completely rewritten to validate, if
buffer is syntactically correct.
(find-bibtex-duplicates): Moved into validate-bibtex-buffer.
(ispell-abstract, bibtex-ispell-abstract, ispell-bibtex-entry,
bibtex-ispell-entry, beginning-of-bibtex-entry,
bibtex-beginning-of-entry, end-of-bibtex-entry,
bibtex-end-of-entry, hide-bibtex-entry-bodies,
bibtex-hide-entry-bodies, narrow-to-bibtex-entry,
bibtex-narrow-to-entry, sort-bibtex-entries, bibtex-sort-entries,
validate-bibtex-buffer, bibtex-validate-buffer,
find-bibtex-entry-location, bibtex-find-entry-location): All
interactive functions are renamed, so that any interface function
begins with "bibtex-". Mapping:
ispell-abstract --> bibtex-ispell-abstract
ispell-bibtex-entry --> bibtex-ispell-entry
beginning-of-bibtex-entry --> bibtex-beginning-of-entry
end-of-bibtex-entry --> bibtex-end-of-entry
hide-bibtex-entry-bodies --> bibtex-hide-entry-bodies
narrow-to-bibtex-entry --> bibtex-narrow-to-entry
sort-bibtex-entries --> bibtex-sort-entries
validate-bibtex-buffer --> bibtex-validate-buffer
find-bibtex-entry-location --> bibtex-find-entry-location
(bibtex-maintain-sorted-entries,
bibtex-sort-ignore-string-entries): Default is now t.
(bibtex-complete-string): String list is built from additional
string list bibtex-predefined-string and current strings in file.
(string-equalp): Deleted and substituted by string-equal.
(assoc-string-equalp): Renamed to assoc-ignore-case.
(bibtex-entry): Reference key can be entered with completion. All
reference keys that are defined in buffer and all labels that
appear in crossreference entries are object to completion.
(Entry types): Changed order of entries in menu "entry types".
(bibtex-entry-field-alist): Changed order of entries slightly to
be more conform with standard BibTeX style layouts.
(bibtex-mode-map): Uniform keybindings for \C-c\C-e prefix (often
used types on control keys, sometimes used types on normal keys,
rarely used types on shift keys, almost never used types on meta
keys).
(bibtex-mode-map): Function narrow-to-bibtex-entry and counterpart
widen and function hide-bibtex-entry-bodies and counterpart
show-all bounded to appropriate local keys.
(bibtex-abbrev-table): Deleted
(bibtex-current-entry-label, put-string-on-kill-ring): Deleted
(AUCTeX provides all the functionality needed for citation
completion).
(bibtex-enclosing-reference, bibtex-pop-previous, bibtex-pop-next,
bibtex-clean-entry): Hacked for speed (bibtex-pop-previous and
bibtex-pop-next were to slow for larger BibTeX files).
(bibtex-pop-previous, bibtex-pop-next): Delimiters from previous
or next entry are changed to actual delimters if necessary.
(bibtex-entry): Fixed bug (False entry wasn't reported in error
message if bibtex-entry was called with undefined reference name).
(bibtex-entry-field-alist, bibtex-entry, bibtex-make-field,
bibtex-next-field, bibtex-clean-entry): Every reference entry now
contains a comment in addition to the name of the reference. This
comment appears in the echo area if you start editing that field
(after calling bibtex-next-field).
(bibtex-include-OPTcrossref, bibtex-entry): Changed
bibtex-include-OPTcrossref from single boolean variable to hold a
list of reference names which should have a crossref field.
(bibtex-complete-word): New function, which completes word
fragment before point to the longest prefix of predefined strings
in the buffer in the same way that ispell-complete-word operates
for words found in the dictionary.
(bibtex-reference-head): Start of bibtex-reference-head changed
from "^[ \t]*\\(" to "^\\( \\|\t\\)*\\(" (bibtex-pop-previous and
bibtex-pop-next didn't work, probably due to a bug in
re-search-forward).
(several functions): Added support for {} as field delimiters
(better than '"' for accented characters.
(bibtex-clean-entry): If optional field crossref is empty or
missing, former optional fields (if bibtex-include-OPTcrossref was
t) are necessary again. bibtex-clean-entry complains if they are
empty but not if they are missing, so you can intenionally omit
them, e. g. for a pseudo @Journal entry (needed for
crossreferences) made out of an @article with missing non-optional
fields.
Menu bar entries aren't centered anymore.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 23 Dec 1994 04:18:29 +0000 |
parents | ad1c04ef7695 |
children | ac7375e60931 |
line wrap: on
line source
;;; resume.el --- process command line args from within a suspended Emacs job ;; Copyright (C) 1992 Free Software Foundation, Inc. ;; Author: Joe Wells <jbw@bucsf.bu.edu> ;; Adapted-By: ESR ;; Keywords: processes ;; This file is part of GNU Emacs. ;; GNU Emacs is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 1, or (at your option) ;; any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. ;;; Commentary: ;; Theory: the first time you start Emacs, command line arguments are ;; handled normally. Then, you suspend your emacs job. When you want to edit ;; something else, you type "emacs filename" as usual, but instead of ;; starting a new emacs job, the old job is resumed instead, and the command ;; line arguments are placed in a file where the old emacs job looks for ;; them. ;; Stephan Gildea suggested bug fix (gildea@bbn.com). ;; Ideas from Michael DeCorte and other people. ;; For csh users, insert the following alias in your .cshrc file ;; (after removing the leading double semicolons, of course): ;; ;;# The following line could be just EMACS_CMD=emacs, but this depends on ;;# your site. ;;if (! $?EMACS_CMD) set EMACS_CMD=emacs ;;set JOBS_FILE=/tmp/jobs.$USER.$$ ;;set ARGS_FILE=~/.emacs_args ;;set STOP_PATT='^\[[0-9]*\] *[ +-] Stopped ............ ' ;;set SUNVIEW_CMD='emacstool -nw -f emacstool-init -f server-start' ;;set X_CMD=\'\''$EMACS_CMD -i -f server-start' ;;alias emacs \ ;;' \\ ;; jobs >! "$JOBS_FILE" \\ ;; && grep "$STOP_PATT$EMACS_CMD" "$JOBS_FILE" >& /dev/null \\ ;; && echo `pwd` \!* >! "$ARGS_FILE" && ""fg %$EMACS_CMD \\ ;;|| if (! -e ~/.emacs_server || -f ~/.emacs_server) set status=1 \\ ;; && emacsclient \!* \\ ;;|| @ status=1 - $?DISPLAY && eval "$X_CMD -i \!* &" \\ ;;|| @ status=1 - $?WINDOW_PARENT && eval "$SUNVIEW_CMD \!* &" \\ ;;|| ""$EMACS_CMD -nw \!* \\ ;;' ;; ;; The alias works as follows: ;; 1. If there is a suspended Emacs job that is a child of the ;; current shell, place its arguments in the ~/.emacs_args file and ;; resume it. ;; 2. Else if the ~/.emacs_server socket has been created, presume an ;; Emacs server is running and attempt to connect to it. If no Emacs ;; server is listening on the socket, this will fail. ;; 3. Else if the DISPLAY environment variable is set, presume we are ;; running under X Windows and start a new GNU Emacs process in the ;; background as an X client. ;; 4. Else if the WINDOW_PARENT environment variable is set, presume we ;; are running under SunView and start an emacstool process in the ;; background. ;; 5. Else start a regular Emacs process. ;; ;; Notes: ;; The output of the "jobs" command is not piped directly into "grep" ;; because that would run the "jobs" command in a subshell. ;; Before resuming a suspended emacs, the current directory and all ;; command line arguments are placed in a file name ~/.emacs_args. ;; The "-nw" switch to Emacs means no windowing system. ;; Insert this in your .emacs file: ;;(add-hook 'suspend-hook 'resume-suspend-hook) ;; Finally, put the rest in a file named "resume.el" in a lisp library ;; directory. ;;; Code: (defvar resume-emacs-args-file (expand-file-name "~/.emacs_args") "*This file is where arguments are placed for a suspended emacs job.") (defvar resume-emacs-args-buffer " *Command Line Args*" "Buffer that is used by resume-process-args.") (defun resume-process-args () "Handler for command line args given when Emacs is resumed." (let ((start-buffer (current-buffer)) (args-buffer (get-buffer-create resume-emacs-args-buffer)) length args (command-line-default-directory default-directory)) (unwind-protect (progn (set-buffer args-buffer) (erase-buffer) ;; get the contents of resume-emacs-args-file (condition-case () (let ((result (insert-file-contents resume-emacs-args-file))) (setq length (car (cdr result)))) ;; the file doesn't exist, ergo no arguments (file-error (erase-buffer) (setq length 0))) (if (<= length 0) (setq args nil) ;; get the arguments from the buffer (goto-char (point-min)) (while (not (eobp)) (skip-chars-forward " \t\n") (let ((begin (point))) (skip-chars-forward "^ \t\n") (setq args (cons (buffer-substring begin (point)) args))) (skip-chars-forward " \t\n")) ;; arguments are now in reverse order (setq args (nreverse args)) ;; make sure they're not read again (erase-buffer)) (resume-write-buffer-to-file (current-buffer) resume-emacs-args-file) ;; if nothing was in buffer, args will be null (or (null args) (setq command-line-default-directory (file-name-as-directory (car args)) args (cdr args))) ;; actually process the arguments (command-line-1 args)) ;; If the command line args don't result in a find-file, the ;; buffer will be left in args-buffer. So we change back to the ;; original buffer. The reason I don't just use ;; (let ((default-directory foo)) ;; (command-line-1 args)) ;; in the context of the original buffer is because let does not ;; work properly with buffer-local variables. (if (eq (current-buffer) args-buffer) (set-buffer start-buffer))))) ;;;###autoload (defun resume-suspend-hook () "Clear out the file used for transmitting args when Emacs resumes." (save-excursion (set-buffer (get-buffer-create resume-emacs-args-buffer)) (erase-buffer) (resume-write-buffer-to-file (current-buffer) resume-emacs-args-file))) (defun resume-write-buffer-to-file (buffer file) "Writes the contents of BUFFER into FILE, if permissions allow." (if (not (file-writable-p file)) (error "No permission to write file %s" file)) (save-excursion (set-buffer buffer) (clear-visited-file-modtime) (save-restriction (widen) (write-region (point-min) (point-max) file nil 'quiet)) (set-buffer-modified-p nil))) (provide 'resume) ;;; resume.el ends here