Develop and Download Open Source Software

Browse CVS Repository

Diff of /kogiku/kogiku/kogiku.el

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.14 by jet, Tue Feb 10 07:30:55 2004 UTC revision 1.15 by shirai, Tue Feb 10 11:47:59 2004 UTC
# Line 84  If nil, kogiku toggle with a prefix argu Line 84  If nil, kogiku toggle with a prefix argu
84    :group 'kogiku    :group 'kogiku
85    :type 'boolean)    :type 'boolean)
86    
87  (defvar kogiku-take-over-targets  (defcustom kogiku-mode-change-key "\M-k"
88      "*Key of change `kogiku-enable-once'."
89      :group 'kogiku
90      :type 'sexp)
91    
92    (defface kogiku-indicator-face
93      '((((class color) (type tty)) (:foreground "blue" :bold t))
94        (((class color) (background light)) (:foreground "dark blue" :bold t))
95        (((class color) (background dark))  (:foreground "cyan" :bold t))
96        (t (:bold t)))
97      "*Face of kogiku indicator."
98      :group 'kogiku)
99    
100    (defface kogiku-change-face
101      '((((class color) (type tty)) (:foreground "blue"))
102        (((class color) (background light)) (:foreground "dark blue"))
103        (((class color) (background dark))  (:foreground "cyan"))
104        (t (:underline t)))
105      "*Face of kogiku indicator."
106      :group 'kogiku)
107    
108    (defvar kogiku-take-over-targets
109    '(read-file-name-internal    '(read-file-name-internal
110      ffap-read-file-or-url-internal))      ffap-read-file-or-url-internal))
111    
# Line 93  If nil, kogiku toggle with a prefix argu Line 114  If nil, kogiku toggle with a prefix argu
114    
115  (defvar kogiku-completion-key "\t")  (defvar kogiku-completion-key "\t")
116  (defvar kogiku-minibuffer-prompt-overlay nil)  (defvar kogiku-minibuffer-prompt-overlay nil)
117    (defvar kogiku-mode-change-original-functions nil)
118    
119  (defun kogiku-complete (&optional arg)  (defun kogiku-complete (&optional arg)
120    (interactive "P")    (interactive "P")
# Line 120  If nil, kogiku toggle with a prefix argu Line 142  If nil, kogiku toggle with a prefix argu
142  (defun kogiku-minibuffer-prompt-e21 ()  (defun kogiku-minibuffer-prompt-e21 ()
143    (when (fboundp 'field-beginning)    (when (fboundp 'field-beginning)
144      (let ((prompt (buffer-substring (point-min) (field-beginning)))      (let ((prompt (buffer-substring (point-min) (field-beginning)))
           (buffer-read-only nil)  
           (inhibit-read-only t)  
145            (props (text-properties-at (point-min)))            (props (text-properties-at (point-min)))
146            (indicator (format " [%s]" kogiku-minibuffer-prompt-string)))            (indicator (format "[%s]" kogiku-minibuffer-prompt-string))
147              (space " ")
148              (buffer-read-only nil)
149              (inhibit-read-only t))
150        (save-excursion        (save-excursion
151          (if (eq minibuffer-completion-table 'kogiku-read-file-name-internal)          (if (eq minibuffer-completion-table 'kogiku-read-file-name-internal)
152              (when (string-match ":[^:]*" prompt)              (when (string-match ":[^:]*" prompt)
153                  (set-text-properties 0 (length space) props space)
154                  (set-text-properties 0 (length indicator) props indicator)
155                  (add-text-properties 0 (length indicator)
156                                       '(face kogiku-indicator-face) indicator)
157                (setq prompt (concat (substring prompt 0 (match-beginning 0))                (setq prompt (concat (substring prompt 0 (match-beginning 0))
158                                     indicator                                     space indicator
159                                     (substring prompt (match-beginning 0))))                                     (substring prompt (match-beginning 0))))
               (set-text-properties 0 (length prompt) props prompt)  
160                (delete-region (point-min) (field-beginning))                (delete-region (point-min) (field-beginning))
161                (goto-char (point-min))                (goto-char (point-min))
162                (insert prompt))                (insert prompt))
163            (when (string-match (regexp-quote indicator) prompt)            (when (string-match (regexp-quote (concat space indicator)) prompt)
164              (setq prompt (replace-match "" nil nil prompt))              (setq prompt (replace-match "" nil nil prompt))
165              (set-text-properties 0 (length prompt) props prompt)              (set-text-properties 0 (length prompt) props prompt)
166              (delete-region (point-min) (field-beginning))              (delete-region (point-min) (field-beginning))
# Line 309  If nil, kogiku toggle with a prefix argu Line 335  If nil, kogiku toggle with a prefix argu
335                      (funcall read-file-name-predicate string)                      (funcall read-file-name-predicate string)
336                    (file-exists-p string))))))))                    (file-exists-p string))))))))
337    
338    (defun kogiku-mode-change ()
339      (interactive)
340      (setq kogiku-enable-once (not kogiku-enable-once))
341      (when (and kogiku-enable-once
342                 (eq minibuffer-completion-table 'kogiku-read-file-name-internal))
343        (setq minibuffer-completion-table 'read-file-name-internal))
344      (when (and (not kogiku-enable-once)
345                 (eq minibuffer-completion-table 'read-file-name-internal))
346        (setq minibuffer-completion-table 'kogiku-read-file-name-internal))
347      (kogiku-minibuffer-prompt-e21)
348      (kogiku-minibuffer-prompt-not-e21)
349      (let ((msg (format "[%s%s-mode]"
350                         (if kogiku-enable-once
351                             (concat kogiku-minibuffer-prompt-string " ") "")
352                         (if kogiku-enable-once "ONESHOT" "TOGGLE")))
353            (max (point-max))
354            (inhibit-quit t))
355        (put-text-property 0 (length msg) 'face 'kogiku-change-face msg)
356        (save-excursion
357          (goto-char max)
358          (insert "  " msg))
359        (sit-for 5)
360        (save-excursion
361          (delete-region max (point-max)))))
362    
363  (defun kogiku-install-key ()  (defun kogiku-install-key ()
364    (when (member minibuffer-completion-table kogiku-take-over-targets)    (when (memq minibuffer-completion-table kogiku-take-over-targets)
365      (setq kogiku-original-completion-table minibuffer-completion-table)      (setq kogiku-original-completion-table minibuffer-completion-table)
366      (push (lookup-key (current-local-map) kogiku-completion-key)      (push (lookup-key (current-local-map) kogiku-completion-key)
367            kogiku-original-functions)            kogiku-original-functions)
368      (define-key (current-local-map) kogiku-completion-key 'kogiku-complete)))      (define-key (current-local-map) kogiku-completion-key 'kogiku-complete)
369        (push (lookup-key (current-local-map) kogiku-mode-change-key)
370              kogiku-mode-change-original-functions)
371        (define-key (current-local-map) kogiku-mode-change-key 'kogiku-mode-change)))
372    
373  (add-hook 'minibuffer-setup-hook 'kogiku-install-key)  (add-hook 'minibuffer-setup-hook 'kogiku-install-key)
374    
# Line 323  If nil, kogiku toggle with a prefix argu Line 377  If nil, kogiku toggle with a prefix argu
377                   (memq minibuffer-completion-table kogiku-take-over-targets))                   (memq minibuffer-completion-table kogiku-take-over-targets))
378               (eq (lookup-key (current-local-map) kogiku-completion-key)               (eq (lookup-key (current-local-map) kogiku-completion-key)
379                   'kogiku-complete))                   'kogiku-complete))
380      (define-key (current-local-map) kogiku-completion-key (pop kogiku-original-functions))))      (define-key (current-local-map) kogiku-completion-key (pop kogiku-original-functions))
381  (add-hook 'minibuffer-exit-hook 'kogiku-uninstall-key)          (when (eq (lookup-key (current-local-map) kogiku-mode-change-key)
382                  'kogiku-mode-change)
383          (define-key (current-local-map) kogiku-mode-change-key
384            (pop kogiku-mode-change-original-functions)))))
385    
386    (add-hook 'minibuffer-exit-hook 'kogiku-uninstall-key)
387    
388  (provide 'kogiku)  (provide 'kogiku)
389  ;; kogiku.el ends here  ;; kogiku.el ends here

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26