annotate lisp/elide-head.el @ 31383:860d7ac182e3

(vc-rcs-show-log-entry): New function. (vc-rcs-checkin, vc-rcs-checkout): Don't set all properties. (vc-rcs-register): If there is no RCS subdir, ask the user whether to create one. (vc-rcs-state-heuristic): Use file-ownership-preserved-p. (vc-rcs-checkout): Remove the error-handling for missing-rcs. (vc-rcs-state-heuristic): Don't use file-writable-p. (vc-rcs-print-log): Insert in the current buffer. (vc-rcs-diff): Insert in the current buffer and remove unused arg CMP. (vc-rcs-workfile-unchanged-p): Use vc-do-command instead of vc-simple-command. (vc-rcs-fetch-master-state): Removed check for unlocked-changes to avoid doing a diff when opening a file. (vc-rcs-state): Added check for unlocked-changes. (vc-rcs-header): Escape Id. (vc-rcs-workfile-unchanged-p): Remove optional arg VERSION. (vc-rcs-state): Call vc-workfile-unchanged-p, not the RCS-specific version. (vc-rcs-state-heuristic): Use file-writable-p instead of comparing userids. (vc-rcs-fetch-master-state): Handle the case where rcs is missing. Simplify the logic by eliminating unreachable code. (vc-rcs-diff): Only pass `2' to vc-do-command if necessary and just do a recursive call if we need to retry. (vc-rcs-checkout): Handle the case where rcs is missing by making the buffer read-write if requested and re-signalling the error. (vc-rcs-find-most-recent-rev): New function. The code derives from the old vc-parse-buffer but uses the revision number rather than the date (much easier to compare robustly). (vc-rcs-fetch-master-state): Use `with-temp-buffer'. Adapt to the new vc-parse-buffer (and vc-rcs-find-most-recent-rev). Find the locking-user more directly. Check strict locking and set checkout-model appropriately. (vc-rcs-parse-locks): Remove. (vc-rcs-latest-on-branch-p): Use with-temp-buffer and adapt to the new vc-parse-buffer (and vc-rcs-find-most-recent-rev). (vc-rcs-system-release): Use with-current-buffer and vc-parse-buffer. (vc-rcs-register, vc-rcs-checkout): Use with-current-buffer. Merge in code from vc-rcs-hooks.el. Don't require 'vc anymore. (vc-rcs-responsible-p): Use expand-file-name instead of concat and file-directory-p instead of file-exists-p. (vc-rcs-exists): Remove. (vc-rcs-header): New var. Update Copyright. (vc-rcs-rename-file): New function. (vc-rcs-diff): Remove unused `backend' variable. (vc-rcs-clear-headers): New function; code moved here from vc-clear-headers in vc.el. (tail): Provide vc-rcs and remove vc-rcs-logentry-check. (vc-rcs-register): Parse command output to find master file name and workfile version. (vc-rcs-checkout): Removed call to vc-file-clear-masterprops. Require vc and vc-rcs-hooks. (vc-rcs-trunk-p, vc-rcs-branch-part): Move to vc-rcs-hooks. (vc-rcs-backend-release-p): Remove (use vc-rcs-release-p). (vc-release-greater-or-equal-p): Move from vc. (vc-rcs-trunk-p, vc-rcs-branch-p, vc-rcs-branch-part, vc-rcs-minor-part, vc-rcs-previous-version): Remove duplicates. (vc-rcs-checkout): Add a missing `new-version' argument in the call to vc-rcs-latest-on-branch-p. Hopefully that was the right one. (vc-rcs-steal-lock): Renamed from `vc-rcs-steal'. Updated everything to use `vc-checkout-model'. (vc-rcs-backend-release-p): function added. other stuff updated to reference this function instead of the old `vc-backend-release-p'. (vc-rcs-logentry-check): Function added. (vc-rcs-checkin, vc-rcs-previous-version) (vc-rcs-checkout): Name space cleaned up. No more revision number crunching function names that are not prefixed with vc-rcs. (vc-rcs-checkout-model): Function added. References to `vc-checkout-model' replaced. (vc-rcs-admin): Added the query-only option as required by the vc.el file. (vc-rcs-exists): Function added. (vc-*-checkout): Use with-temp-file instead of /bin/sh. Merged from mainline (vc-rcs-latest-on-branch-p): Moved to vc-rcs-hooks.el. (vc-rcs-latest-on-branch-p, vc-rcs-trunk-p) (vc-rcs-branch-p, vc-rcs-branch-part, vc-rcs-minor-part) (vc-rcs-previous-version): Functions added. (vc-rcs-diff): Function added. (vc-rcs-checkout) Bug (typo) found and fixed. (vc-rcs-register-switches) Variable `vc-rcs-register-switches' added. Require vc when compiling. (vc-rcs-print-log, vc-rcs-assign-name, vc-rcs-merge) (vc-rcs-check-headers, vc-rcs-steal, vc-rcs-uncheck, vc-rcs-revert) (vc-rcs-checkin): New functions (code from vc.el). (vc-rcs-previous-version, vc-rcs-system-release, vc-rcs-checkout): Doc fix. (vc-rcs-release): Deleted. (Duplicated vc-rcs-system-release). (vc-rcs-trunk-p, vc-rcs-branch-p, vc-rcs-branch-part) (vc-rcs-minor-part, vc-rcs-previous-version, vc-rcs-release) (vc-rcs-release-p, vc-rcs-admin, vc-rcs-checkout): New functions from vc.el. (vc-rcs-system-release): Renamed from vc-rcs-backend-release.
author Gerd Moellmann <gerd@gnu.org>
date Mon, 04 Sep 2000 19:47:43 +0000
parents e3f24c47fbcd
children 96fb197c6aff
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26151
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
1 ;;; elid-head.el --- hide headers in files
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
2
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
3 ;; Copyright (C) 1999 Free Software Foundation, Inc.
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
4
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
5 ;; Author: Dave Love <fx@gnu.org>
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
6 ;; Keywords: outlines tools
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
7
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
9
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
13 ;; any later version.
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
14
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
19
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
23 ;; Boston, MA 02111-1307, USA.
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
24
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
25 ;;; Commentary:
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
26
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
27 ;; Functionality for eliding boilerplate text (normally copyright
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
28 ;; notices) in file headers to avoid clutter when you know what it
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
29 ;; says.
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
30 ;;
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
31 ;; `elide-head-headers-to-hide' controls what is elided by the command
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
32 ;; `elide-head'. A buffer-local invisible overlay manages the
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
33 ;; elision.
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
34
26700
61f2605f9e41 Comments only.
Dave Love <fx@gnu.org>
parents: 26151
diff changeset
35 ;; You might add `elide-head' to appropriate major mode hooks or to
26703
b8145f3d528e Fix commentary.
Dave Love <fx@gnu.org>
parents: 26700
diff changeset
36 ;; `find-file-hooks'. Please do not do this in site init files. If
b8145f3d528e Fix commentary.
Dave Love <fx@gnu.org>
parents: 26700
diff changeset
37 ;; you do, information may be hidden from users who don't know it
b8145f3d528e Fix commentary.
Dave Love <fx@gnu.org>
parents: 26700
diff changeset
38 ;; already.
26151
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
39
26925
4364c74ee502 Comment.
Dave Love <fx@gnu.org>
parents: 26703
diff changeset
40 ;; Note that `hs-minor-mode' will do a similar job by default, but
4364c74ee502 Comment.
Dave Love <fx@gnu.org>
parents: 26703
diff changeset
41 ;; it's not selective about what leading commentary it hides.
4364c74ee502 Comment.
Dave Love <fx@gnu.org>
parents: 26703
diff changeset
42
26151
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
43 ;; Inspired by jwz's hide-copyleft.el, for which we don't have an
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
44 ;; assignment.
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
45
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
46 ;;; Code:
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
47
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
48 (defgroup elide-head nil
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
49 "Eliding copyright headers and the like in source files."
27125
4b3c83c489cf (elide-head): Add :version.
Dave Love <fx@gnu.org>
parents: 26925
diff changeset
50 :version "21.1"
26151
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
51 :prefix "elide-head"
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
52 :group 'tools)
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
53
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
54 (defcustom elide-head-headers-to-hide
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
55 '(("is free software; you can redistribute it" . ; GNU boilerplate
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
56 "Boston, MA 02111-1307, USA\\.")
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
57 ("The Regents of the University of California\\. All rights reserved\\." .
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
58 "SUCH DAMAGE\\.") ; BSD
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
59 ("Permission is hereby granted, free of charge" . ; X11
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
60 "authorization from the X Consortium\\."))
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
61 "Alist of regexps defining start end end of text to elide.
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
62
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
63 The cars of elements of the list are searched for in order. Text is
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
64 elided with an invisible overlay from the end of the line where the
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
65 first match is found to the end of the match for the corresponding
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
66 cdr."
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
67 :group 'elide-head
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
68 :type '(alist :key-type (string :tag "Start regexp")
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
69 :value-type (string :tag "End regexp")))
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
70
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
71 (defvar elide-head-overlay nil)
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
72 (make-variable-buffer-local 'elide-head-overlay)
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
73
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
74 ;;;###autoload
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
75 (defun elide-head (&optional arg)
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
76 "Hide header material in buffer according to `elide-head-headers-to-hide'.
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
77
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
78 The header is made invisible with an overlay. With a prefix arg, show
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
79 an elided material again.
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
80
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
81 This is suitable as an entry on `find-file-hooks' or appropriate mode hooks."
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
82 (interactive "P")
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
83 (if arg
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
84 (elide-head-show)
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
85 (save-excursion
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
86 (save-restriction
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
87 (let ((rest elide-head-headers-to-hide)
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
88 beg end)
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
89 (widen)
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
90 (goto-char (point-min))
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
91 (while rest
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
92 (save-excursion
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
93 (when (re-search-forward (caar rest) nil t)
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
94 (setq beg (point))
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
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
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
97 rest nil))))
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
98 (if rest (setq rest (cdr rest))))
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
99 (if (not (and beg end))
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
100 (if (interactive-p)
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
101 (error "No header found"))
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
102 (goto-char beg)
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
103 (end-of-line)
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
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
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
107 (overlay-put elide-head-overlay 'invisible t)
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
108 (overlay-put elide-head-overlay 'intangible t)
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
109 (overlay-put elide-head-overlay 'after-string "...")))))))
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
110
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
111 (defun elide-head-show ()
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
112 "Show a header elided current buffer by \\[elide-head]."
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
113 (interactive)
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
114 (if (and (overlayp elide-head-overlay)
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
115 (overlay-buffer elide-head-overlay))
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
116 (delete-overlay elide-head-overlay)
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
117 (if (interactive-p)
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
118 (error "No header hidden"))))
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
119
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
120 (provide 'elide-head)
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
121
983ad33e1d97 *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
122 ;;; elide-head.el ends here