• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Japanese translation of message catalog for Sawfish Window-Manager


Commit MetaInfo

修订版49672b617d9ccb4e61341cd6687c3bc0407498bc (tree)
时间2010-06-06 10:33:02
作者Jeremy Hankins <nowan@nowa...>
CommiterJeremy Hankins

Log Message

sawfish.wm.util.prompt now requires that helper functions be passed explicitly.

更改概述

差异

--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
1+2010-05-23 Jeremy Hankins <nowan@nowan.org>
2+ * lisp/sawfish/wm/util/prompt-extras.jl
3+ * lisp/sawfish/wm/util/prompt-wm.jl
4+ * lisp/sawfish/wm/util/prompt.jl: Changed the way prompt is called:
5+ helper functions are now passed directly instead of implicitly
6+ via let statements. Also reverts the previous compilation error
7+ fix, since it's no longer necessary.
8+
19 2010-05-28 Jeremy Hankins <nowan@nowan.org>
210 * lisp/sawfish/wm/util/prompt.jl: Fix compilation error
311 -- [Harald van Dijk]
--- a/lisp/sawfish/wm/util/prompt-extras.jl
+++ b/lisp/sawfish/wm/util/prompt-extras.jl
@@ -24,6 +24,13 @@
2424
2525 (require 'rep.io.files)
2626
27+(defvar prompt-list-fold-case nil
28+ "Whether prompt-from-list should ignore case.")
29+
30+(defvar prompt-file-exclude '"\\.(o|jlc|x)$|~$|^#.*#$|^\\.\\.?$"
31+ "A regexp, if it matches the file being considered for completion, the file
32+is rejected.")
33+
2734 ;;; completion/validation functions
2835
2936 (define (prompt-complete-filename word)
@@ -64,24 +71,27 @@
6471 (file-name-nondirectory (directory-file-name name)))
6572 abbrev)))
6673
67-(define (prompt-complete-from-list word)
68- (let (out)
69- (mapc (lambda (x)
70- (when (string-match (concat ?^ (quote-regexp word))
71- x nil prompt-list-fold-case)
72- (setq out (cons x out)))) prompt-list)
73- out))
74-
75-(define (prompt-validate-from-list name)
76- (if (null prompt-list-fold-case)
77- (and (member name prompt-list) name)
78- (catch 'exit
74+(define (prompt-list-completor prompt-list)
75+ (lambda (word)
76+ (let (out)
7977 (mapc (lambda (x)
80- (when (string-match (concat ?^ (quote-regexp name) ?$) x nil t)
81- (throw 'exit name))) prompt-list))))
78+ (when (string-match (concat ?^ (quote-regexp word))
79+ x nil prompt-list-fold-case)
80+ (setq out (cons x out)))) prompt-list)
81+ out)))
82+
83+(define (prompt-list-validator prompt-list)
84+ (lambda (name)
85+ (if (null prompt-list-fold-case)
86+ (and (member name prompt-list) name)
87+ (catch 'exit
88+ (mapc (lambda (x)
89+ (when (string-match (concat ?^ (quote-regexp name) ?$) x nil t)
90+ (throw 'exit name))) prompt-list)))))
8291
8392 ;;; entry points
8493
94+(define filename-history (prompt-make-history))
8595 (define (prompt-for-file #!optional title existing start default)
8696 "Prompt for a file, if EXISTING is t only files which exist are
8797 allowed to be entered."
@@ -90,14 +100,17 @@ allowed to be entered."
90100 (setq start (if (stringp start)
91101 (expand-file-name start)
92102 (file-name-as-directory default-directory)))
93- (let* ((prompt-completion-fun prompt-complete-filename)
94- (prompt-validation-fun (and existing prompt-validate-filename))
95- (prompt-abbrev-fun prompt-abbreviate-filename)
96- (str (prompt title start)))
103+ (let ((str (prompt #:title title
104+ #:start start
105+ #:completion-fun prompt-complete-filename
106+ #:validation-fun (and existing prompt-validate-filename)
107+ #:abbrev-fun prompt-abbreviate-filename
108+ #:history filename-history)))
97109 (when (and (string= str "") default)
98110 (setq str default))
99111 str))
100112
113+(define directory-name-history (prompt-make-history))
101114 (define (prompt-for-directory #!optional title existing start default)
102115 "Prompt for a directory, if EXISTING is t only files which exist are
103116 allowed to be entered."
@@ -105,10 +118,12 @@ allowed to be entered."
105118 (setq title "Enter filename:"))
106119 (unless (stringp start)
107120 (setq start (file-name-as-directory default-directory)))
108- (let* ((prompt-completion-fun prompt-complete-directory)
109- (prompt-validation-fun (and existing prompt-validate-directory))
110- (prompt-abbrev-fun prompt-abbreviate-filename)
111- (str (prompt title start)))
121+ (let ((str (prompt #:title title
122+ #:start start
123+ #:completion-fun prompt-complete-directory
124+ #:validation-fun (and existing prompt-validate-directory)
125+ #:abbrev-fun prompt-abbreviate-filename
126+ #:history directory-name-history)))
112127 (when (and (string= str "") default)
113128 (setq str default))
114129 str))
@@ -117,26 +132,30 @@ allowed to be entered."
117132 "Return a selected choice from the list of options (strings) OPTIONS.
118133 PROMPT is the title displayed, START the starting choice.
119134 Unless DONT-VALIDATE is t, only a member of PROMPT-LIST will be returned."
120- (let ((prompt-list options)
121- (prompt-completion-fun prompt-complete-from-list)
122- (prompt-validation-fun (if dont-validate
123- nil
124- prompt-validate-from-list)))
125- (prompt title start)))
135+ (prompt #:title title
136+ #:start start
137+ #:completion-fun (prompt-list-completor options)
138+ #:validation-fun (if dont-validate
139+ nil
140+ (prompt-list-validator options))))
126141
127142 (define (prompt-for-string #!optional title start)
128- (let ((prompt-completion-fun prompt-complete-filename)
129- (prompt-validation-fun nil))
130- (prompt (or title "Enter string: ") start)))
143+ (prompt #:title (or title "Enter string: ")
144+ #:start start
145+ ;; XXX: Why is this completing on files???
146+ #:completion-fun prompt-complete-filename))
131147
132148 (define (prompt-for-number #!optional title)
133149 (let (num)
134150 (while (not (numberp num))
135- (setq num (read-from-string (prompt (or title "Enter number: ")))))
151+ (setq num (read-from-string (prompt
152+ #:title (or title "Enter number: ")))))
136153 num))
137154
138155 (define (pwd-prompt title)
139- (let ((prompt-display-fun (lambda (string)
140- (make-string (length string) ?*)))
141- (prompt-history nil))
142- (prompt-for-string title)))
156+ "Prompt for a string, hiding the string behind asterisks (e.g., for
157+a password)."
158+ (prompt #:title title
159+ #:history (make-fluid) ; Disable history
160+ #:display-fun (lambda (string)
161+ (make-string (length string) ?*))))
--- a/lisp/sawfish/wm/util/prompt-wm.jl
+++ b/lisp/sawfish/wm/util/prompt-wm.jl
@@ -43,11 +43,12 @@
4343 (if (string-match re (car names))
4444 (cons (car names) (names-matching re (cdr names)))
4545 (names-matching re (cdr names))))))
46- (prompt-completion-fun
46+ (complete-windows
4747 (lambda (text)
4848 (names-matching (format nil "^%s" text)
4949 (sort (window-names (managed-windows)))))))
50- (let ((window-title (prompt (or title (_ "Window:")))))
50+ (let ((window-title (prompt #:title (or title (_ "Window:"))
51+ #:completion-fun complete-windows)))
5152 (unless (zerop (length window-title))
5253 (cdr (assoc window-title (mapcar (lambda (w)
5354 (cons (window-name w) w))
@@ -70,10 +71,11 @@
7071 (if (string-match re (car names))
7172 (cons (car names) (names-matching re (cdr names)))
7273 (names-matching re (cdr names))))))
73- (prompt-completion-fun
74+ (complete-workspaces
7475 (lambda (text)
7576 (names-matching (format nil "^%s" text) (workspaces)))))
76- (let ((ws-title (prompt (or title (_ "Workspace:"))))
77+ (let ((ws-title (prompt #:title (or title (_ "Workspace:"))
78+ #:completion-fun complete-workspaces))
7779 (wsl (workspaces)))
7880 (unless (zerop (length ws-title))
7981 (let ((where (member ws-title wsl)))
--- a/lisp/sawfish/wm/util/prompt.jl
+++ b/lisp/sawfish/wm/util/prompt.jl
@@ -19,6 +19,7 @@
1919 prompt-for-function
2020 prompt-for-variable
2121 prompt-for-command
22+ prompt-make-history
2223
2324 ;; motion / editing commands
2425 prompt-backward-character
@@ -85,51 +86,31 @@
8586 "Regexp that determines which characters are to be considered part
8687 of a word when moving.")
8788
88- (defvar prompt-file-exclude '"\\.(o|jlc|x)$|~$|^#.*#$|^\\.\\.?$"
89- "A regexp, if it matches the file being considered for completion,
90-the file is rejected.")
91-
92- (defvar prompt-list nil
93- "List of possible entries for prompt-from-list.")
94-
95- (defvar prompt-list-fold-case nil
96- "Whether prompt-from-list should ignore case.")
97-
98- (defvar prompt-history (make-ring 16)
99- "Ring buffer containing strings most-recently entered through the `prompt'
100-function.")
101-
10289 (defvar prompt-window-position
10390 (cons (- (quotient (screen-width) 2) 200) -200)
10491 "A cons cell defining the screen position at which the `prompt' window is
10592 displayed. See the `display-message' function for more details.")
10693
107- (defvar prompt-result nil)
108- (defvar prompt-prompt nil)
109- (defvar prompt-completion-fun nil)
110- (defvar prompt-validation-fun nil)
111- (defvar prompt-abbrev-fun nil)
112- (defvar prompt-display-fun nil)
113- (defvar prompt-position 0)
114- (defvar prompt-completion-position nil)
115- (defvar prompt-completions nil)
116- (defvar prompt-completions-outdated nil)
117- (defvar prompt-history-pos nil)
118- (defvar prompt-saved nil)
119- (defvar prompt-attr nil)
120-
121- ;; Compilation hack: ensure that the compiler doesn't complain when
122- ;; these are treated like functions and passed values.
123- (eval-when-compile
124- (progn
125- (defvar prompt-completion-fun nil)
126- (defvar prompt-validation-fun nil)
127- (defvar prompt-abbrev-fun nil)
128- (defvar prompt-display-fun nil)
129- (setq prompt-completion-fun (lambda (#!rest) nil)
130- prompt-validation-fun (lambda (#!rest) nil)
131- prompt-abbrev-fun (lambda (#!rest) nil)
132- prompt-display-fun (lambda (#!rest) nil))))
94+ (define (prompt-make-history)
95+ "Make a receptacle for prompt history."
96+ (make-fluid (make-ring 16)))
97+
98+ ;; Internal variables:
99+ (define prompt-history-default (prompt-make-history))
100+ (define prompt-history nil)
101+ (define prompt-result nil)
102+ (define prompt-prompt nil)
103+ (define prompt-completion-fun nil)
104+ (define prompt-validation-fun nil)
105+ (define prompt-abbrev-fun nil)
106+ (define prompt-display-fun nil)
107+ (define prompt-position 0)
108+ (define prompt-completion-position nil)
109+ (define prompt-completions nil)
110+ (define prompt-completions-outdated nil)
111+ (define prompt-history-pos nil)
112+ (define prompt-saved nil)
113+ (define prompt-attr nil)
133114
134115
135116 ;; From merlin
@@ -149,11 +130,11 @@ displayed. See the `display-message' function for more details.")
149130 (assq key alist)
150131 (cons key default)))
151132
152- (defun prompt-exit ()
133+ (define (prompt-exit)
153134 "Cancel string input."
154135 (throw 'prompt-exit nil))
155136
156- (defun prompt-accept ()
137+ (define (prompt-accept)
157138 "End input and accept current string."
158139 (let ((result (if (not prompt-validation-fun)
159140 prompt-result
@@ -166,7 +147,7 @@ displayed. See the `display-message' function for more details.")
166147 (throw 'prompt-exit result))
167148 (beep))))
168149
169- (defun prompt-next (count)
150+ (define (prompt-next count)
170151 (interactive "p")
171152 (when prompt-history
172153 (setq count (- prompt-history-pos count))
@@ -185,21 +166,21 @@ displayed. See the `display-message' function for more details.")
185166 (prompt-end-of-line)
186167 (prompt-update-display)))
187168
188- (defun prompt-previous (count)
169+ (define (prompt-previous count)
189170 (interactive "p")
190171 (prompt-next (- count)))
191172
192- (defun prompt-changed ()
173+ (define (prompt-changed)
193174 (setq prompt-completions-outdated t))
194175
195- (defun prompt-clear ()
176+ (define (prompt-clear)
196177 "Clear input buffer."
197178 (setq prompt-result "")
198179 (setq prompt-position 0)
199180 (prompt-changed)
200181 (prompt-update-display))
201182
202- (defun prompt-backspace ()
183+ (define (prompt-backspace)
203184 "Remove previous character from buffer."
204185 (when (> prompt-position 0)
205186 (let ((cutoff (max (- prompt-position 1) 0)))
@@ -210,20 +191,20 @@ displayed. See the `display-message' function for more details.")
210191 (prompt-changed)
211192 (prompt-update-display))))
212193
213- (defun prompt-kill-line ()
194+ (define (prompt-kill-line)
214195 "Delete rest of line."
215196 (setq prompt-result (substring prompt-result 0 prompt-position))
216197 (prompt-changed)
217198 (prompt-update-display))
218199
219- (defun prompt-move (num)
200+ (define (prompt-move num)
220201 "Move NUM characters forward or backward."
221202 (let ((new-pos (+ prompt-position num)))
222203 (and (>= new-pos 0) (<= new-pos (length prompt-result))
223204 (setq prompt-position new-pos)
224205 (prompt-update-display))))
225206
226- (defun prompt-forward-word ()
207+ (define (prompt-forward-word)
227208 "Move to next non-word character."
228209 (setq prompt-position (1+ prompt-position))
229210 (while (and (< prompt-position (length prompt-result))
@@ -234,7 +215,7 @@ displayed. See the `display-message' function for more details.")
234215 (length prompt-result)))
235216 (prompt-update-display))
236217
237- (defun prompt-backward-word ()
218+ (define (prompt-backward-word)
238219 "Move to previous non-word character."
239220 (setq prompt-position (1- prompt-position))
240221 (while (and (> prompt-position 0)
@@ -244,25 +225,25 @@ displayed. See the `display-message' function for more details.")
244225 (setq prompt-position (max prompt-position 0))
245226 (prompt-update-display))
246227
247- (defun prompt-forward-character ()
228+ (define (prompt-forward-character)
248229 "Move forward one character."
249230 (prompt-move 1))
250231
251- (defun prompt-backward-character ()
232+ (define (prompt-backward-character)
252233 "Move backward one character."
253234 (prompt-move -1))
254235
255- (defun prompt-beginning-of-line ()
236+ (define (prompt-beginning-of-line)
256237 "Move to beginning of line."
257238 (setq prompt-position 0)
258239 (prompt-update-display))
259240
260- (defun prompt-end-of-line ()
241+ (define (prompt-end-of-line)
261242 "Move to end of line."
262243 (setq prompt-position (length prompt-result))
263244 (prompt-update-display))
264245
265- (defun prompt-complete ()
246+ (define (prompt-complete)
266247 (if (and (not prompt-completions-outdated) prompt-completion-position)
267248 (let
268249 ((new (min (max 0 (- (length prompt-completions)
@@ -290,7 +271,7 @@ displayed. See the `display-message' function for more details.")
290271 (setq prompt-completion-position 0))))))
291272 (prompt-update-display))
292273
293- (defun prompt-format-completions ()
274+ (define (prompt-format-completions)
294275 (when (numberp prompt-completion-position)
295276 (let ((compl (nthcdr prompt-completion-position prompt-completions))
296277 (continued nil))
@@ -307,7 +288,7 @@ displayed. See the `display-message' function for more details.")
307288 compl))
308289 continued))))
309290
310- (defun prompt-update-display ()
291+ (define (prompt-update-display)
311292 (let ((result (if prompt-display-fun
312293 (prompt-display-fun prompt-result)
313294 prompt-result))
@@ -334,7 +315,7 @@ displayed. See the `display-message' function for more details.")
334315 )))))
335316
336317 ;; Insert all unbound keys to result.
337- (defun prompt-unbound-callback ()
318+ (define (prompt-unbound-callback)
338319 (let ((key (current-event-string)))
339320 (setq prompt-result
340321 (concat (substring prompt-result 0 prompt-position)
@@ -345,8 +326,20 @@ displayed. See the `display-message' function for more details.")
345326 (prompt-update-display)
346327 t))
347328
348- (defun prompt (#!optional title start attributes)
349- "Prompt the user for a string."
329+ (define (prompt #!key title start attributes completion-fun
330+ validation-fun abbrev-fun display-fun history)
331+ "Prompt the user for a string. All of the keyword options are
332+optional and have reasonable defaults.
333+
334+ - `title' is the message displayed to prompt the user.
335+ - `start' is an initial string automatically entered into the prompt.
336+ - `attributes' can be used to set text attributes.
337+ - `completion-fun' is a function used for tab completion.
338+ - `validation-fun' is a function that checks input for validity.
339+ - `abbrev-fun' is used to abbreviate possible completions for display.
340+ - `display-fun' can be used to change the way entered text is displayed.
341+ - `history' contains history. Use `prompt-make-history' to generate
342+ an appropriate value."
350343 (unless (stringp title)
351344 (setq title "Enter string:"))
352345 (unless (string-match " $" title)
@@ -354,52 +347,68 @@ displayed. See the `display-message' function for more details.")
354347 (call-with-keyboard-grabbed
355348 (lambda ()
356349 (unwind-protect
357- (let* ((override-keymap prompt-keymap)
358- (prompt-result (or start ""))
359- (prompt-prompt title)
360- (prompt-position (length prompt-result))
361- (prompt-history-pos 0)
362- (prompt-saved nil)
363- (prompt-attr attributes)
364- (prompt-completion-position nil)
365- (prompt-completions nil)
366- (prompt-completions-outdated t)
367- (unbound-key-hook (list prompt-unbound-callback)))
350+ (let ((override-keymap prompt-keymap)
351+ (unbound-key-hook (list prompt-unbound-callback)))
352+ (setq prompt-history (fluid (or history
353+ prompt-history-default))
354+ prompt-completion-fun completion-fun
355+ prompt-validation-fun validation-fun
356+ prompt-abbrev-fun abbrev-fun
357+ prompt-display-fun display-fun
358+ prompt-result (or start "")
359+ prompt-prompt title
360+ prompt-position (length prompt-result)
361+ prompt-history-pos 0
362+ prompt-saved nil
363+ prompt-attr attributes
364+ prompt-completion-position nil
365+ prompt-completions nil
366+ prompt-completions-outdated t)
368367 (prompt-update-display)
369368 (catch 'prompt-exit
370369 (recursive-edit)))
371370 (display-message nil)))))
372371
373- (defun prompt-for-symbol (#!optional title predicate validator)
374- (let ((prompt-completion-fun
375- (lambda (x)
376- (mapcar symbol-name
377- (apropos (concat ?^ (quote-regexp x)) predicate))))
378- (prompt-validation-fun
379- (lambda (x)
380- (let
381- ((symbol (intern x)))
382- (if validator
383- (and (validator symbol) symbol)
384- symbol)))))
385- (prompt title)))
386-
387- (defun prompt-for-function (#!optional title)
372+ (define symbol-history (prompt-make-history))
373+ (define (prompt-for-symbol #!key title predicate validator history)
374+ (prompt #:title title
375+ #:completion-fun (lambda (x)
376+ (mapcar symbol-name
377+ (apropos (concat ?^ (quote-regexp x))
378+ predicate)))
379+ #:validation-fun (lambda (x)
380+ (let
381+ ((symbol (intern x)))
382+ (if validator
383+ (and (validator symbol) symbol)
384+ symbol)))
385+ #:history (or history symbol-history)))
386+
387+ (define function-history (prompt-make-history))
388+ (define (prompt-for-function #!optional title)
388389 "Prompt for a function."
389- (prompt-for-symbol (or title "Enter name of function:")
390- (lambda (x)
391- (and (boundp x)
392- (let ((value (symbol-value x)))
393- (or (functionp value)
394- (macrop value)
395- (special-form-p value)))))))
396-
397- (defun prompt-for-variable (#!optional title)
390+ (prompt-for-symbol #:title (or title "Enter name of function:")
391+ #:predicate (lambda (x)
392+ (and (boundp x)
393+ (let ((value (symbol-value x)))
394+ (or (functionp value)
395+ (macrop value)
396+ (special-form-p value)))))
397+ #:history function-history))
398+
399+ (define variable-history (prompt-make-history))
400+ (define (prompt-for-variable #!optional title)
398401 "Prompt for a variable."
399- (prompt-for-symbol (or title "Enter name of variable:") boundp))
400-
401- (defun prompt-for-command (#!optional title)
402- (prompt-for-symbol title commandp commandp))
402+ (prompt-for-symbol #:title (or title "Enter name of variable:")
403+ #:predicate boundp
404+ #:history variable-history))
405+
406+ (define command-history (prompt-make-history))
407+ (define (prompt-for-command #!optional title)
408+ (prompt-for-symbol #:title title
409+ #:predicate commandp
410+ #:validator commandp
411+ #:history command-history))
403412
404413
405414 ;;; autoloads
--- a/man/news.texi
+++ b/man/news.texi
@@ -13,6 +13,13 @@ they occurred between. For more detailed information see the
1313
1414 @itemize @bullet
1515
16+@item Bugfixes
17+@itemize @minus
18+@item The sawfish.wm.util.prompt no longer makes all of its internals
19+available globally, so helper functions must be passed explicitly rather
20+than implicitly via let statements.
21+@end itemize
22+
1623 @item New Features
1724 @itemize @minus
1825 @item Added border_with and border_color frame-part attributes