diff options
| author | Stefan Monnier | 2012-06-07 12:35:00 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2012-06-07 12:35:00 -0400 |
| commit | 7287f2f3453903ec10164e9ca44626a588a7a793 (patch) | |
| tree | 54e8381ecda3123c89c1754095870605258a35a8 | |
| parent | ed8bd4d70540d5756b8e173b3d8a7cf7acb5c742 (diff) | |
| download | emacs-7287f2f3453903ec10164e9ca44626a588a7a793.tar.gz emacs-7287f2f3453903ec10164e9ca44626a588a7a793.zip | |
* tmm.el (tmm-prompt): Use string-prefix-p.
(tmm-completion-delete-prompt): Don't affect current-buffer outside.
(tmm-add-prompt): Use minibuffer-completion-help.
(tmm-delete-map): Remove.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/tmm.el | 45 |
2 files changed, 22 insertions, 28 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index cbdf00d639d..becb266b5bd 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,10 @@ | |||
| 1 | 2012-06-07 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2012-06-07 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * tmm.el (tmm-prompt): Use string-prefix-p. | ||
| 4 | (tmm-completion-delete-prompt): Don't affect current-buffer outside. | ||
| 5 | (tmm-add-prompt): Use minibuffer-completion-help. | ||
| 6 | (tmm-delete-map): Remove. | ||
| 7 | |||
| 3 | * subr.el (kbd): Make it its own function. | 8 | * subr.el (kbd): Make it its own function. |
| 4 | 9 | ||
| 5 | 2012-06-07 Stefan Merten <smerten@oekonux.de> | 10 | 2012-06-07 Stefan Merten <smerten@oekonux.de> |
diff --git a/lisp/tmm.el b/lisp/tmm.el index 776e4335376..4bc1c9af99a 100644 --- a/lisp/tmm.el +++ b/lisp/tmm.el | |||
| @@ -229,8 +229,7 @@ Its value should be an event that has a binding in MENU." | |||
| 229 | (- (* 2 history-len) index-of-default)))))))) | 229 | (- (* 2 history-len) index-of-default)))))))) |
| 230 | (setq choice (cdr (assoc out tmm-km-list))) | 230 | (setq choice (cdr (assoc out tmm-km-list))) |
| 231 | (and (null choice) | 231 | (and (null choice) |
| 232 | (> (length out) (length tmm-c-prompt)) | 232 | (string-prefix-p tmm-c-prompt out) |
| 233 | (string= (substring out 0 (length tmm-c-prompt)) tmm-c-prompt) | ||
| 234 | (setq out (substring out (length tmm-c-prompt)) | 233 | (setq out (substring out (length tmm-c-prompt)) |
| 235 | choice (cdr (assoc out tmm-km-list)))) | 234 | choice (cdr (assoc out tmm-km-list)))) |
| 236 | (and (null choice) out | 235 | (and (null choice) out |
| @@ -330,9 +329,9 @@ Stores a list of all the shortcuts in the free variable `tmm-short-cuts'." | |||
| 330 | (use-local-map (append map (current-local-map)))))) | 329 | (use-local-map (append map (current-local-map)))))) |
| 331 | 330 | ||
| 332 | (defun tmm-completion-delete-prompt () | 331 | (defun tmm-completion-delete-prompt () |
| 333 | (set-buffer standard-output) | 332 | (with-current-buffer standard-output |
| 334 | (goto-char (point-min)) | 333 | (goto-char (point-min)) |
| 335 | (delete-region (point) (search-forward "Possible completions are:\n"))) | 334 | (delete-region (point) (search-forward "Possible completions are:\n")))) |
| 336 | 335 | ||
| 337 | (defun tmm-remove-inactive-mouse-face () | 336 | (defun tmm-remove-inactive-mouse-face () |
| 338 | "Remove the mouse-face property from inactive menu items." | 337 | "Remove the mouse-face property from inactive menu items." |
| @@ -351,38 +350,24 @@ Stores a list of all the shortcuts in the free variable `tmm-short-cuts'." | |||
| 351 | (set-buffer-modified-p nil))) | 350 | (set-buffer-modified-p nil))) |
| 352 | 351 | ||
| 353 | (defun tmm-add-prompt () | 352 | (defun tmm-add-prompt () |
| 354 | (add-hook 'minibuffer-exit-hook 'tmm-delete-map nil t) | ||
| 355 | (unless tmm-c-prompt | 353 | (unless tmm-c-prompt |
| 356 | (error "No active menu entries")) | 354 | (error "No active menu entries")) |
| 357 | (setq tmm-old-mb-map (tmm-define-keys t)) | 355 | (setq tmm-old-mb-map (tmm-define-keys t)) |
| 358 | ;; Get window and hide it for electric mode to get correct size | 356 | ;; Get window and hide it for electric mode to get correct size |
| 359 | (save-window-excursion | 357 | (or tmm-completion-prompt |
| 360 | (let ((completions | 358 | (add-hook 'completion-setup-hook |
| 361 | (mapcar 'car minibuffer-completion-table))) | 359 | 'tmm-completion-delete-prompt 'append)) |
| 362 | (or tmm-completion-prompt | 360 | (unwind-protect |
| 363 | (add-hook 'completion-setup-hook | 361 | (minibuffer-completion-help) |
| 364 | 'tmm-completion-delete-prompt 'append)) | 362 | (remove-hook 'completion-setup-hook 'tmm-completion-delete-prompt)) |
| 365 | (unwind-protect | 363 | (with-current-buffer "*Completions*" |
| 366 | (with-output-to-temp-buffer "*Completions*" | ||
| 367 | (display-completion-list completions)) | ||
| 368 | (remove-hook 'completion-setup-hook 'tmm-completion-delete-prompt))) | ||
| 369 | (set-buffer "*Completions*") | ||
| 370 | (tmm-remove-inactive-mouse-face) | 364 | (tmm-remove-inactive-mouse-face) |
| 371 | (when tmm-completion-prompt | 365 | (when tmm-completion-prompt |
| 372 | (let ((buffer-read-only nil)) | 366 | (let ((inhibit-read-only t)) |
| 373 | (goto-char (point-min)) | 367 | (goto-char (point-min)) |
| 374 | (insert tmm-completion-prompt)))) | 368 | (insert tmm-completion-prompt)))) |
| 375 | (save-selected-window | ||
| 376 | (other-window 1) ; Electric-pop-up-window does | ||
| 377 | ; not work in minibuffer | ||
| 378 | (Electric-pop-up-window "*Completions*")) | ||
| 379 | (insert tmm-c-prompt)) | 369 | (insert tmm-c-prompt)) |
| 380 | 370 | ||
| 381 | (defun tmm-delete-map () | ||
| 382 | (remove-hook 'minibuffer-exit-hook 'tmm-delete-map t) | ||
| 383 | (if tmm-old-mb-map | ||
| 384 | (use-local-map tmm-old-mb-map))) | ||
| 385 | |||
| 386 | (defun tmm-shortcut () | 371 | (defun tmm-shortcut () |
| 387 | "Choose the shortcut that the user typed." | 372 | "Choose the shortcut that the user typed." |
| 388 | (interactive) | 373 | (interactive) |
| @@ -520,6 +505,10 @@ of `menu-bar-final-items'." | |||
| 520 | (progn | 505 | (progn |
| 521 | ;; Otherwise, it is a prefix, so make a list of the subcommands. | 506 | ;; Otherwise, it is a prefix, so make a list of the subcommands. |
| 522 | ;; Make a list of all the bindings in all the keymaps. | 507 | ;; Make a list of all the bindings in all the keymaps. |
| 508 | ;; FIXME: we'd really like to just use `key-binding' now that it | ||
| 509 | ;; returns a keymap that contains really all the bindings under that | ||
| 510 | ;; prefix, but `keyseq' is always [menu-bar], so the desired order of | ||
| 511 | ;; the bindings is difficult to recover. | ||
| 523 | (setq minorbind (mapcar 'cdr (minor-mode-key-binding keyseq))) | 512 | (setq minorbind (mapcar 'cdr (minor-mode-key-binding keyseq))) |
| 524 | (setq localbind (local-key-binding keyseq)) | 513 | (setq localbind (local-key-binding keyseq)) |
| 525 | (setq globalbind (copy-sequence (cdr (global-key-binding keyseq)))) | 514 | (setq globalbind (copy-sequence (cdr (global-key-binding keyseq)))) |