(define-key map (char-to-string ch) 'undefined)
(setq ch (1+ ch)))
(setq ch ?0)
- (while (< ch ?9)
+ (while (<= ch ?9)
(define-key map (char-to-string ch) 'menudiag-goto-item)
(setq ch (1+ ch)))
(setq ch ?a)
- (while (< ch ?z)
+ (while (<= ch ?z)
(define-key map (char-to-string ch) 'menudiag-goto-item)
(setq ch (1+ ch)))
(setq ch ?A)
- (while (< ch ?Z)
+ (while (<= ch ?Z)
(define-key map (char-to-string ch) 'menudiag-goto-item)
(setq ch (1+ ch)))
(define-key map "\C-a" 'menudiag-beginning-of-line)
(defun menudiag-make-selection-list (item-list line-width)
(let ((l nil)
(line nil)
- (width 0))
+ (width 0)
+ (i 0))
(while item-list
(let* ((item (car item-list))
(item-width (menudiag-item-width item)))
- (if (and line (>= (+ width item-width) line-width))
+ (if (and line (or (>= (+ width item-width) line-width)
+ (>= i 36)))
(setq l (cons (reverse line) l)
line nil
- width 0))
+ width 0
+ i 0))
(setq line (cons item line)
width (+ width (menudiag-item-width item))
+ i (1+ i)
item-list (cdr item-list))))
(if line
(reverse (cons (reverse line) l))
(interactive)
(menudiag-goto-item-internal (1- (length line))))
+;; Should retain compatibility. Must.
+;;
+;;(defun menudiag-forward-item ()
+;; (interactive)
+;; (if (< pos-in-line (1- (length line)))
+;; (menudiag-goto-item-internal (1+ pos-in-line))
+;; (if (>= linepos (1- (length selection-list)))
+;; (signal 'end-of-buffer "")
+;; (menudiag-goto-line (1+ linepos))
+;; (menudiag-beginning-of-line))))
+;;
+;;(defun menudiag-backward-item ()
+;; (interactive)
+;; (if (< 0 pos-in-line)
+;; (menudiag-goto-item-internal (1- pos-in-line))
+;; (if (< linepos 1)
+;; (signal 'beginning-of-buffer "")
+;; (menudiag-goto-line (1- linepos))
+;; (menudiag-end-of-line))))
+;;
+;;(defun menudiag-goto-line (n)
+;; (if (or (>= n (length selection-list)) (< n 0))
+;; (ding)
+;; (setq line (nth n selection-list)
+;; linepos n)
+;; (delete-region (point-min) (point-max))
+;; (insert (menudiag-make-menu-formatted-string line))))
+;;
+
(defun menudiag-forward-item ()
(interactive)
(if (< pos-in-line (1- (length line)))
(menudiag-goto-item-internal (1+ pos-in-line))
(if (>= linepos (1- (length selection-list)))
- (signal 'end-of-buffer "")
- (menudiag-goto-line (1+ linepos))
- (menudiag-beginning-of-line))))
+ (menudiag-goto-line 0)
+ (menudiag-goto-line (1+ linepos)))
+ (menudiag-beginning-of-line)))
(defun menudiag-backward-item ()
(interactive)
(if (< 0 pos-in-line)
(menudiag-goto-item-internal (1- pos-in-line))
(if (< linepos 1)
- (signal 'beginning-of-buffer "")
- (menudiag-goto-line (1- linepos))
- (menudiag-end-of-line))))
+ (menudiag-goto-line (1- (length selection-list)))
+ (menudiag-goto-line (1- linepos)))
+ (menudiag-end-of-line)))
(defun menudiag-goto-line (n)
- (if (or (>= n (length selection-list)) (< n 0))
- (ding)
- (setq line (nth n selection-list)
- linepos n)
- (delete-region (point-min) (point-max))
- (insert (menudiag-make-menu-formatted-string line))))
+ (cond
+ ((>= n (length selection-list))
+ (setq n 0))
+ ((< n 0)
+ (setq n (1- (length selection-list)))))
+ (setq line (nth n selection-list)
+ linepos n)
+ (delete-region (point-min) (point-max))
+ (insert (menudiag-make-menu-formatted-string line)))
(defun menudiag-next-line ()
(interactive)