Mercurial > emacs
annotate lisp/elide-head.el @ 58556:8ff63943e93e
(bibtex-sort-entry-class)
(bibtex-comment-start): Use defcustom.
(bibtex-entry-field-alist): Use nil if initial content of the
field is undefined. Fix docstring.
(bibtex-parse-keys-timeout, bibtex-autokey-additional-names)
(bibtex-generate-autokey, bibtex-parse-buffers-stealthily)
(bibtex-mode, bibtex-field-list, bibtex-entry-updat)
(bibtex-autofill-entry, bibtex-entry-index, bibtex-next-field):
Fix docstring.
(bibtex-autokey-title-terminators): Use only one regexp.
(bibtex-string-maybe-empty-head): New variable.
(bibtex-remove-delimiters-string): New function.
(bibtex-text-in-field-bounds, bibtex-text-in-string):
Use bibtex-remove-delimiters-string.
(bibtex-progress-message, bibtex-field-left-delimiter)
(bibtex-field-right-delimiter, bibtex-entry-left-delimiter)
(bibtex-entry-right-delimiter, bibtex-search-entry): Use eq.
(bibtex-insert-kill): Rename from `bibtex-insert-current-kill'.
Simplify.
(bibtex-format-entry): Use save-excursion for inherited booktitle.
Use eq and bibtex-remove-delimiters-string. For end markers use
insertion type so that marker stays after inserted text.
(bibtex-autokey-get-names): Return empty string if name is missing.
(bibtex-autokey-demangle-name): Call bibtex-autokey-abbrev before
calling bibtex-autokey-name-case-convert.
(bibtex-autokey-demangle-title):
Call bibtex-autokey-titleword-case-convert. Remove call to
bibtex-autokey-titleword-case-convert from bibtex-autokey-get-title.
(bibtex-global-key-alist, bibtex-read-string-key): New functions.
(bibtex-read-key): New optional arg global.
(bibtex-files-expand): New optional arg force.
(bibtex-complete-string-cleanup): Expansion of abbrev can be absent.
(bibtex-complete-crossref-cleanup): Rename from
bibtex-complete-key-cleanup. Simplify code.
(bibtex-copy-summary-as-kill): Remove arg key. Operate on current entry.
Use looking-at.
(bibtex-button): Add docstring.
(bibtex-entry): Simplify.
(bibtex-make-field): Replace optional arg called-by-yank with more
specific args move and interactive.
(bibtex-end-of-entry): Use forward-sexp.
(bibtex-find-entry-globally): Remove.
(bibtex-find-crossref): Allow for crossref key located in other buffer.
Bound to C-c C-x.
(bibtex-find-entry): New optional args global and display.
(bibtex-find-text): Fix docstring. Remove arg as-if-interactive.
(bibtex-validate): Use arg force of bibtex-files-expand.
(bibtex-clean-entry): Bugfix, clean string entries properly.
Always keep point at beginning of entry.
(bibtex-complete): Bugfix. Handle string entries properly.
Call cleanup functions only if needed.
(bibtex-String): Use bibtex-read-string-key.
(bibtex-url): Use bibtex-remove-delimiters-string. Do not alter
case of replacement text.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Fri, 26 Nov 2004 23:24:44 +0000 |
parents | d2b6a6d18cc9 |
children | 6fb026ad601f e24e2e78deda |
rev | line source |
---|---|
38436
b174db545cfd
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
35701
diff
changeset
|
1 ;;; elide-head.el --- hide headers in files |
26151 | 2 |
3 ;; Copyright (C) 1999 Free Software Foundation, Inc. | |
4 | |
5 ;; Author: Dave Love <fx@gnu.org> | |
6 ;; Keywords: outlines tools | |
7 | |
8 ;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
24 | |
25 ;;; Commentary: | |
26 | |
27 ;; Functionality for eliding boilerplate text (normally copyright | |
28 ;; notices) in file headers to avoid clutter when you know what it | |
29 ;; says. | |
30 ;; | |
31 ;; `elide-head-headers-to-hide' controls what is elided by the command | |
32 ;; `elide-head'. A buffer-local invisible overlay manages the | |
33 ;; elision. | |
34 | |
26700 | 35 ;; You might add `elide-head' to appropriate major mode hooks or to |
46899
f00337f04e78
Use find-file-hook instead of find-file-hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38436
diff
changeset
|
36 ;; `find-file-hook'. Please do not do this in site init files. If |
26703 | 37 ;; you do, information may be hidden from users who don't know it |
38 ;; already. | |
26151 | 39 |
26925 | 40 ;; Note that `hs-minor-mode' will do a similar job by default, but |
41 ;; it's not selective about what leading commentary it hides. | |
42 | |
26151 | 43 ;; Inspired by jwz's hide-copyleft.el, for which we don't have an |
44 ;; assignment. | |
45 | |
46 ;;; Code: | |
47 | |
48 (defgroup elide-head nil | |
49 "Eliding copyright headers and the like in source files." | |
27125 | 50 :version "21.1" |
26151 | 51 :prefix "elide-head" |
52 :group 'tools) | |
53 | |
54 (defcustom elide-head-headers-to-hide | |
55 '(("is free software; you can redistribute it" . ; GNU boilerplate | |
56 "Boston, MA 02111-1307, USA\\.") | |
57 ("The Regents of the University of California\\. All rights reserved\\." . | |
58 "SUCH DAMAGE\\.") ; BSD | |
59 ("Permission is hereby granted, free of charge" . ; X11 | |
60 "authorization from the X Consortium\\.")) | |
61 "Alist of regexps defining start end end of text to elide. | |
62 | |
63 The cars of elements of the list are searched for in order. Text is | |
64 elided with an invisible overlay from the end of the line where the | |
65 first match is found to the end of the match for the corresponding | |
66 cdr." | |
67 :group 'elide-head | |
68 :type '(alist :key-type (string :tag "Start regexp") | |
69 :value-type (string :tag "End regexp"))) | |
70 | |
71 (defvar elide-head-overlay nil) | |
72 (make-variable-buffer-local 'elide-head-overlay) | |
73 | |
74 ;;;###autoload | |
75 (defun elide-head (&optional arg) | |
76 "Hide header material in buffer according to `elide-head-headers-to-hide'. | |
77 | |
78 The header is made invisible with an overlay. With a prefix arg, show | |
79 an elided material again. | |
80 | |
46899
f00337f04e78
Use find-file-hook instead of find-file-hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38436
diff
changeset
|
81 This is suitable as an entry on `find-file-hook' or appropriate mode hooks." |
26151 | 82 (interactive "P") |
83 (if arg | |
84 (elide-head-show) | |
85 (save-excursion | |
86 (save-restriction | |
87 (let ((rest elide-head-headers-to-hide) | |
88 beg end) | |
89 (widen) | |
90 (goto-char (point-min)) | |
91 (while rest | |
92 (save-excursion | |
93 (when (re-search-forward (caar rest) nil t) | |
94 (setq beg (point)) | |
95 (when (re-search-forward (cdar rest) nil t) | |
27264
7c1aca21377a
(elide-head): Use point-marker, not point.
Dave Love <fx@gnu.org>
parents:
27125
diff
changeset
|
96 (setq end (point-marker) |
26151 | 97 rest nil)))) |
98 (if rest (setq rest (cdr rest)))) | |
99 (if (not (and beg end)) | |
100 (if (interactive-p) | |
57751
d2b6a6d18cc9
(elide-head): Change error to message.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
101 (message "No header found")) |
26151 | 102 (goto-char beg) |
103 (end-of-line) | |
104 (if (overlayp elide-head-overlay) | |
27264
7c1aca21377a
(elide-head): Use point-marker, not point.
Dave Love <fx@gnu.org>
parents:
27125
diff
changeset
|
105 (move-overlay elide-head-overlay (point-marker) end) |
27578
e3f24c47fbcd
(elide-head): Use point-marker more.
Dave Love <fx@gnu.org>
parents:
27264
diff
changeset
|
106 (setq elide-head-overlay (make-overlay (point-marker) end))) |
26151 | 107 (overlay-put elide-head-overlay 'invisible t) |
35701
96fb197c6aff
(elide-head): Make overlay evaporate.
Dave Love <fx@gnu.org>
parents:
27578
diff
changeset
|
108 (overlay-put elide-head-overlay 'evaporate t) |
26151 | 109 (overlay-put elide-head-overlay 'after-string "..."))))))) |
110 | |
111 (defun elide-head-show () | |
112 "Show a header elided current buffer by \\[elide-head]." | |
113 (interactive) | |
114 (if (and (overlayp elide-head-overlay) | |
115 (overlay-buffer elide-head-overlay)) | |
116 (delete-overlay elide-head-overlay) | |
117 (if (interactive-p) | |
57751
d2b6a6d18cc9
(elide-head): Change error to message.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
118 (message "No header hidden")))) |
26151 | 119 |
120 (provide 'elide-head) | |
121 | |
52401 | 122 ;;; arch-tag: a00e6b5b-6aeb-45b1-b734-63e23df80928 |
26151 | 123 ;;; elide-head.el ends here |