38422
|
1 ;;; pcvs-util.el --- utility functions for PCL-CVS -*- byte-compile-dynamic: t -*-
|
28088
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
2
|
35166
|
3 ;; Copyright (C) 1991,92,93,94,95,96,97,98,99,2000, 2001
|
|
4 ;; Free Software Foundation, Inc.
|
28088
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
5
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
6 ;; Author: Stefan Monnier <monnier@cs.yale.edu>
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
7 ;; Keywords: pcl-cvs
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
8
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
9 ;; This file is part of GNU Emacs.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
10
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
12 ;; it under the terms of the GNU General Public License as published by
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
13 ;; the Free Software Foundation; either version 2, or (at your option)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
14 ;; any later version.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
15
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
16 ;; GNU Emacs is distributed in the hope that it will be useful,
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
19 ;; GNU General Public License for more details.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
20
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
21 ;; You should have received a copy of the GNU General Public License
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
24 ;; Boston, MA 02111-1307, USA.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
25
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
26 ;;; Commentary:
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
27
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
28
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
29 ;;; Code:
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
30
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
31 (eval-when-compile (require 'cl))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
32
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
33 ;;;;
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
34 ;;;; list processing
|
33229
|
35 ;;;;
|
28088
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
36
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
37 (defsubst cvs-car (x) (if (consp x) (car x) x))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
38 (defalias 'cvs-cdr 'cdr-safe)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
39 (defsubst cvs-append (&rest xs)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
40 (apply 'append (mapcar (lambda (x) (if (listp x) x (list x))) xs)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
41
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
42 (defsubst cvs-every (-cvs-every-f -cvs-every-l)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
43 (while (consp -cvs-every-l)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
44 (unless (funcall -cvs-every-f (pop -cvs-every-l))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
45 (setq -cvs-every-l t)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
46 (not -cvs-every-l))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
47
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
48 (defun cvs-union (xs ys)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
49 (let ((zs ys))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
50 (dolist (x xs zs)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
51 (unless (member x ys) (push x zs)))))
|
49597
|
52
|
28088
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
53
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
54 (defun cvs-map (-cvs-map-f &rest -cvs-map-ls)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
55 (unless (cvs-every 'null -cvs-map-ls)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
56 (cons (apply -cvs-map-f (mapcar 'car -cvs-map-ls))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
57 (apply 'cvs-map -cvs-map-f (mapcar 'cdr -cvs-map-ls)))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
58
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
59 (defun cvs-first (l &optional n)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
60 (if (null n) (car l)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
61 (when l
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
62 (let* ((nl (list (pop l)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
63 (ret nl))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
64 (while (and l (> n 1))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
65 (setcdr nl (list (pop l)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
66 (setq nl (cdr nl))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
67 (decf n))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
68 ret))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
69
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
70 (defun cvs-partition (p l)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
71 "Partition a list L into two lists based on predicate P.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
72 The function returns a `cons' cell where the `car' contains
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
73 elements of L for which P is true while the `cdr' contains
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
74 the other elements. The ordering among elements is maintained."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
75 (let (car cdr)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
76 (dolist (x l)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
77 (if (funcall p x) (push x car) (push x cdr)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
78 (cons (nreverse car) (nreverse cdr))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
79
|
33229
|
80 ;; Copied from CL ;-(
|
|
81
|
|
82 (defun cvs-butlast (x &optional n)
|
|
83 "Returns a copy of LIST with the last N elements removed."
|
|
84 (if (and n (<= n 0)) x
|
|
85 (cvs-nbutlast (copy-sequence x) n)))
|
|
86
|
|
87 (defun cvs-nbutlast (x &optional n)
|
|
88 "Modifies LIST to remove the last N elements."
|
|
89 (let ((m (length x)))
|
|
90 (or n (setq n 1))
|
|
91 (and (< n m)
|
|
92 (progn
|
|
93 (if (> n 0) (setcdr (nthcdr (- (1- m) n) x) nil))
|
|
94 x))))
|
|
95
|
34407
|
96 ;;;
|
|
97 ;;; frame, window, buffer handling
|
|
98 ;;;
|
28088
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
99
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
100 (defun cvs-pop-to-buffer-same-frame (buf)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
101 "Pop to BUF like `pop-to-buffer' but staying on the same frame.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
102 If `pop-to-buffer' would have opened a new frame, this function would
|
34407
|
103 try to split a new window instead."
|
28088
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
104 (let ((pop-up-windows (or pop-up-windows pop-up-frames))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
105 (pop-up-frames nil))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
106 (or (let ((buf (get-buffer-window buf))) (and buf (select-window buf)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
107 (and pop-up-windows
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
108 (ignore-errors (select-window (split-window-vertically)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
109 (switch-to-buffer buf))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
110 (pop-to-buffer (current-buffer)))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
111
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
112 (defun cvs-bury-buffer (buf &optional mainbuf)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
113 "Hide the buffer BUF that was temporarily popped up.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
114 BUF is assumed to be a temporary buffer used from the buffer MAINBUF."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
115 (interactive (list (current-buffer)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
116 (save-current-buffer
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
117 (let ((win (if (eq buf (window-buffer (selected-window))) (selected-window)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
118 (get-buffer-window buf t))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
119 (when win
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
120 (if (window-dedicated-p win)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
121 (condition-case ()
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
122 (delete-window win)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
123 (error (iconify-frame (window-frame win))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
124 (if (and mainbuf (get-buffer-window mainbuf))
|
36614
|
125 ;; FIXME: if the buffer popped into a pre-existing window,
|
|
126 ;; we don't want to delete that window.
|
36906
|
127 t ;;(delete-window win)
|
36614
|
128 ))))
|
28088
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
129 (with-current-buffer buf
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
130 (bury-buffer (unless (and (eq buf (window-buffer (selected-window)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
131 (not (window-dedicated-p (selected-window))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
132 buf)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
133 (when mainbuf
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
134 (let ((mainwin (or (get-buffer-window mainbuf)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
135 (get-buffer-window mainbuf 'visible))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
136 (when mainwin (select-window mainwin))))))
|
49597
|
137
|
28088
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
138 (defun cvs-get-buffer-create (name &optional noreuse)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
139 "Create a buffer NAME unless such a buffer already exists.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
140 If the NAME looks like an absolute file name, the buffer will be created
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
141 with `create-file-buffer' and will probably get another name than NAME.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
142 In such a case, the search for another buffer with the same name doesn't
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
143 use the buffer name but the buffer's `list-buffers-directory' variable.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
144 If NOREUSE is non-nil, always return a new buffer."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
145 (or (and (not (file-name-absolute-p name)) (get-buffer-create name))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
146 (unless noreuse
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
147 (dolist (buf (buffer-list))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
148 (with-current-buffer buf
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
149 (when (equal name list-buffers-directory)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
150 (return buf)))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
151 (with-current-buffer (create-file-buffer name)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
152 (set (make-local-variable 'list-buffers-directory) name)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
153 (current-buffer))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
154
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
155 ;;;;
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
156 ;;;; string processing
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
157 ;;;;
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
158
|
33229
|
159 (defun cvs-insert-strings (strings)
|
|
160 "Insert a list of STRINGS into the current buffer.
|
|
161 Uses columns to keep the listing readable but compact."
|
|
162 (when (consp strings)
|
|
163 (let* ((length (apply 'max (mapcar 'length strings)))
|
|
164 (wwidth (1- (window-width)))
|
|
165 (columns (min
|
|
166 ;; At least 2 columns; at least 2 spaces between columns.
|
|
167 (max 2 (/ wwidth (+ 2 length)))
|
|
168 ;; Don't allocate more columns than we can fill.
|
37338
|
169 ;; Windows can't show less than 3 lines anyway.
|
33229
|
170 (max 1 (/ (length strings) 2))))
|
|
171 (colwidth (/ wwidth columns)))
|
37338
|
172 ;; Use tab-width rather than indent-to.
|
33229
|
173 (setq tab-width colwidth)
|
|
174 ;; The insertion should be "sensible" no matter what choices were made.
|
|
175 (dolist (str strings)
|
|
176 (unless (bolp) (insert " \t"))
|
|
177 (when (< wwidth (+ (max colwidth (length str)) (current-column)))
|
|
178 (delete-char -2) (insert "\n"))
|
|
179 (insert str)))))
|
|
180
|
|
181
|
28088
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
182 (defun cvs-file-to-string (file &optional oneline args)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
183 "Read the content of FILE and return it as a string.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
184 If ONELINE is t, only the first line (no \\n) will be returned.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
185 If ARGS is non-nil, the file will be executed with ARGS as its
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
186 arguments. If ARGS is not a list, no argument will be passed."
|
41780
|
187 (condition-case nil
|
|
188 (with-temp-buffer
|
|
189 (if args
|
|
190 (apply 'call-process
|
|
191 file nil t nil (when (listp args) args))
|
|
192 (insert-file-contents file))
|
|
193 (goto-char (point-min))
|
|
194 (buffer-substring (point)
|
|
195 (if oneline (line-end-position) (point-max))))
|
|
196 (file-error nil)))
|
28088
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
197
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
198 (defun cvs-string-prefix-p (str1 str2)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
199 "Tell whether STR1 is a prefix of STR2."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
200 (let ((length1 (length str1)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
201 (and (>= (length str2) length1)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
202 (string= str1 (substring str2 0 length1)))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
203
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
204 ;; (string->strings (strings->string X)) == X
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
205 (defun cvs-strings->string (strings &optional separator)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
206 "Concatenate the STRINGS, adding the SEPARATOR (default \" \").
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
207 This tries to quote the strings to avoid ambiguity such that
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
208 (cvs-string->strings (cvs-strings->string strs)) == strs
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
209 Only some SEPARATOR will work properly."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
210 (let ((sep (or separator " ")))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
211 (mapconcat
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
212 (lambda (str)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
213 (if (string-match "[\\\"]" str)
|
28177
|
214 (concat "\"" (replace-regexp-in-string "[\\\"]" "\\\\\\&" str) "\"")
|
28088
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
215 str))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
216 strings sep)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
217
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
218 ;; (string->strings (strings->string X)) == X
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
219 (defun cvs-string->strings (string &optional separator)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
220 "Split the STRING into a list of strings.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
221 It understands elisp style quoting within STRING such that
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
222 (cvs-string->strings (cvs-strings->string strs)) == strs
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
223 The SEPARATOR regexp defaults to \"\\s-+\"."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
224 (let ((sep (or separator "\\s-+"))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
225 (i (string-match "[\"]" string)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
226 (if (null i) (split-string string sep) ; no quoting: easy
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
227 (append (unless (eq i 0) (split-string (substring string 0 i) sep))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
228 (let ((rfs (read-from-string string i)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
229 (cons (car rfs)
|
41780
|
230 (cvs-string->strings (substring string (cdr rfs))
|
|
231 sep)))))))
|
28088
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
232
|
49597
|
233 ;;;;
|
28088
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
234 ;;;; file names
|
49597
|
235 ;;;;
|
28088
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
236
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
237 (defsubst cvs-expand-dir-name (d)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
238 (file-name-as-directory (expand-file-name d)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
239
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
240 ;;;;
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
241 ;;;; (interactive <foo>) support function
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
242 ;;;;
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
243
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
244 (defstruct (cvs-qtypedesc
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
245 (:constructor nil) (:copier nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
246 (:constructor cvs-qtypedesc-create
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
247 (str2obj obj2str &optional complete hist-sym require)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
248 str2obj
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
249 obj2str
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
250 hist-sym
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
251 complete
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
252 require)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
253
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
254
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
255 (defconst cvs-qtypedesc-string1 (cvs-qtypedesc-create 'identity 'identity t))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
256 (defconst cvs-qtypedesc-string (cvs-qtypedesc-create 'identity 'identity))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
257 (defconst cvs-qtypedesc-strings
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
258 (cvs-qtypedesc-create 'cvs-string->strings 'cvs-strings->string nil))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
259
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
260 (defun cvs-query-read (default prompt qtypedesc &optional hist-sym)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
261 (let* ((qtypedesc (or qtypedesc cvs-qtypedesc-strings))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
262 (hist-sym (or hist-sym (cvs-qtypedesc-hist-sym qtypedesc)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
263 (complete (cvs-qtypedesc-complete qtypedesc))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
264 (completions (and (functionp complete) (funcall complete)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
265 (initval (funcall (cvs-qtypedesc-obj2str qtypedesc) default)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
266 (funcall (cvs-qtypedesc-str2obj qtypedesc)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
267 (cond
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
268 ((null complete) (read-string prompt initval hist-sym))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
269 ((functionp complete)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
270 (completing-read prompt completions
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
271 nil (cvs-qtypedesc-require qtypedesc)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
272 initval hist-sym))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
273 (t initval)))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
274
|
49597
|
275 ;;;;
|
28088
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
276 ;;;; Flags handling
|
49597
|
277 ;;;;
|
28088
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
278
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
279 (defstruct (cvs-flags
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
280 (:constructor nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
281 (:constructor -cvs-flags-make
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
282 (desc defaults &optional qtypedesc hist-sym)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
283 defaults persist desc qtypedesc hist-sym)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
284
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
285 (defmacro cvs-flags-define (sym defaults
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
286 &optional desc qtypedesc hist-sym docstring)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
287 `(defconst ,sym
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
288 (let ((bound (boundp ',sym)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
289 (if (and bound (cvs-flags-p ,sym)) ,sym
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
290 (let ((defaults ,defaults))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
291 (-cvs-flags-make ,desc
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
292 (if bound (cons ,sym (cdr defaults)) defaults)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
293 ,qtypedesc ,hist-sym))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
294 ,docstring))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
295
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
296 (defun cvs-flags-query (sym &optional desc arg)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
297 "Query flags based on SYM.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
298 Optional argument DESC will be used for the prompt
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
299 If ARG (or a prefix argument) is nil, just use the 0th default.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
300 If it is a non-negative integer, use the corresponding default.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
301 If it is a negative integer query for a new value of the corresponding
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
302 default and return that new value.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
303 If it is \\[universal-argument], just query and return a value without
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
304 altering the defaults.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
305 If it is \\[universal-argument] \\[universal-argument], behave just
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
306 as if a negative zero was provided."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
307 (let* ((flags (symbol-value sym))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
308 (desc (or desc (cvs-flags-desc flags)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
309 (qtypedesc (cvs-flags-qtypedesc flags))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
310 (hist-sym (cvs-flags-hist-sym flags))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
311 (arg (if (eq arg 'noquery) 0 (or arg current-prefix-arg 0)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
312 (numarg (prefix-numeric-value arg))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
313 (defaults (cvs-flags-defaults flags))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
314 (permstr (if (< numarg 0) (format " (%sth default)" (- numarg)))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
315 ;; special case for universal-argument
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
316 (when (consp arg)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
317 (setq permstr (if (> numarg 4) " (permanent)" ""))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
318 (setq numarg 0))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
319
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
320 ;; sanity check
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
321 (unless (< (abs numarg) (length defaults))
|
38422
|
322 (error "There is no %sth default" (abs numarg)))
|
28088
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
323
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
324 (if permstr
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
325 (let* ((prompt (format "%s%s: " desc permstr))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
326 (fs (cvs-query-read (nth (- numarg) (cvs-flags-defaults flags))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
327 prompt qtypedesc hist-sym)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
328 (when (not (equal permstr ""))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
329 (setf (nth (- numarg) (cvs-flags-defaults flags)) fs))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
330 fs)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
331 (nth numarg defaults))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
332
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
333 (defsubst cvs-flags-set (sym index value)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
334 "Set SYM's INDEX'th setting to VALUE."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
335 (setf (nth index (cvs-flags-defaults (symbol-value sym))) value))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
336
|
49597
|
337 ;;;;
|
28088
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
338 ;;;; Prefix keys
|
49597
|
339 ;;;;
|
28088
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
340
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
341 (defconst cvs-prefix-number 10)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
342
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
343 (defsubst cvs-prefix-sym (sym) (intern (concat (symbol-name sym) "-cps")))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
344
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
345 (defmacro cvs-prefix-define (sym docstring desc defaults
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
346 &optional qtypedesc hist-sym)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
347 (let ((cps (cvs-prefix-sym sym)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
348 `(progn
|
39542
|
349 (defvar ,sym nil ,(concat (or docstring "") "
|
28088
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
350 See `cvs-prefix-set' for further description of the behavior."))
|
41174
|
351 (defvar ,cps
|
28088
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
352 (let ((defaults ,defaults))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
353 ;; sanity ensurance
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
354 (unless (>= (length defaults) cvs-prefix-number)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
355 (setq defaults (append defaults
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
356 (make-list (1- cvs-prefix-number)
|
30618
|
357 (nth 0 defaults)))))
|
28088
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
358 (-cvs-flags-make ,desc defaults ,qtypedesc ,hist-sym))))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
359
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
360 (defun cvs-prefix-make-local (sym)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
361 (let ((cps (cvs-prefix-sym sym)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
362 (make-local-variable sym)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
363 (set (make-local-variable cps) (copy-cvs-flags (symbol-value cps)))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
364
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
365 (defun cvs-prefix-set (sym arg)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
366 ;; we could distinguish between numeric and non-numeric prefix args instead of
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
367 ;; relying on that magic `4'.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
368 "Set the cvs-prefix contained in SYM.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
369 If ARG is between 0 and 9, it selects the corresponding default.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
370 If ARG is negative (or \\[universal-argument] which corresponds to negative 0),
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
371 it queries the user and sets the -ARG'th default.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
372 If ARG is greater than 9 (or \\[universal-argument] \\[universal-argument]),
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
373 the (ARG mod 10)'th prefix is made persistent.
|
42205
|
374 If ARG is nil toggle the PREFIX's value between its 0th default and nil
|
28088
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
375 and reset the persistence."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
376 (let* ((prefix (symbol-value (cvs-prefix-sym sym)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
377 (numarg (if (integerp arg) arg 0))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
378 (defs (cvs-flags-defaults prefix)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
379
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
380 ;; set persistence if requested
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
381 (when (> (prefix-numeric-value arg) 9)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
382 (setf (cvs-flags-persist prefix) t)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
383 (setq numarg (mod numarg 10)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
384
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
385 ;; set the value
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
386 (set sym
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
387 (cond
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
388 ((null arg)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
389 (setf (cvs-flags-persist prefix) nil)
|
30618
|
390 (unless (symbol-value sym) (nth 0 (cvs-flags-defaults prefix))))
|
28088
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
391
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
392 ((or (consp arg) (< numarg 0))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
393 (setf (nth (- numarg) (cvs-flags-defaults prefix))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
394 (cvs-query-read (nth (- numarg) (cvs-flags-defaults prefix))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
395 (format "%s: " (cvs-flags-desc prefix))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
396 (cvs-flags-qtypedesc prefix)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
397 (cvs-flags-hist-sym prefix))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
398 (t (nth numarg (cvs-flags-defaults prefix)))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
399 (force-mode-line-update)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
400
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
401 (defun cvs-prefix-get (sym &optional read-only)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
402 "Return the current value of the prefix SYM.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
403 and reset it unless READ-ONLY is non-nil."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
404 (prog1 (symbol-value sym)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
405 (unless (or read-only
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
406 (cvs-flags-persist (symbol-value (cvs-prefix-sym sym))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
407 (set sym nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
408 (force-mode-line-update))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
409
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
410 (provide 'pcvs-util)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
411
|
38422
|
412 ;;; pcvs-util.el ends here
|