From dccb0688651388531f00de3c8b365cdabcf54aa2 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Sun, 4 May 2014 21:46:47 -0400 Subject: [PATCH 01/24] * lisp/minibuffer.el (completion-table-with-quoting) : Make sure the new point we return is within the new string. Fixes: debbugs:17239 --- lisp/ChangeLog | 5 +++++ lisp/minibuffer.el | 35 ++++++++++++++++++++++++++++++----- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e1a0ee66dd7..bef5f1ba71f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2014-05-05 Stefan Monnier + + * minibuffer.el (completion-table-with-quoting) : + Make sure the new point we return is within the new string (bug#17239). + 2014-05-03 Eli Zaretskii * mail/rmailsum.el (rmail-new-summary-1): Fix a typo in a comment. diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 9dd4ef9fe04..87ba8a22e64 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -519,11 +519,35 @@ for use at QPOS." completions)) ((eq action 'completion--unquote) - (let ((ustring (funcall unquote string)) - (uprefix (funcall unquote (substring string 0 pred)))) - ;; We presume (more or less) that `concat' and `unquote' commute. - (cl-assert (string-prefix-p uprefix ustring)) - (list ustring table (length uprefix) + ;; PRED is really a POINT in STRING. + ;; We should return a new set (STRING TABLE POINT REQUOTE) + ;; where STRING is a new (unquoted) STRING to match against the new TABLE + ;; using a new POINT inside it, and REQUOTE is a requoting function which + ;; should reverse the unquoting, (i.e. it receives the completion result + ;; of using the new TABLE and should turn it into the corresponding + ;; quoted result). + (let* ((qpos pred) + (ustring (funcall unquote string)) + (uprefix (funcall unquote (substring string 0 qpos))) + ;; FIXME: we really should pass `qpos' to `unuote' and have that + ;; function give us the corresponding `uqpos'. But for now we + ;; presume (more or less) that `concat' and `unquote' commute. + (uqpos (if (string-prefix-p uprefix ustring) + ;; Yay!! They do seem to commute! + (length uprefix) + ;; They don't commute this time! :-( + ;; Maybe qpos is in some text that disappears in the + ;; ustring (bug#17239). Let's try a second chance guess. + (let ((usuffix (funcall unquote (substring string qpos)))) + (if (string-suffix-p usuffix ustring) + ;; Yay!! They still "commute" in a sense! + (- (length ustring) (length usuffix)) + ;; Still no luck! Let's just choose *some* position + ;; within ustring. + (/ (+ (min (length uprefix) (length ustring)) + (max (- (length ustring) (length usuffix)) 0)) + 2)))))) + (list ustring table uqpos (lambda (unquoted-result op) (pcase op (1 ;;try @@ -853,6 +877,7 @@ completing buffer and file names, respectively." (setq string (pop new)) (setq table (pop new)) (setq point (pop new)) + (cl-assert (<= point (length string))) (pop new)))) (result (completion--some (lambda (style) From 879e36286d46283ac4b3e794c502bfac4c33016d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Dj=C3=A4rv?= Date: Mon, 5 May 2014 19:37:43 +0200 Subject: [PATCH 02/24] * nsselect.m (Fx_selection_exists_p): Just return Qnil if window system not initialized. Fixes: debbugs:17398 --- src/ChangeLog | 5 +++++ src/nsselect.m | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ChangeLog b/src/ChangeLog index 0f6aaf93598..9839b6a2146 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2014-05-05 Jan Djärv + + * nsselect.m (Fx_selection_exists_p): Just return Qnil if window system + not initialized (Bug#17398). + 2014-05-04 Paul Eggert Revert recent libpng changes (Bug#17339). diff --git a/src/nsselect.m b/src/nsselect.m index f4713cb5e10..038849c0aed 100644 --- a/src/nsselect.m +++ b/src/nsselect.m @@ -429,7 +429,9 @@ On Nextstep, TERMINAL is unused. */) id pb; NSArray *types; - check_window_system (NULL); + if (!window_system_available (NULL)) + return Qnil; + CHECK_SYMBOL (selection); if (EQ (selection, Qnil)) selection = QPRIMARY; if (EQ (selection, Qt)) selection = QSECONDARY; From e6025d7240197bfd47cf649c5976533da6869a6e Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 5 May 2014 15:04:40 -0400 Subject: [PATCH 03/24] * lisp/electric.el (electric-indent-functions-without-reindent): Add yaml. --- lisp/ChangeLog | 2 ++ lisp/electric.el | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index bef5f1ba71f..9b21fd8cd66 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,7 @@ 2014-05-05 Stefan Monnier + * electric.el (electric-indent-functions-without-reindent): Add yaml. + * minibuffer.el (completion-table-with-quoting) : Make sure the new point we return is within the new string (bug#17239). diff --git a/lisp/electric.el b/lisp/electric.el index 52b0595f7d9..e8ceaa6406c 100644 --- a/lisp/electric.el +++ b/lisp/electric.el @@ -221,7 +221,8 @@ Python does not lend itself to fully automatic indentation.") (defvar electric-indent-functions-without-reindent '(indent-relative indent-to-left-margin indent-relative-maybe py-indent-line coffee-indent-line org-indent-line yaml-indent-line - haskell-indentation-indent-line haskell-indent-cycle haskell-simple-indent) + haskell-indentation-indent-line haskell-indent-cycle haskell-simple-indent + yaml-indent-line) "List of indent functions that can't reindent. If `line-indent-function' is one of those, then `electric-indent-mode' will not try to reindent lines. It is normally better to make the major From 6da8d069757fd26ee537704a9f0dea24dc5e00b8 Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Mon, 5 May 2014 17:33:07 -0400 Subject: [PATCH 04/24] * lisp/help-fns.el (describe-function-1): Test for an autoload before a macro since `macrop' works on autoloads. * test/automated/help-fns.el: New file. Fixes: debbugs:17410 --- lisp/ChangeLog | 5 +++++ lisp/help-fns.el | 13 ++++++------- test/ChangeLog | 4 ++++ test/automated/help-fns.el | 37 +++++++++++++++++++++++++++++++++++++ 4 files changed, 52 insertions(+), 7 deletions(-) create mode 100644 test/automated/help-fns.el diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9b21fd8cd66..3bbacb85e97 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2014-05-05 Glenn Morris + + * help-fns.el (describe-function-1): Test for an autoload before a + macro, since `macrop' works on autoloads. (Bug#17410) + 2014-05-05 Stefan Monnier * electric.el (electric-indent-functions-without-reindent): Add yaml. diff --git a/lisp/help-fns.el b/lisp/help-fns.el index a186254123d..5b0739ed9ae 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el @@ -1,7 +1,6 @@ ;;; help-fns.el --- Complex help functions -*- lexical-binding: t -*- -;; Copyright (C) 1985-1986, 1993-1994, 1998-2014 Free Software -;; Foundation, Inc. +;; Copyright (C) 1985-1986, 1993-1994, 1998-2014 Free Software Foundation, Inc. ;; Maintainer: emacs-devel@gnu.org ;; Keywords: help, internal @@ -479,6 +478,11 @@ FILE is the file where FUNCTION was probably defined." ;; aliases before functions. (aliased (format "an alias for `%s'" real-def)) + ((autoloadp def) + (format "%s autoloaded %s" + (if (commandp def) "an interactive" "an") + (if (eq (nth 4 def) 'keymap) "keymap" + (if (nth 4 def) "Lisp macro" "Lisp function")))) ((or (eq (car-safe def) 'macro) ;; For advised macros, def is a lambda ;; expression or a byte-code-function-p, so we @@ -491,11 +495,6 @@ FILE is the file where FUNCTION was probably defined." (concat beg "Lisp function")) ((eq (car-safe def) 'closure) (concat beg "Lisp closure")) - ((autoloadp def) - (format "%s autoloaded %s" - (if (commandp def) "an interactive" "an") - (if (eq (nth 4 def) 'keymap) "keymap" - (if (nth 4 def) "Lisp macro" "Lisp function")))) ((keymapp def) (let ((is-full nil) (elts (cdr-safe def))) diff --git a/test/ChangeLog b/test/ChangeLog index 7d4e9d5e687..a02b8e80395 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,7 @@ +2014-05-05 Glenn Morris + + * automated/help-fns.el: New file. + 2014-04-25 Michael Albinus * automated/tramp-tests.el (top): diff --git a/test/automated/help-fns.el b/test/automated/help-fns.el new file mode 100644 index 00000000000..153de7f9e30 --- /dev/null +++ b/test/automated/help-fns.el @@ -0,0 +1,37 @@ +;;; help-fns.el --- tests for help-fns.el + +;; Copyright (C) 2014 Free Software Foundation, Inc. + +;; Maintainer: emacs-devel@gnu.org + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Commentary: + +;;; Code: + +(require 'ert) + +(autoload 'help-fns-test--macro "help-fns" nil nil t) + +(ert-deftest help-fns-test-bug17410 () + "Test for http://debbugs.gnu.org/17410 ." + (describe-function 'help-fns-test--macro) + (with-current-buffer "*Help*" + (goto-char (point-min)) + (should (search-forward "autoloaded Lisp macro" (line-end-position))))) + +;;; help-fns.el ends here From 4dd3c4d53af81b017363cb778ac6fd5abea2d132 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Tue, 6 May 2014 03:18:18 +0400 Subject: [PATCH 05/24] * lisp/progmodes/ruby-mode.el (ruby-syntax-propertize-function): Backtrack one char if the global/char-literal var matcher hits inside a string. The next char could be the beginning of an expression expansion. * test/automated/ruby-mode-tests.el (ruby-interpolation-after-dollar-sign): New test. --- lisp/ChangeLog | 7 +++++++ lisp/progmodes/ruby-mode.el | 7 ++++--- test/ChangeLog | 5 +++++ test/automated/ruby-mode-tests.el | 4 ++++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 3bbacb85e97..7c838a61fe5 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2014-05-05 Dmitry Gutov + + * progmodes/ruby-mode.el (ruby-syntax-propertize-function): + Backtrack one char if the global/char-literal var matcher hits + inside a string. The next char could be the beginning of an + expression expansion. + 2014-05-05 Glenn Morris * help-fns.el (describe-function-1): Test for an autoload before a diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index 912736707ef..74edf7a680f 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el @@ -1804,9 +1804,10 @@ It will be properly highlighted even when the call omits parens.") ;; $' $" $` .... are variables. ;; ?' ?" ?` are character literals (one-char strings in 1.9+). ("\\([?$]\\)[#\"'`]" - (1 (unless (save-excursion - ;; Not within a string. - (nth 3 (syntax-ppss (match-beginning 0)))) + (1 (if (save-excursion + (nth 3 (syntax-ppss (match-beginning 0)))) + ;; Within a string, skip. + (goto-char (match-end 1)) (string-to-syntax "\\")))) ;; Part of symbol when at the end of a method name. ("[!?]" diff --git a/test/ChangeLog b/test/ChangeLog index a02b8e80395..0a3e89e7385 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,8 @@ +2014-05-05 Dmitry Gutov + + * automated/ruby-mode-tests.el + (ruby-interpolation-after-dollar-sign): New test. + 2014-05-05 Glenn Morris * automated/help-fns.el: New file. diff --git a/test/automated/ruby-mode-tests.el b/test/automated/ruby-mode-tests.el index f6fddb5ef4c..0ad5650cd77 100644 --- a/test/automated/ruby-mode-tests.el +++ b/test/automated/ruby-mode-tests.el @@ -452,6 +452,10 @@ VALUES-PLIST is a list with alternating index and value elements." (ruby-assert-face "%w{foo #@bar}" 8 font-lock-string-face) (ruby-assert-face "%s{foo #@bar}" 8 font-lock-string-face)) +(ert-deftest ruby-interpolation-after-dollar-sign () + (ruby-assert-face "\"$#{balance}\"" 2 'font-lock-string-face) + (ruby-assert-face "\"$#{balance}\"" 3 'font-lock-variable-name-face)) + (ert-deftest ruby-no-unknown-percent-literals () ;; No folding of case. (ruby-assert-face "%S{foo}" 4 nil) From c22f24f6ef76b6bc62bbaafb0b1423bff3d867d4 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 5 May 2014 19:50:20 -0400 Subject: [PATCH 06/24] * lisp/xt-mouse.el (xterm-mouse--read-event-sequence-1000): Always store button numbers in the same way in xterm-mouse-last; Don't burp is xterm-mouse-last is not set as expected. Never return negative indices. Fixes: debbugs:17378 --- lisp/ChangeLog | 7 +++++++ lisp/xt-mouse.el | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7c838a61fe5..043a0c240b1 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2014-05-05 Stefan Monnier + + * xt-mouse.el (xterm-mouse--read-event-sequence-1000): (bug#17378) + Always store button numbers in the same way in xterm-mouse-last; + Don't burp is xterm-mouse-last is not set as expected. + Never return negative indices. + 2014-05-05 Dmitry Gutov * progmodes/ruby-mode.el (ruby-syntax-propertize-function): diff --git a/lisp/xt-mouse.el b/lisp/xt-mouse.el index 26a07b46840..87e65f7e117 100644 --- a/lisp/xt-mouse.el +++ b/lisp/xt-mouse.el @@ -161,10 +161,10 @@ http://invisible-island.net/xterm/ctlseqs/ctlseqs.html)." (cond ((>= code 64) (format "mouse-%d" (- code 60))) ((memq code '(8 9 10)) - (setq xterm-mouse-last code) + (setq xterm-mouse-last (- code 8)) (format "M-down-mouse-%d" (- code 7))) ((= code 11) - (format "M-mouse-%d" (- xterm-mouse-last 7))) + (format "M-mouse-%d" (+ 1 (or xterm-mouse-last 0)))) ((= code 3) ;; For buttons > 5 xterm only reports a ;; button-release event. Avoid error by mapping @@ -174,8 +174,8 @@ http://invisible-island.net/xterm/ctlseqs/ctlseqs.html)." (setq xterm-mouse-last code) (format "down-mouse-%d" (+ 1 code)))))) ;; x and y coordinates - (- (read-event) 33) - (- (read-event) 33))) + (max 0 (- (read-event) 33)) + (max 0 (- (read-event) 33)))) ;; XTerm's 1006-mode terminal mouse click reporting has the form ;;