| 73 |
"reading file and directory name with migemo service" |
"reading file and directory name with migemo service" |
| 74 |
:group 'convenience) |
:group 'convenience) |
| 75 |
|
|
|
(defcustom kogiku-completion-key "\t" |
|
|
"" |
|
|
:group 'kogiku |
|
|
:type 'sexp |
|
|
:options '("\t" "\e\t") |
|
|
:set (lambda (symbol value) |
|
|
(set-default symbol value) |
|
|
(setq kogiku-original-function-for-minibuffer-local-completion-map |
|
|
(let ((tmp (lookup-key minibuffer-local-completion-map value))) |
|
|
(if (or (null tmp) (eq tmp 'kogiku-completion-complete)) |
|
|
'minibuffer-complete |
|
|
tmp)) |
|
|
kogiku-original-function-for-minibuffer-local-must-match-map |
|
|
(let ((tmp (lookup-key minibuffer-local-must-match-map value))) |
|
|
(if (or (null tmp) (eq tmp 'kogiku-must-match-complete)) |
|
|
'minibuffer-complete |
|
|
tmp))) |
|
|
(define-key |
|
|
minibuffer-local-completion-map |
|
|
value |
|
|
'kogiku-completion-complete) |
|
|
(define-key |
|
|
minibuffer-local-must-match-map |
|
|
value |
|
|
'kogiku-must-match-complete))) |
|
|
|
|
| 76 |
(defcustom kogiku-minibuffer-prompt-string "kogiku" |
(defcustom kogiku-minibuffer-prompt-string "kogiku" |
| 77 |
"*Kogiku indicator in minibuffer." |
"*Kogiku indicator in minibuffer." |
| 78 |
:group 'kogiku |
:group 'kogiku |
| 79 |
:type 'string) |
:type 'string) |
| 80 |
|
|
| 81 |
(defvar kogiku-original-function-for-minibuffer-local-completion-map |
(defcustom kogiku-enable-once nil |
| 82 |
nil) |
"*If non-nil, kogiku effects a one time when call with a prefix argument. |
| 83 |
|
If nil, kogiku toggle with a prefix argument." |
| 84 |
|
:group 'kogiku |
| 85 |
|
:type 'boolean) |
| 86 |
|
|
| 87 |
(defvar kogiku-original-function-for-minibuffer-local-must-match-map |
(defvar kogiku-original-function nil) |
| 88 |
nil) |
(defvar kogiku-completion-key "\t") |
| 89 |
|
|
| 90 |
(defun kogiku-completion-complete (&optional arg) |
(defun kogiku-complete (&optional arg) |
| 91 |
(interactive "P") |
(interactive "P") |
| 92 |
(when (and arg |
(if kogiku-enable-once |
| 93 |
(eq minibuffer-completion-table 'read-file-name-internal)) |
(kogiku-oneshot-complete arg) |
| 94 |
|
(kogiku-complete-with-toggle arg))) |
| 95 |
|
|
| 96 |
|
(defun kogiku-oneshot-complete (fire) |
| 97 |
|
(let ((minibuffer-completion-table minibuffer-completion-table)) |
| 98 |
|
(when fire |
| 99 |
|
(setq minibuffer-completion-table 'kogiku-read-file-name-internal)) |
| 100 |
|
(funcall kogiku-original-function))) |
| 101 |
|
|
| 102 |
|
(defun kogiku-complete-with-toggle (switch) |
| 103 |
|
(cond |
| 104 |
|
((and switch |
| 105 |
|
(eq minibuffer-completion-table 'read-file-name-internal)) |
| 106 |
(setq minibuffer-completion-table 'kogiku-read-file-name-internal) |
(setq minibuffer-completion-table 'kogiku-read-file-name-internal) |
| 107 |
(kogiku-minibuffer-prompt-e21)) |
(kogiku-minibuffer-prompt-e21)) |
| 108 |
(funcall kogiku-original-function-for-minibuffer-local-completion-map) |
((and switch |
| 109 |
(kogiku-minibuffer-prompt-not-e21)) |
(eq minibuffer-completion-table 'kogiku-read-file-name-internal)) |
| 110 |
|
(setq minibuffer-completion-table 'read-file-name-internal) |
| 111 |
(defun kogiku-must-match-complete (&optional arg) |
(kogiku-minibuffer-prompt-e21))) |
| 112 |
(interactive "P") |
(funcall kogiku-original-function) |
|
(when (and arg |
|
|
(eq minibuffer-completion-table 'read-file-name-internal)) |
|
|
(setq minibuffer-completion-table 'kogiku-read-file-name-internal) |
|
|
(kogiku-minibuffer-prompt-e21)) |
|
|
(funcall kogiku-original-function-for-minibuffer-local-must-match-map) |
|
| 113 |
(kogiku-minibuffer-prompt-not-e21)) |
(kogiku-minibuffer-prompt-not-e21)) |
| 114 |
|
|
| 115 |
(defun kogiku-minibuffer-prompt-e21 () |
(defun kogiku-minibuffer-prompt-e21 () |
| 296 |
(funcall read-file-name-predicate string) |
(funcall read-file-name-predicate string) |
| 297 |
(file-exists-p string)))))))) |
(file-exists-p string)))))))) |
| 298 |
|
|
| 299 |
|
(defun kogiku-install-key () |
| 300 |
|
(when (eq minibuffer-completion-table 'read-file-name-internal) |
| 301 |
|
(setq kogiku-original-function |
| 302 |
|
(let ((tmp (lookup-key (current-local-map) kogiku-completion-key))) |
| 303 |
|
(cond |
| 304 |
|
((null tmp) |
| 305 |
|
'minibuffer-complete) |
| 306 |
|
((eq tmp 'kogiku-complete) |
| 307 |
|
(and kogiku-original-function 'minibuffer-complete)) |
| 308 |
|
(t |
| 309 |
|
tmp)))) |
| 310 |
|
(define-key (current-local-map) kogiku-completion-key 'kogiku-complete))) |
| 311 |
|
(add-hook 'minibuffer-setup-hook 'kogiku-install-key) |
| 312 |
|
|
| 313 |
|
(defun kogiku-uninstall-key () |
| 314 |
|
(when (and (eq minibuffer-completion-table 'read-file-name-internal) |
| 315 |
|
(eq (lookup-key (current-local-map) kogiku-completion-key) |
| 316 |
|
'kogiku-complete))) |
| 317 |
|
(define-key (current-local-map) kogiku-completion-key kogiku-original-function)) |
| 318 |
|
(add-hook 'minibuffer-exit-hook 'kogiku-uninstall-key) |
| 319 |
|
|
| 320 |
(provide 'kogiku) |
(provide 'kogiku) |
| 321 |
;; kogiku.el ends here |
;; kogiku.el ends here |