[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 26/39: Improved keyboard handling.
From: |
Phillip Lord |
Subject: |
[elpa] 26/39: Improved keyboard handling. |
Date: |
Mon, 20 Oct 2014 08:22:41 +0000 |
phillord pushed a commit to branch externals/pabbrev
in repository elpa.
commit 66435578633c987b6acb0db984922e809ba62811
Author: Phillip Lord <address@hidden>
Date: Tue Sep 16 21:46:01 2014 +0100
Improved keyboard handling.
Although not really deliberately done, effectively pabbrev had become
hard-coded to tab. This commit enables changing the keybinding, but
has to add specific support for tab and return.
---
pabbrev.el | 56 ++++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 42 insertions(+), 14 deletions(-)
diff --git a/pabbrev.el b/pabbrev.el
index 6c1e9ce..9075f31 100644
--- a/pabbrev.el
+++ b/pabbrev.el
@@ -620,14 +620,17 @@ it's ordering is part of the core data structures"
(defvar pabbrev-mode-map (make-keymap)
"Keymap for pabbrev-minor-mode.")
-;; I don't understand this. I thought that this were equivalent. But
-;; modes which define [tab] get used in preference to \t. So I define
-;; both. Don't change these without also changing the definition of
-;; pabbrev-expand-maybe.
+;; it should be possible to reconfigure this now, although there is special
+;; handling in `pabbrev-get-previous-binding' for tab and return and this
+;; might be needed for other bindings also.
+
+;; \t works in tty but gets overridden by the [tab] binding elsewhere.
(define-key pabbrev-mode-map "\t" 'pabbrev-expand-maybe)
+;; this is normally the one that gets called
(define-key pabbrev-mode-map [tab] 'pabbrev-expand-maybe)
+
;; xemacs has synced to newest easy-mmode now
;;(if (not pabbrev-xemacs-p)
(define-minor-mode pabbrev-mode
@@ -943,7 +946,11 @@ at buffer position END."
prev-binding
last-command))
(this-command prev-binding))
- (funcall prev-binding)))))
+ (if (eq 'self-insert-command prev-binding)
+ (self-insert-command 1)
+ (funcall prev-binding))))))
+
+
;; (defun pabbrev-call-previous-tab-binding ()
@@ -997,26 +1004,47 @@ With prefix argument, bring up a menu of all full
expansions."
;; (setq pabbrev-minimal-expansion-p nil)
-
(defun pabbrev-show-previous-binding ()
(interactive)
- (message "Previous binding is: %s"
+ (message "Previous binding is: %s"
(pabbrev-get-previous-binding)))
(defun pabbrev-get-previous-binding ()
"Show the binding of tab if pabbrev were not active.
The command `pabbrev-show-previous-binding' prints this out."
(let ((pabbrev-mode nil))
- ;; This is the original and satisfying solution
- ;;(key-binding (char-to-string last-command-event)))))
-
+ ;; tab is special, because we can bind both [tab]
+ ;; and \t. Normally, pabbrev binds to [tab] but for example
+ ;; so this-command-keys-vector returns [tab]. But, emacs-lisp-mode for
+ ;; instance, binds to \t. Now this has been overridden by the pabbrev
+ ;; binding for [tab]. But if we check for previous binding for [tab] it
+ ;; will be nil, because emacs-lisp-mode binds \t and not [tab]. So,
+ ;; we check for tab and return either the binding for tab or the binding
+ ;; for \t which should work regardless of what the mode binds.
+ ;; Likewise return it seems!
+ (let ((tckv
+ (if pabbrev-xemacs-p
+ (this-command-keys)
+ (this-command-keys-vector))))
+ (cond
+ ((or (equal tckv [tab])
+ (equal tckv [9]))
+ (or (key-binding [tab]) (key-binding "\t")))
+ ((or (equal tckv [return])
+ (equal tckv [32]))
+ (or (key-binding [return]) (key-binding "\n")))
+ (t
+ (key-binding tckv))))))
+
+ ;; ;; This is the original and satisfying solution
+ ;; (key-binding (this-command-keys))))
;; This is the new and unsatisfying one. The
;; keybindings are hard coded here, because I defined
;; [tab] and \t earlier. Both are tab, but the former
- ;; gets used in preference to the later.
- (or (key-binding [tab])
- (key-binding "\t"))))
-
+ ;; gets used in preference to the later.
+;; (or (key-binding [tab])
+;; (key-binding "\t"))))
+
;; ;; I think that I have this worked out now.
;; (if (eq prev-binding 'pabbrev-expand-maybe)
;; (message "pabbrev known bug! Avoiding recursive tab")
- [elpa] 13/39: Initial Checkin, (continued)
- [elpa] 13/39: Initial Checkin, Phillip Lord, 2014/10/20
- [elpa] 17/39: Version number added. Documentation fix. Indentation fix., Phillip Lord, 2014/10/20
- [elpa] 05/39: Ported from generic.el to define-derived-mode. Comment-character is now "#" rather than fudged "# " Delimited URIs now recognised as strings Electric indentation added. Indentation engine improved., Phillip Lord, 2014/10/20
- [elpa] 20/39: New keywords added., Phillip Lord, 2014/10/20
- [elpa] 18/39: Copes better with missing repos. Improved output., Phillip Lord, 2014/10/20
- [elpa] 19/39: Markdown support added., Phillip Lord, 2014/10/20
- [elpa] 21/39: Exclude nrepl mode., Phillip Lord, 2014/10/20
- [elpa] 14/39: Initial checkin., Phillip Lord, 2014/10/20
- [elpa] 23/39: Some code re-organisation. Checks whether pulse.el can cope with foreground pulse., Phillip Lord, 2014/10/20
- [elpa] 25/39: pabbrev-mode now sets inhibit-modification-hooks, Phillip Lord, 2014/10/20
- [elpa] 26/39: Improved keyboard handling.,
Phillip Lord <=
- [elpa] 22/39: Initial checkin, Phillip Lord, 2014/10/20
- [elpa] 27/39: Add cider-nrepl mode to ignored., Phillip Lord, 2014/10/20
- [elpa] 24/39: Keywords, Status added., Phillip Lord, 2014/10/20
- [elpa] 32/39: README.md added., Phillip Lord, 2014/10/20
- [elpa] 34/39: Version 4.0, Phillip Lord, 2014/10/20
- [elpa] 02/39: Initial checking to mercurial, Phillip Lord, 2014/10/20
- [elpa] 33/39: README.md update for version 4.0, Phillip Lord, 2014/10/20
- [elpa] 01/39: Initial checkin to Mercurial, Phillip Lord, 2014/10/20
- [elpa] 39/39: Set version to 0 for ELPA., Phillip Lord, 2014/10/20
- [elpa] 35/39: Prepare for next iteration., Phillip Lord, 2014/10/20