;;; mouse.el --- window system-independent mouse support
;; Copyright (C) 1993, 1994, 1995, 1999, 2000, 2001, 2002, 2003,
-;; 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+;; 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
;; Maintainer: FSF
;; Keywords: hardware, mouse
;; Make a keymap in which our last command leads to a menu or
;; default to the edit menu.
(newmap (if ancestor
- (make-sparse-keymap (concat mode-name " Mode"))
- menu-bar-edit-menu)))
+ (make-sparse-keymap (concat (format-mode-line mode-name)
+ " Mode"))
+ menu-bar-edit-menu))
+ uniq)
(if ancestor
;; Make our menu inherit from the desired keymap which we want
;; to display as the menu now.
- (set-keymap-parent newmap ancestor))
+ ;; Sometimes keymaps contain duplicate menu code, leading to
+ ;; duplicates in the popped-up menu. Avoid this by simply
+ ;; taking the first of any identically-named menus.
+ ;; http://lists.gnu.org/archive/html/emacs-devel/2007-11/msg00469.html
+ (set-keymap-parent newmap
+ (progn
+ (dolist (e ancestor)
+ (unless (and (listp e)
+ (assoc (car e) uniq))
+ (setq uniq (append uniq (list e)))))
+ uniq)))
(popup-menu newmap event prefix)))
(or (null local-menu)
(stringp local-title-or-map)
(setq local-menu (cons 'keymap
- (cons (concat mode-name " Mode Menu")
+ (cons (concat (format-mode-line mode-name)
+ " Mode Menu")
(cdr local-menu)))))
(or (stringp global-title-or-map)
(setq global-menu (cons 'keymap
(setq mouse-selection-click-count 0)
(yank arg))
+(defun mouse-yank-primary (click)
+ "Insert the primary selection at the position clicked on.
+Move point to the end of the inserted text.
+If `mouse-yank-at-point' is non-nil, insert at point
+regardless of where you click."
+ (interactive "e")
+ ;; Give temporary modes such as isearch a chance to turn off.
+ (run-hooks 'mouse-leave-buffer-hook)
+ (or mouse-yank-at-point (mouse-set-point click))
+ (let ((primary (x-get-selection 'PRIMARY)))
+ (if primary
+ (insert (x-get-selection 'PRIMARY))
+ (error "No primary selection"))))
+
(defun mouse-kill-ring-save (click)
"Copy the region between point and the mouse click in the kill ring.
This does not delete the region; it acts like \\[kill-ring-save]."
(setq elt (list adjusted-major-mode
(if (stringp adjusted-major-mode)
adjusted-major-mode
- mode-name))
+ (format-mode-line mode-name nil nil buf)))
split-by-major-mode (cons elt split-by-major-mode)))
(or (memq buf (cdr (cdr elt)))
(setcdr (cdr elt) (cons buf (cdr (cdr elt))))))))
(cons
(cons
(format
- (format "%%%ds %%s%%s %%s" maxlen)
+ (format "%%-%ds %%s%%s %%s" maxlen)
(buffer-name elt)
(if (buffer-modified-p elt) "*" " ")
(save-excursion