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