aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorKarl Heuer1994-09-15 22:16:49 +0000
committerKarl Heuer1994-09-15 22:16:49 +0000
commit3dd92899562e644e87f26488cee2ecafba68f41d (patch)
tree95346cf16f437d3feda252c588d57a1a568d95a2 /lisp
parentf77e1e4b80dfb580be8c53f3a95be5356cedde0e (diff)
downloademacs-3dd92899562e644e87f26488cee2ecafba68f41d.tar.gz
emacs-3dd92899562e644e87f26488cee2ecafba68f41d.zip
(yank-menu): New variable; kill-ring in menu format.
(menu-bar-update-yank-menu, menu-bar-select-yank): New function.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/menu-bar.el67
1 files changed, 31 insertions, 36 deletions
diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el
index a868ac4c69c..57306178ce0 100644
--- a/lisp/menu-bar.el
+++ b/lisp/menu-bar.el
@@ -105,9 +105,12 @@
105 '("--")) 105 '("--"))
106 106
107(define-key menu-bar-edit-menu [clear] '("Clear" . delete-region)) 107(define-key menu-bar-edit-menu [clear] '("Clear" . delete-region))
108(define-key menu-bar-edit-menu [choose-next-paste] 108
109 '("Choose Next Paste >" . mouse-menu-choose-yank)) 109(define-key menu-bar-edit-menu [paste] '("Paste most recent" . yank))
110(define-key menu-bar-edit-menu [paste] '("Paste" . yank)) 110
111(defvar yank-menu (cons "Select Yank" nil))
112(fset 'yank-menu (cons 'keymap yank-menu))
113(define-key menu-bar-edit-menu [select-paste] '("Select and Paste" . yank-menu))
111(define-key menu-bar-edit-menu [copy] '("Copy" . kill-ring-save)) 114(define-key menu-bar-edit-menu [copy] '("Copy" . kill-ring-save))
112(define-key menu-bar-edit-menu [cut] '("Cut" . kill-region)) 115(define-key menu-bar-edit-menu [cut] '("Cut" . kill-region))
113(define-key menu-bar-edit-menu [undo] '("Undo" . undo)) 116(define-key menu-bar-edit-menu [undo] '("Undo" . undo))
@@ -116,6 +119,7 @@
116(put 'kill-region 'menu-enable 'mark-active) 119(put 'kill-region 'menu-enable 'mark-active)
117(put 'kill-ring-save 'menu-enable 'mark-active) 120(put 'kill-ring-save 'menu-enable 'mark-active)
118(put 'yank 'menu-enable '(x-selection-exists-p)) 121(put 'yank 'menu-enable '(x-selection-exists-p))
122(put 'yank-menu 'menu-enable '(cdr yank-menu))
119(put 'delete-region 'menu-enable 'mark-active) 123(put 'delete-region 'menu-enable 'mark-active)
120(put 'undo 'menu-enable '(if (eq last-command 'undo) 124(put 'undo 'menu-enable '(if (eq last-command 'undo)
121 pending-undo-list 125 pending-undo-list
@@ -232,40 +236,31 @@ Do the same for the keys of the same name."
232 buffer-undo-list))) 236 buffer-undo-list)))
233 237
234(defvar yank-menu-length 100 238(defvar yank-menu-length 100
235 "*Maximum length of an item in the menu for \ 239 "*Maximum length to display in the yank-menu.")
236\\[mouse-menu-choose-yank].") 240
237 241(defun menu-bar-update-yank-menu (string old)
238(defun mouse-menu-choose-yank (event) 242 (let ((front (car (cdr yank-menu)))
239 "Pop up a menu of the kill-ring for selection with the mouse. 243 (menu-string (if (<= (length string) yank-menu-length)
240The kill-ring-yank-pointer is moved to the selected element. 244 string
241A subsequent \\[yank] yanks the choice just selected." 245 (substring string 0 yank-menu-length))))
242 (interactive "e") 246 ;; If we're supposed to be extending an existing string, and that
243 (let* ((count 0) 247 ;; string really is at the front of the menu, then update it in place.
244 (menu (mapcar (lambda (string) 248 (if (and old (or (eq old (car front))
245 (if (> (length string) yank-menu-length) 249 (string= old (car front))))
246 (setq string (substring string
247 0 yank-menu-length)))
248 (prog1 (cons string count)
249 (setq count (1+ count))))
250 kill-ring))
251 (arg (x-popup-menu event
252 (list "Yank Menu"
253 (cons "Choose Next Yank" menu)))))
254 ;; A mouse click outside the menu returns nil.
255 ;; Avoid a confusing error from passing nil to rotate-yank-pointer.
256 ;; XXX should this perhaps do something other than simply return? -rm
257 (if arg
258 (progn 250 (progn
259 ;; We don't use `rotate-yank-pointer' because we want to move 251 (setcar front string)
260 ;; relative to the beginning of kill-ring, not the current 252 (setcar (cdr front) menu-string))
261 ;; position. Also, that would ask for any new X selection and 253 (setcdr yank-menu
262 ;; thus change the list of items the user just chose from, which 254 (cons
263 ;; would be highly confusing. 255 (cons string (cons menu-string 'menu-bar-select-yank))
264 (setq kill-ring-yank-pointer (nthcdr arg kill-ring)) 256 (cdr yank-menu)))))
265 (if (interactive-p) 257 (if (> (length (cdr yank-menu)) kill-ring-max)
266 (message "The next yank will insert the selected text.") 258 (setcdr (nthcdr kill-ring-max yank-menu) nil)))
267 (current-kill 0)))))) 259
268(put 'mouse-menu-choose-yank 'menu-enable 'kill-ring) 260(defun menu-bar-select-yank ()
261 (interactive "*")
262 (push-mark (point))
263 (insert last-command-event))
269 264
270(define-key global-map [menu-bar buffer] '("Buffers" . menu-bar-buffers)) 265(define-key global-map [menu-bar buffer] '("Buffers" . menu-bar-buffers))
271 266