Mercurial > emacs
view lisp/ebuff-menu.el @ 13728:4b7903cfa7ee
(bibtex-auto-fill-function): Adapted for use with
changed autofill policy of emacs-19.30 (uses now fill-prefix
instead of indent-line-function).
(bibtex-indent-line-function): Removed (not used any more).
(bibtex-make-field): Was broken when called
non-interactively.
(bibtex-make-field): Point is now placed on closing
brace or quote (suggested by Karl Eichwalder <ke@ke.Central.DE>).
(bibtex-clean-entry): Comma after last field isn't
deleted anymore (new standard in BibTeX 0.99 and 1.xx).
(bibtex-enclosing-reference-maybe-empty-head): Works with entries
with comma after last field.
(bibtex-reference): Permits entries with comma after last field.
(bibtex-font-lock-keywords): Enhanced to support new field-name
characters (suggested by Martin Maechler
<maechler@stat.math.ethz.ch>).
(bibtex-field-name): Now numbers (not as the first sign), dashes,
and underscores are allowed (suggested by Martin Maechler
<maechler@stat.math.ethz.ch> and Oren Patashnik
<opbibtex@labrea.Stanford.EDU>).
(bibtex-make-field): Was broken on lines containing
non-parenthesized entries (reported by Karl Eichwalder
<ke@ke.Central.DE>).
(bibtex-validate-buffer): Changed so that preamble
references are ignored (same as string entries) (reported by
Martin Maechler <maechler@stat.math.ethz.ch>).
(bibtex-enclosing-reference-maybe-empty-head):
New function to be used in case reference head may be empty.
(bibtex-clean-entry, bibtex-pop-previous, bibtex-pop-next): Uses
now bibtex-enclosing-reference-maybe-empty-head.
(bibtex-mode): Added support for font-lock mode.
(bibtex-font-lock-keywords): New variable with font-lock keywords
for BibTeX mode.
(bibtex-make-optional-field): Not longer interactive
(suggested by Karl Eichwalder <karl@pertron.central.de>).
(bibtex-maintain-sorted-entries): Set to nil, since it
requires more user attention and more restricted files to have
this set to t.
(bibtex-maintain-sorted-entries,
bibtex-sort-ignore-string-entries): Made buffer local, since it
may depend on the buffer which preferences to use.
(bibtex-validate-buffer): Looking for correct sort order only when
bibtex-maintain-sorted-entries is non-nil.
Put a comment in the `KNOWN BUGS' section about the
quote-inside-quotes problem.
(whole file): Changed string `true' in some documentation strings
to `non-nil' (e.g. `if variable has a true/non-nil value').
(bibtex-mode-map): Changed `move/edit' to `bibtex-edit'.
(bibtex-sort-entries): Now works correctly with
`@String' entries inside BibTeX files (i.e. after the occurence of
other references).
(bibtex-validate-buffer): Inserted code which looks if entries are
balanced (a single non-escaped quote inside braces was not
detected till now, but bibtex-sort-entries stumbles about it).
(bibtex-entry): bibtex-move-outside-of-entry is only
called when bibtex-maintain-sorted-entries is nil (otherwise
bibtex-find-entry-location determines the correct location).
(bibtex-find-entry-location): Now uses binary search. As before,
it assumes that the buffer is sorted without duplicates (but as
before it is only called when bibtex-maintain-sorted-entries is
t). Ignores `@String' entries if told so via variable
bibtex-sort-ignore-string-entries.
(bibtex-clean-entry): Respect
bibtex-maintain-sorted-entries when inserting autokey.
(bibtex-validate-buffer): Searching whole buffer for duplicates
and correct order is now done directly instead of calling
bibtex-find-entry-location (since this is to be reprogrammed to
use a binary search instead a sequential one).
(bibtex-parse-keys): May now be called with an
optional parameter which (if t) tells bibtex-parse-keys that it
should abort if input is pending.
(bibtex-mode): The instance of bibtex-parse-keys called in
auto-save-mode-hook is now called with this new parameter set to
t, so an auto-save caused by exceeding auto-save-interval is now
aborted immediately if user is still typing.
(bibtex-print-help-message, bibtex-clean-entry): Use
now constant strings instead of custom ones.
(bibtex-clean-entry): Changed the call of
bibtex-enclosing-reference to a more specific call so entries
without a key (here allowed) can be handled.
(bibtex-reference-key): Cleared off parentheses (caused string
entries enclosed by parentheses instead of braces to be not added
to bibtex-completion-candidates).
(bibtex-complete-string): Made it use bibtex-string.
(bibtex-keys,
bibtex-buffer-last-parsed-for-keys-tick): New buffer-local
variables to make parsing of BibTeX buffer for reference keys
(needed by TAB completion in minibuffer when entering key) more
occasional.
(bibtex-parse-keys): New function to parse for keys (functionality
was partially included in bibtex-entry).
(bibtex-entry): Changed to use bibtex-parse-keys.
(bibtex-mode): Installs bibtex-parse-keys as an
auto-save-mode-hook, so whole buffer is parsed at most when it is
autosaved.
(bibtex-clean-entry): Calls bibtex-parse-keys on the new entry, so
bibtex-keys remains consistent for new entries that are finished
by calling this function (most should).
(bibtex-inside-field): Be independent on current
setting of bibtex-field-right-delimiter (allows more intermixing
between quotes and braces).
(bibtex-make-field): Last change didn't make it work correctly
when called non-interactively by bibtex-entry (fixed).
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Wed, 13 Dec 1995 20:26:13 +0000 |
parents | 94ee086557db |
children | 83f275dcd93a |
line wrap: on
line source
;;; ebuff-menu.el --- electric-buffer-list mode ;; Copyright (C) 1985, 1986, 1994 Free Software Foundation, Inc. ;; Author: Richard Mlynarik <mly@ai.mit.edu> ;; 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 2, 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: ;; Who says one can't have typeout windows in GNU Emacs? The entry ;; point, `electric-buffer-list' works like ^r select buffer from the ;; ITS Emacs lunar or tmacs libraries. ;;; Code: (require 'electric) ;; this depends on the format of list-buffers (from src/buffer.c) and ;; on stuff in lisp/buff-menu.el (defvar electric-buffer-menu-mode-map nil) ;;;###autoload (defun electric-buffer-list (arg) "Pops up a buffer describing the set of Emacs buffers. Vaguely like ITS lunar select buffer; combining typeoutoid buffer listing with menuoid buffer selection. If the very next character typed is a space then the buffer list window disappears. Otherwise, one may move around in the buffer list window, marking buffers to be selected, saved or deleted. To exit and select a new buffer, type a space when the cursor is on the appropriate line of the buffer-list window. Other commands are much like those of buffer-menu-mode. Calls value of `electric-buffer-menu-mode-hook' on entry if non-nil. \\{electric-buffer-menu-mode-map}" (interactive "P") (let (select buffer) (save-window-excursion (save-window-excursion (list-buffers arg)) (setq buffer (window-buffer (Electric-pop-up-window "*Buffer List*"))) (unwind-protect (progn (set-buffer buffer) (Electric-buffer-menu-mode) (setq select (catch 'electric-buffer-menu-select (message "<<< Press Return to bury the buffer list >>>") (if (eq (setq unread-command-events (list (read-event))) ?\ ) (progn (setq unread-command-events nil) (throw 'electric-buffer-menu-select nil))) (let ((start-point (point)) (first (progn (goto-char (point-min)) (forward-line 2) (point))) (last (progn (goto-char (point-max)) (forward-line -1) (point))) (goal-column 0)) ;; Use start-point if it is meaningful. (goto-char (if (or (< start-point first) (> start-point last)) first start-point)) (Electric-command-loop 'electric-buffer-menu-select nil t 'electric-buffer-menu-looper (cons first last)))))) (set-buffer buffer) (Buffer-menu-mode) (bury-buffer buffer) (message ""))) (if select (progn (set-buffer buffer) (let ((opoint (point-marker))) (Buffer-menu-execute) (goto-char (point-min)) (if (prog1 (search-forward "\n>" nil t) (goto-char opoint) (set-marker opoint nil)) (Buffer-menu-select) (switch-to-buffer (Buffer-menu-buffer t)))))))) (defun electric-buffer-menu-looper (state condition) (cond ((and condition (not (memq (car condition) '(buffer-read-only end-of-buffer beginning-of-buffer)))) (signal (car condition) (cdr condition))) ((< (point) (car state)) (goto-char (point-min)) (forward-line 2)) ((> (point) (cdr state)) (goto-char (point-max)) (forward-line -1) (if (pos-visible-in-window-p (point-max)) (recenter -1))))) (put 'Electric-buffer-menu-mode 'mode-class 'special) (defun Electric-buffer-menu-mode () "Major mode for editing a list of buffers. Each line describes one of the buffers in Emacs. Letters do not insert themselves; instead, they are commands. \\<electric-buffer-menu-mode-map> \\[keyboard-quit] or \\[Electric-buffer-menu-quit] -- exit buffer menu, returning to previous window and buffer configuration. If the very first character typed is a space, it also has this effect. \\[Electric-buffer-menu-select] -- select buffer of line point is on. Also show buffers marked with m in other windows, deletes buffers marked with \"D\", and saves those marked with \"S\". \\[Buffer-menu-mark] -- mark buffer to be displayed. \\[Buffer-menu-not-modified] -- clear modified-flag on that buffer. \\[Buffer-menu-save] -- mark that buffer to be saved. \\[Buffer-menu-delete] or \\[Buffer-menu-delete-backwards] -- mark that buffer to be deleted. \\[Buffer-menu-unmark] -- remove all kinds of marks from current line. \\[Electric-buffer-menu-mode-view-buffer] -- view buffer, returning when done. \\[Buffer-menu-backup-unmark] -- back up a line and remove marks. \\{electric-buffer-menu-mode-map} Entry to this mode via command electric-buffer-list calls the value of electric-buffer-menu-mode-hook if it is non-nil." (kill-all-local-variables) (use-local-map electric-buffer-menu-mode-map) (setq mode-name "Electric Buffer Menu") (setq mode-line-buffer-identification "Electric Buffer List") (make-local-variable 'Helper-return-blurb) (setq Helper-return-blurb "return to buffer editing") (setq truncate-lines t) (setq buffer-read-only t) (setq major-mode 'Electric-buffer-menu-mode) (goto-char (point-min)) (if (search-forward "\n." nil t) (forward-char -1)) (run-hooks 'electric-buffer-menu-mode-hook)) ;; generally the same as Buffer-menu-mode-map ;; (except we don't indirect to global-map) (put 'Electric-buffer-menu-undefined 'suppress-keymap t) (if electric-buffer-menu-mode-map nil (let ((map (make-keymap)) (submap (make-keymap))) (fillarray (car (cdr map)) 'Electric-buffer-menu-undefined) (define-key map "\e" submap) (fillarray (car (cdr submap)) 'Electric-buffer-menu-undefined) (define-key map "\C-z" 'suspend-emacs) (define-key map "v" 'Electric-buffer-menu-mode-view-buffer) (define-key map (char-to-string help-char) 'Helper-help) (define-key map "?" 'Helper-describe-bindings) (define-key map "\C-c" nil) (define-key map "\C-c\C-c" 'Electric-buffer-menu-quit) (define-key map "\C-]" 'Electric-buffer-menu-quit) (define-key map "q" 'Electric-buffer-menu-quit) (define-key map " " 'Electric-buffer-menu-select) (define-key map "\C-m" 'Electric-buffer-menu-select) (define-key map "\C-l" 'recenter) (define-key map "s" 'Buffer-menu-save) (define-key map "d" 'Buffer-menu-delete) (define-key map "k" 'Buffer-menu-delete) (define-key map "\C-d" 'Buffer-menu-delete-backwards) ;(define-key map "\C-k" 'Buffer-menu-delete) (define-key map "\177" 'Buffer-menu-backup-unmark) (define-key map "~" 'Buffer-menu-not-modified) (define-key map "u" 'Buffer-menu-unmark) (let ((i ?0)) (while (<= i ?9) (define-key map (char-to-string i) 'digit-argument) (define-key map (concat "\e" (char-to-string i)) 'digit-argument) (setq i (1+ i)))) (define-key map "-" 'negative-argument) (define-key map "\e-" 'negative-argument) (define-key map "m" 'Buffer-menu-mark) (define-key map "\C-u" 'universal-argument) (define-key map "\C-p" 'previous-line) (define-key map "\C-n" 'next-line) (define-key map "p" 'previous-line) (define-key map "n" 'next-line) (define-key map "\C-v" 'scroll-up) (define-key map "\ev" 'scroll-down) (define-key map ">" 'scroll-right) (define-key map "<" 'scroll-left) (define-key map "\e\C-v" 'scroll-other-window) (define-key map "\e>" 'end-of-buffer) (define-key map "\e<" 'beginning-of-buffer) (define-key map "\e\e" nil) (define-key map "\e\e\e" 'Electric-buffer-menu-quit) (define-key map [escape escape escape] 'Electric-buffer-menu-quit) (define-key map [mouse-2] 'Electric-buffer-menu-mouse-select) (setq electric-buffer-menu-mode-map map))) (defun Electric-buffer-menu-exit () (interactive) (setq unread-command-events (listify-key-sequence (this-command-keys))) ;; for robustness (condition-case () (throw 'electric-buffer-menu-select nil) (error (Buffer-menu-mode) (other-buffer)))) (defun Electric-buffer-menu-select () "Leave Electric Buffer Menu, selecting buffers and executing changes. Saves buffers marked \"S\". Deletes buffers marked \"K\". Selects buffer at point and displays buffers marked \">\" in other windows." (interactive) (throw 'electric-buffer-menu-select (point))) (defun Electric-buffer-menu-mouse-select (event) (interactive "e") (select-window (posn-window (event-end event))) (set-buffer (window-buffer (selected-window))) (goto-char (posn-point (event-end event))) (throw 'electric-buffer-menu-select (point))) (defun Electric-buffer-menu-quit () "Leave Electric Buffer Menu, restoring previous window configuration. Does not execute select, save, or delete commands." (interactive) (throw 'electric-buffer-menu-select nil)) (defun Electric-buffer-menu-undefined () (interactive) (ding) (message (if (and (eq (key-binding "\C-c\C-c") 'Electric-buffer-menu-quit) (eq (key-binding " ") 'Electric-buffer-menu-select) (eq (key-binding (char-to-string help-char)) 'Helper-help) (eq (key-binding "?") 'Helper-describe-bindings)) (substitute-command-keys "Type C-c C-c to exit, Space to select, \\[Helper-help] for help, ? for commands") (substitute-command-keys "\ Type \\[Electric-buffer-menu-quit] to exit, \ \\[Electric-buffer-menu-select] to select, \ \\[Helper-help] for help, \\[Helper-describe-bindings] for commands."))) (sit-for 4)) (defun Electric-buffer-menu-mode-view-buffer () "View buffer on current line in Electric Buffer Menu. Returns to Electric Buffer Menu when done." (interactive) (let ((bufnam (Buffer-menu-buffer nil))) (if bufnam (view-buffer bufnam) (ding) (message "Buffer %s does not exist!" bufnam) (sit-for 4)))) ;;; ebuff-menu.el ends here