Package: emacs-goodies-el
Version: 35.12
Severity: normal

Dear Maintainer,

The functions home-end-end and home-end home didn't work for me,
because they were assuming a keyboard-event (key-press) was being
stored as a single byte, or single element, in the vector returned by
funciton recent-keys. However, on my machine at least, each of those
key-presses seems to be three bytes in length, and is recorded as
three elements of the vector returned by recent-keys. ( [home] was
being recorded as the sequence '27 79 72' (ESC-O-H); [end] was being
recorded as the sequence '27 79 70' (ESC-O-F)).

So, I started modifying the code. Results below.

While I was at it, I generalized the core functionality into a
separate function, so that it might easily and portably be re-used for
repeating other (three-byte-long) keyboard-events. I supose I could
rewrite it for an unlimited number of unique repetition reactions to
any-byte-length event, but I don't see the pressing need for such.

;---------------------------------------------------------------------
(defun home-quadruple-play (&optional arg)
  "React uniquely to repeated presses of the `home' key. A first key-pre\
ss moves the point to the beginning of the current line; a second key-pr\
ess moves the point to the beginning of the current visible window, and;\
 a third key-press moves the point to the beginning of the buffer.
   Additionally, with numeric `arg' N, this command calls function `begi\
nning-of-buffer' to move the point to the (N*10)% position of the buffer\
..
  Recommended usage is to bind this function to the `home' key by, for i\
nstance, placing the following in the .emacs file:
  `(global-set-key [home] \'home-quadruple-play)'"
  (interactive "P")
  (if arg
      (beginning-of-buffer arg)
    (keypress-triple-play
      '(lambda() (setq home-end-marker (copy-marker (point)))
                 (beginning-of-line))
      '(lambda() (push-mark home-end-marker)
                 (move-to-window-line 0))
      '(lambda() (goto-char (point-min))))
))

(defun end-quadruple-play (&optional arg)
  "React uniquely to repeated presses of the `end' key. A first key-pres\
s moves the point to the end of the current line; a second key-press mov\
es the point to the end of the current visible window, and; a third key-\
press moves the point to the end of the buffer.
   Additionally, with numeric `arg' N, this command calls function `end-\
of-buffer' to move the point to the (100-N*10)% position of the buffer.
  Recommended usage is to bind this function to the `end' key by, for in\
stance, placing the following in the .emacs file:
  `(global-set-key [end] \'end-quadruple-play)'"
  (interactive "P")
  (if arg
      (end-of-buffer arg)
    (keypress-triple-play
      '(lambda() (setq home-end-marker (copy-marker (point)))
                 (end-of-line))
      '(lambda() (push-mark home-end-marker)
                 (move-to-window-line -1)
                 (end-of-line))
      '(lambda() (goto-char (point-max))))
))

(defun keypress-triple-play (react_1 react_2 react_3)
  "Respond to a repeated keyboard-event (key-press) based upon the numbe\
r of its repetitions. When the key-press has been performed once, react_\
 by calling function `react_1'; When the key-press is repeated once, rea\
ct_ by calling function `react_2'; When the key-press is repeated more o\
ften, react_ by calling function `react_3'.
   This function was originally written to support functions `home-quadr\
uple-play' and `end-quadruple-play'. See there as example usages. These \
three functions replace functions `home-end-home' and `home-end-end' in \
file `home-end.el' of Debian\'s `emacs-goodies-el' package."
  (interactive)
  (if (or executing-kbd-macro
          defining-kbd-macro)
      (funcall react_1))
    (let* ((keys (recent-keys))
           (len (length keys))
           (key1 (if (> len 3) (vector (elt keys (- len 1))
                                       (elt keys (- len 2))
                                       (elt keys (- len 3)))
                     nil))
           (key2 (if (> len 6) (vector (elt keys (- len 4))
                                       (elt keys (- len 5))
                                       (elt keys (- len 6)))
                     nil))
           (key3 (if (> len 9) (vector (elt keys (- len 7))
                                       (elt keys (- len 8))
                                       (elt keys (- len 9)))
                     nil))
           (key-equal-1 (equal key1 key2))
           (key-equal-2 (and key-equal-1 (equal key2 key3))))
      (cond
           (key-equal-2 (funcall react_3))
           (key-equal-1 (funcall react_2))
           (t           (funcall react_1))
)))
;---------------------------------------------------------------------



-- System Information:
Debian Release: jessie/sid
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.13-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages emacs-goodies-el depends on:
ii  bash                   4.3-9
ii  dpkg                   1.17.10
ii  emacs24-nox [emacsen]  24.3+1-4+b1
ii  install-info           5.2.0.dfsg.1-4

Versions of packages emacs-goodies-el recommends:
ii  dict      1.12.1+dfsg-2
ii  perl-doc  5.20.0-4
ii  wget      1.15-1+b1

emacs-goodies-el suggests no packages.

-- no debconf information


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to