From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.emacs.devel Subject: Re: local keymap patch for key-binding Date: Fri, 15 Sep 2006 00:36:43 +0200 Message-ID: <85bqpim5xg.fsf@lola.goethe.zz> References: <87slj1hybl.fsf@stupidchicken.com> <85pse5cbqw.fsf@lola.goethe.zz> <87zmd7yjq4.fsf@furball.mit.edu> <85pse3n99c.fsf@lola.goethe.zz> <87r6yjxh7k.fsf@furball.mit.edu> <85venuc27c.fsf@lola.goethe.zz> <85r6yiivi7.fsf@lola.goethe.zz> <85hczdbdv2.fsf@lola.goethe.zz> <85mz959kkw.fsf@lola.goethe.zz> <854pvbiyax.fsf@lola.goethe.zz> <85r6yeek4e.fsf@lola.goethe.zz> <85fyeum61g.fsf@lola.goethe.zz> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1158273448 20197 80.91.229.2 (14 Sep 2006 22:37:28 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 14 Sep 2006 22:37:28 +0000 (UTC) Cc: cyd@stupidchicken.com, storm@cua.dk, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Sep 15 00:37:25 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GNzpW-00081S-LE for ged-emacs-devel@m.gmane.org; Fri, 15 Sep 2006 00:37:14 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GNzpV-0000iz-5y for ged-emacs-devel@m.gmane.org; Thu, 14 Sep 2006 18:37:09 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GNzpH-0000hx-K1 for emacs-devel@gnu.org; Thu, 14 Sep 2006 18:36:55 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GNzpF-0000hl-R2 for emacs-devel@gnu.org; Thu, 14 Sep 2006 18:36:54 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GNzpF-0000hi-Ka for emacs-devel@gnu.org; Thu, 14 Sep 2006 18:36:53 -0400 Original-Received: from [199.232.76.164] (helo=fencepost.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GNzrH-0003yg-P5 for emacs-devel@gnu.org; Thu, 14 Sep 2006 18:38:59 -0400 Original-Received: from localhost ([127.0.0.1] helo=lola.goethe.zz) by fencepost.gnu.org with esmtp (Exim 4.34) id 1GNzp7-0004yA-M3; Thu, 14 Sep 2006 18:36:46 -0400 Original-Received: by lola.goethe.zz (Postfix, from userid 1002) id 2E3A31C40B5C; Fri, 15 Sep 2006 00:36:43 +0200 (CEST) Original-To: rms@gnu.org In-Reply-To: <85fyeum61g.fsf@lola.goethe.zz> (David Kastrup's message of "Fri\, 15 Sep 2006 00\:34\:19 +0200") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:59848 Archived-At: --=-=-= David Kastrup writes: > Don't apply it unless the key-binding patch set has been applied > previously, or things will _really_ break. > > So once Richard has been able to look over his mail again, I'd like > to apply both patch sets. They work fine here. I am trying to set a new record for not or badly included patches. Next try: --=-=-= Content-Type: text/x-patch Content-Disposition: attachment Index: lisp/mouse.el =================================================================== RCS file: /sources/emacs/emacs/lisp/mouse.el,v retrieving revision 1.300 diff -u -r1.300 mouse.el *** lisp/mouse.el 17 Aug 2006 03:36:17 -0000 1.300 --- lisp/mouse.el 14 Sep 2006 22:23:10 -0000 *************** *** 775,780 **** --- 775,791 ---- (mouse-drag-track start-event t)))) + (defun mouse-posn-property (pos property) + "Look for a property at click position." + (if (consp pos) + (let ((w (posn-window pos)) (pt (posn-point pos)) + (str (posn-string pos))) + (or (and str + (get-text-property (cdr str) property (car str))) + (and pt + (get-char-property pt property w)))) + (get-char-property pos property))) + (defun mouse-on-link-p (pos) "Return non-nil if POS is on a link in the current buffer. POS must be a buffer position in the current buffer or a mouse *************** *** 814,837 **** - Otherwise, the mouse-1 event is translated into a mouse-2 event at the same position." ! (let ((w (and (consp pos) (posn-window pos)))) ! (if (consp pos) ! (setq pos (and (or mouse-1-click-in-non-selected-windows ! (eq (selected-window) w)) ! (posn-point pos)))) ! (when pos ! (with-current-buffer (window-buffer w) ! (let ((action ! (or (get-char-property pos 'follow-link) ! (save-excursion ! (goto-char pos) ! (key-binding [follow-link] nil t))))) ! (cond ! ((eq action 'mouse-face) ! (and (get-char-property pos 'mouse-face) t)) ! ((functionp action) ! (funcall action pos)) ! (t action))))))) (defun mouse-fixup-help-message (msg) "Fix help message MSG for `mouse-1-click-follows-link'." --- 825,842 ---- - Otherwise, the mouse-1 event is translated into a mouse-2 event at the same position." ! (let ((action ! (and (or (not (consp pos)) ! mouse-1-click-in-non-selected-windows ! (eq (selected-window) (posn-window pos))) ! (or (mouse-posn-property pos 'follow-link) ! (key-binding [follow-link] nil t pos))))) ! (cond ! ((eq action 'mouse-face) ! (and (mouse-posn-property pos 'mouse-face) t)) ! ((functionp action) ! (funcall action pos)) ! (t action)))) (defun mouse-fixup-help-message (msg) "Fix help message MSG for `mouse-1-click-follows-link'." *************** *** 904,910 **** ;; Use start-point before the intangibility ;; treatment, in case we click on a link inside an ;; intangible text. ! (mouse-on-link-p start-point))) (click-count (1- (event-click-count start-event))) (remap-double-click (and on-link (eq mouse-1-click-follows-link 'double) --- 909,915 ---- ;; Use start-point before the intangibility ;; treatment, in case we click on a link inside an ;; intangible text. ! (mouse-on-link-p start-posn))) (click-count (1- (event-click-count start-event))) (remap-double-click (and on-link (eq mouse-1-click-follows-link 'double) Index: lisp/mouse-sel.el =================================================================== RCS file: /sources/emacs/emacs/lisp/mouse-sel.el,v retrieving revision 1.47 diff -u -r1.47 mouse-sel.el *** lisp/mouse-sel.el 6 Feb 2006 14:33:34 -0000 1.47 --- lisp/mouse-sel.el 14 Sep 2006 22:23:10 -0000 *************** *** 702,708 **** using double-clicks." (and initial final mouse-1-click-follows-link (eq (car initial) 'down-mouse-1) ! (mouse-on-link-p (posn-point (event-start initial))) (= (posn-point (event-start initial)) (posn-point (event-end final))) (= (event-click-count initial) 1) --- 702,708 ---- using double-clicks." (and initial final mouse-1-click-follows-link (eq (car initial) 'down-mouse-1) ! (mouse-on-link-p (event-start initial)) (= (posn-point (event-start initial)) (posn-point (event-end final))) (= (event-click-count initial) 1) Index: lisp/help.el =================================================================== RCS file: /sources/emacs/emacs/lisp/help.el,v retrieving revision 1.315 diff -u -r1.315 help.el *** lisp/help.el 11 Sep 2006 09:47:43 -0000 1.315 --- lisp/help.el 14 Sep 2006 22:23:12 -0000 *************** *** 567,577 **** (menu-bar-update-yank-menu "(any string)" nil)) (setq key (read-key-sequence "Describe key (or click or menu item): ")) ;; If KEY is a down-event, read and discard the ! ;; corresponding up-event. ! (if (and (vectorp key) ! (eventp (elt key 0)) ! (memq 'down (event-modifiers (elt key 0)))) ! (read-event)) (list key (if current-prefix-arg (prefix-numeric-value current-prefix-arg)) --- 567,582 ---- (menu-bar-update-yank-menu "(any string)" nil)) (setq key (read-key-sequence "Describe key (or click or menu item): ")) ;; If KEY is a down-event, read and discard the ! ;; corresponding up-event. Note that there are also ! ;; down-events on scroll bars and mode lines: the actual ! ;; event then is in the second element of the vector. ! (and (vectorp key) ! (or (and (eventp (aref key 0)) ! (memq 'down (event-modifiers (aref key 0)))) ! (and (> (length key) 1) ! (eventp (aref key 1)) ! (memq 'down (event-modifiers (aref key 1))))) ! (read-event)) (list key (if current-prefix-arg (prefix-numeric-value current-prefix-arg)) *************** *** 582,626 **** (fset 'yank-menu (cons 'keymap yank-menu)))))) (if (numberp untranslated) (setq untranslated (this-single-command-raw-keys))) ! (save-excursion ! (let ((modifiers (event-modifiers (aref key 0))) ! (standard-output (if insert (current-buffer) t)) ! window position) ! ;; For a mouse button event, go to the button it applies to ! ;; to get the right key bindings. And go to the right place ! ;; in case the keymap depends on where you clicked. ! (if (or (memq 'click modifiers) (memq 'down modifiers) ! (memq 'drag modifiers)) ! (setq window (posn-window (event-start (aref key 0))) ! position (posn-point (event-start (aref key 0))))) ! (if (windowp window) ! (progn ! (set-buffer (window-buffer window)) ! (goto-char position))) ! ;; Ok, now look up the key and name the command. ! (let ((defn (key-binding key t)) ! key-desc) ! ;; Handle the case where we faked an entry in "Select and Paste" menu. ! (if (and (eq defn nil) ! (stringp (aref key (1- (length key)))) ! (eq (key-binding (substring key 0 -1)) 'yank-menu)) ! (setq defn 'menu-bar-select-yank)) ! ;; Don't bother user with strings from (e.g.) the select-paste menu. ! (if (stringp (aref key (1- (length key)))) ! (aset key (1- (length key)) "(any string)")) ! (if (and (> (length untranslated) 0) ! (stringp (aref untranslated (1- (length untranslated))))) ! (aset untranslated (1- (length untranslated)) ! "(any string)")) ! ;; Now describe the key, perhaps as changed. ! (setq key-desc (help-key-description key untranslated)) ! (if (or (null defn) (integerp defn) (equal defn 'undefined)) ! (princ (format "%s is undefined" key-desc)) ! (princ (format (if (windowp window) ! "%s at that spot runs the command %s" ! "%s runs the command %s") ! key-desc ! (if (symbolp defn) defn (prin1-to-string defn))))))))) (defun describe-key (&optional key untranslated up-event) "Display documentation of the function invoked by KEY. --- 587,626 ---- (fset 'yank-menu (cons 'keymap yank-menu)))))) (if (numberp untranslated) (setq untranslated (this-single-command-raw-keys))) ! (let* ((event (if (and (symbolp (aref key 0)) ! (> (length key) 1) ! (consp (aref key 1))) ! (aref key 1) ! (aref key 0))) ! (modifiers (event-modifiers event)) ! (standard-output (if insert (current-buffer) t)) ! (mousep ! (or (memq 'click modifiers) (memq 'down modifiers) ! (memq 'drag modifiers)))) ! ;; Ok, now look up the key and name the command. ! (let ((defn (key-binding key t)) ! key-desc) ! ;; Handle the case where we faked an entry in "Select and Paste" menu. ! (if (and (eq defn nil) ! (stringp (aref key (1- (length key)))) ! (eq (key-binding (substring key 0 -1)) 'yank-menu)) ! (setq defn 'menu-bar-select-yank)) ! ;; Don't bother user with strings from (e.g.) the select-paste menu. ! (if (stringp (aref key (1- (length key)))) ! (aset key (1- (length key)) "(any string)")) ! (if (and (> (length untranslated) 0) ! (stringp (aref untranslated (1- (length untranslated))))) ! (aset untranslated (1- (length untranslated)) ! "(any string)")) ! ;; Now describe the key, perhaps as changed. ! (setq key-desc (help-key-description key untranslated)) ! (if (or (null defn) (integerp defn) (equal defn 'undefined)) ! (princ (format "%s is undefined" key-desc)) ! (princ (format (if mousep ! "%s at that spot runs the command %s" ! "%s runs the command %s") ! key-desc ! (if (symbolp defn) defn (prin1-to-string defn)))))))) (defun describe-key (&optional key untranslated up-event) "Display documentation of the function invoked by KEY. *************** *** 652,756 **** (prefix-numeric-value current-prefix-arg) ;; If KEY is a down-event, read the corresponding up-event ;; and use it as the third argument. ! (if (and (vectorp key) ! (eventp (elt key 0)) ! (memq 'down (event-modifiers (elt key 0)))) ! (read-event)))) ;; Put yank-menu back as it was, if we changed it. (when saved-yank-menu (setq yank-menu (copy-sequence saved-yank-menu)) (fset 'yank-menu (cons 'keymap yank-menu)))))) (if (numberp untranslated) (setq untranslated (this-single-command-raw-keys))) ! (save-excursion ! (let ((modifiers (event-modifiers (aref key 0))) ! window position) ! ;; For a mouse button event, go to the button it applies to ! ;; to get the right key bindings. And go to the right place ! ;; in case the keymap depends on where you clicked. ! (if (or (memq 'click modifiers) (memq 'down modifiers) ! (memq 'drag modifiers)) ! (setq window (posn-window (event-start (aref key 0))) ! position (posn-point (event-start (aref key 0))))) ! (when (windowp window) ! (set-buffer (window-buffer window)) ! (goto-char position)) ! (let ((defn (key-binding key t))) ! ;; Handle the case where we faked an entry in "Select and Paste" menu. ! (if (and (eq defn nil) ! (stringp (aref key (1- (length key)))) ! (eq (key-binding (substring key 0 -1)) 'yank-menu)) ! (setq defn 'menu-bar-select-yank)) ! (if (or (null defn) (integerp defn) (equal defn 'undefined)) ! (message "%s is undefined" (help-key-description key untranslated)) ! (help-setup-xref (list #'describe-function defn) (interactive-p)) ! ;; Don't bother user with strings from (e.g.) the select-paste menu. ! (if (stringp (aref key (1- (length key)))) ! (aset key (1- (length key)) "(any string)")) ! (if (and untranslated ! (stringp (aref untranslated (1- (length untranslated))))) ! (aset untranslated (1- (length untranslated)) ! "(any string)")) ! (with-output-to-temp-buffer (help-buffer) ! (princ (help-key-description key untranslated)) ! (if (windowp window) ! (princ " at that spot")) ! (princ " runs the command ") ! (prin1 defn) ! (princ "\n which is ") ! (describe-function-1 defn) ! (when up-event ! (let ((type (event-basic-type up-event)) ! (hdr "\n\n-------------- up event ---------------\n\n") ! defn sequence ! mouse-1-tricky mouse-1-remapped) ! (setq sequence (vector up-event)) ! (when (and (eq type 'mouse-1) ! (windowp window) ! mouse-1-click-follows-link ! (not (eq mouse-1-click-follows-link 'double)) ! (setq mouse-1-remapped ! (with-current-buffer (window-buffer window) ! (mouse-on-link-p (posn-point ! (event-start up-event)))))) ! (setq mouse-1-tricky (and (integerp mouse-1-click-follows-link) ! (> mouse-1-click-follows-link 0))) ! (cond ((stringp mouse-1-remapped) ! (setq sequence mouse-1-remapped)) ! ((vectorp mouse-1-remapped) ! (setcar up-event (elt mouse-1-remapped 0))) ! (t (setcar up-event 'mouse-2)))) ! (setq defn (key-binding sequence)) ! (unless (or (null defn) (integerp defn) (equal defn 'undefined)) ! (princ (if mouse-1-tricky ! "\n\n----------------- up-event (short click) ----------------\n\n" ! hdr)) ! (setq hdr nil) ! (princ (symbol-name type)) ! (if (windowp window) (princ " at that spot")) ! (if mouse-1-remapped ! (princ " is remapped to \n which" )) (princ " runs the command ") (prin1 defn) (princ "\n which is ") ! (describe-function-1 defn)) ! (when mouse-1-tricky ! (setcar up-event 'mouse-1) ! (setq defn (key-binding (vector up-event))) ! (unless (or (null defn) (integerp defn) (eq defn 'undefined)) ! (princ (or hdr ! "\n\n----------------- up-event (long click) ----------------\n\n")) ! (princ "Pressing mouse-1") ! (if (windowp window) ! (princ " at that spot")) ! (princ (format " for longer than %d milli-seconds\n" ! mouse-1-click-follows-link)) ! (princ " runs the command ") ! (prin1 defn) ! (princ "\n which is ") ! (describe-function-1 defn))))) ! (print-help-return-message))))))) (defun describe-mode (&optional buffer) "Display documentation of current major mode and minor modes. --- 652,755 ---- (prefix-numeric-value current-prefix-arg) ;; If KEY is a down-event, read the corresponding up-event ;; and use it as the third argument. ! (and (vectorp key) ! (or (and (eventp (aref key 0)) ! (memq 'down (event-modifiers (aref key 0)))) ! (and (> (length key) 1) ! (eventp (aref key 1)) ! (memq 'down (event-modifiers (aref key 1))))) ! (read-event)))) ;; Put yank-menu back as it was, if we changed it. (when saved-yank-menu (setq yank-menu (copy-sequence saved-yank-menu)) (fset 'yank-menu (cons 'keymap yank-menu)))))) (if (numberp untranslated) (setq untranslated (this-single-command-raw-keys))) ! (let* ((event (if (and (symbolp (aref key 0)) ! (> (length key) 1) ! (consp (aref key 1))) ! (aref key 1) ! (aref key 0))) ! (modifiers (event-modifiers event)) ! (mousep ! (or (memq 'click modifiers) (memq 'down modifiers) ! (memq 'drag modifiers)))) ! ;; Ok, now look up the key and name the command. ! ! (let ((defn (key-binding key t))) ! ;; Handle the case where we faked an entry in "Select and Paste" menu. ! (if (and (eq defn nil) ! (stringp (aref key (1- (length key)))) ! (eq (key-binding (substring key 0 -1)) 'yank-menu)) ! (setq defn 'menu-bar-select-yank)) ! (if (or (null defn) (integerp defn) (equal defn 'undefined)) ! (message "%s is undefined" (help-key-description key untranslated)) ! (help-setup-xref (list #'describe-function defn) (interactive-p)) ! ;; Don't bother user with strings from (e.g.) the select-paste menu. ! (if (stringp (aref key (1- (length key)))) ! (aset key (1- (length key)) "(any string)")) ! (if (and untranslated ! (stringp (aref untranslated (1- (length untranslated))))) ! (aset untranslated (1- (length untranslated)) ! "(any string)")) ! (with-output-to-temp-buffer (help-buffer) ! (princ (help-key-description key untranslated)) ! (if mousep ! (princ " at that spot")) ! (princ " runs the command ") ! (prin1 defn) ! (princ "\n which is ") ! (describe-function-1 defn) ! (when up-event ! (let ((type (event-basic-type up-event)) ! (hdr "\n\n-------------- up event ---------------\n\n") ! defn sequence ! mouse-1-tricky mouse-1-remapped) ! (setq sequence (vector up-event)) ! (when (and (eq type 'mouse-1) ! mouse-1-click-follows-link ! (not (eq mouse-1-click-follows-link 'double)) ! (setq mouse-1-remapped ! (mouse-on-link-p (event-start up-event)))) ! (setq mouse-1-tricky (and (integerp mouse-1-click-follows-link) ! (> mouse-1-click-follows-link 0))) ! (cond ((stringp mouse-1-remapped) ! (setq sequence mouse-1-remapped)) ! ((vectorp mouse-1-remapped) ! (setcar up-event (elt mouse-1-remapped 0))) ! (t (setcar up-event 'mouse-2)))) ! (setq defn (key-binding sequence nil nil (event-start up-event))) ! (unless (or (null defn) (integerp defn) (equal defn 'undefined)) ! (princ (if mouse-1-tricky ! "\n\n----------------- up-event (short click) ----------------\n\n" ! hdr)) ! (setq hdr nil) ! (princ (symbol-name type)) ! (if mousep ! (princ " at that spot")) ! (if mouse-1-remapped ! (princ " is remapped to \n which" )) ! (princ " runs the command ") ! (prin1 defn) ! (princ "\n which is ") ! (describe-function-1 defn)) ! (when mouse-1-tricky ! (setcar up-event 'mouse-1) ! (setq defn (key-binding (vector up-event) nil nil ! (event-start up-event))) ! (unless (or (null defn) (integerp defn) (eq defn 'undefined)) ! (princ (or hdr ! "\n\n----------------- up-event (long click) ----------------\n\n")) ! (princ "Pressing mouse-1") ! (if mousep (princ " at that spot")) ! (princ (format " for longer than %d milli-seconds\n" ! mouse-1-click-follows-link)) (princ " runs the command ") (prin1 defn) (princ "\n which is ") ! (describe-function-1 defn))))) ! (print-help-return-message)))))) (defun describe-mode (&optional buffer) "Display documentation of current major mode and minor modes. Index: lisp/ChangeLog =================================================================== RCS file: /sources/emacs/emacs/lisp/ChangeLog,v retrieving revision 1.10062 diff -u -r1.10062 ChangeLog *** lisp/ChangeLog 14 Sep 2006 17:52:07 -0000 1.10062 --- lisp/ChangeLog 14 Sep 2006 22:23:44 -0000 *************** *** 1,4 **** ! 2006-09-005 Ken Manheimer * allout.el (allout-regexp, allout-line-boundary-regexp) (allout-bob-regexp): Correct grouping and boundaries to fix --- 1,22 ---- ! 2006-09-15 David Kastrup ! ! * mouse-sel.el (mouse-sel-follow-link-p): Use event position ! instead of buffer position for `mouse-on-link-p'. ! ! * mouse.el (mouse-posn-property): New function looking up the ! properties at a click position in overlays and text properties in ! either buffer or strings. ! (mouse-on-link-p): Use `mouse-posn-property' to streamline lookup ! of both `follow-link' as well as `mouse-face' properties. ! (mouse-drag-track): Check `mouse-on-link-p' on event position, not ! buffer position. ! ! * help.el (describe-key-briefly): When reading a down-event on ! mode lines or scroll bar, swallow the following up event, too. ! Use the new mouse sensitity of `key-binding' for lookup. ! (describe-key): The same here. ! ! 2006-09-05 Ken Manheimer * allout.el (allout-regexp, allout-line-boundary-regexp) (allout-bob-regexp): Correct grouping and boundaries to fix --=-=-= -- David Kastrup, Kriemhildstr. 15, 44793 Bochum --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --=-=-=--