1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-17 03:10:58 -08:00

Merge from origin/emacs-25

620951f Fix previous fix of enlarge-/shrink-window
2e78353 * lisp/isearch.el (isearch-define-mode-toggle): Fix toggling logic
66d2717 Complete temperature units in calc-convert-temperature
dbb02bf Make sure to use case-sensitive search
8b01e69 Prevent infinite loop on not-well-formed xml. (Bug#16344)
100346a Add the missing test case for the previous patch
5aba61e Use the correct dabbrev expansion
This commit is contained in:
John Wiegley 2016-03-11 13:32:13 -08:00
commit a934bf445f
8 changed files with 108 additions and 27 deletions

View file

@ -565,7 +565,12 @@ If COMP or STD is non-nil, put that in the units table instead."
(defun calc-convert-temperature (&optional old-units new-units) (defun calc-convert-temperature (&optional old-units new-units)
(interactive) (interactive)
(calc-slow-wrapper (calc-slow-wrapper
(let ((expr (calc-top-n 1)) (let ((tempunits (delq nil
(mapcar
(lambda (x)
(if (nth 3 x) (car x)))
math-standard-units)))
(expr (calc-top-n 1))
(uold nil) (uold nil)
(uoldname nil) (uoldname nil)
unew unew
@ -580,15 +585,16 @@ If COMP or STD is non-nil, put that in the units table instead."
(car units))))) (car units)))))
(error "Not a pure temperature expression")) (error "Not a pure temperature expression"))
(math-read-expr (math-read-expr
(setq uoldname (read-string (setq uoldname (completing-read
"Old temperature units: "))))))) "Old temperature units: "
tempunits)))))))
(when (eq (car-safe uold) 'error) (when (eq (car-safe uold) 'error)
(error "Bad format in units expression: %s" (nth 2 uold))) (error "Bad format in units expression: %s" (nth 2 uold)))
(or (math-units-in-expr-p expr nil) (or (math-units-in-expr-p expr nil)
(setq expr (math-mul expr uold))) (setq expr (math-mul expr uold)))
(setq defunits (math-get-default-units expr)) (setq defunits (math-get-default-units expr))
(setq unew (or new-units (setq unew (or new-units
(read-string (completing-read
(concat (concat
(if uoldname (if uoldname
(concat "Old temperature units: " (concat "Old temperature units: "
@ -599,7 +605,8 @@ If COMP or STD is non-nil, put that in the units table instead."
(concat " (default " (concat " (default "
defunits defunits
"): ") "): ")
": "))))) ": "))
tempunits)))
(setq unew (math-read-expr (if (string= unew "") defunits unew))) (setq unew (math-read-expr (if (string= unew "") defunits unew)))
(when (eq (car-safe unew) 'error) (when (eq (car-safe unew) 'error)
(error "Bad format in units expression: %s" (nth 2 unew))) (error "Bad format in units expression: %s" (nth 2 unew)))

View file

@ -546,8 +546,8 @@ See also `dabbrev-abbrev-char-regexp' and \\[dabbrev-completion]."
(copy-marker dabbrev--last-expansion-location))) (copy-marker dabbrev--last-expansion-location)))
;; Success: stick it in and return. ;; Success: stick it in and return.
(setq buffer-undo-list (cons orig-point buffer-undo-list)) (setq buffer-undo-list (cons orig-point buffer-undo-list))
(dabbrev--substitute-expansion old abbrev expansion (setq expansion (dabbrev--substitute-expansion old abbrev expansion
record-case-pattern) record-case-pattern))
;; Save state for re-expand. ;; Save state for re-expand.
(setq dabbrev--last-expansion expansion) (setq dabbrev--last-expansion expansion)
@ -902,7 +902,9 @@ to record whether we upcased the expansion, downcased it, or did neither."
;; and (2) the replacement itself is all lower case. ;; and (2) the replacement itself is all lower case.
(dabbrev--safe-replace-match expansion (dabbrev--safe-replace-match expansion
(not use-case-replace) (not use-case-replace)
t))) t))
;; Return the expansion actually used.
expansion)
;;;---------------------------------------------------------------- ;;;----------------------------------------------------------------

View file

@ -1528,7 +1528,9 @@ The command then executes BODY and updates the isearch prompt."
(if docstring (concat "\n" docstring) "")) (if docstring (concat "\n" docstring) ""))
(interactive) (interactive)
,@(when function ,@(when function
`((setq isearch-regexp-function #',function) `((setq isearch-regexp-function
(unless (eq isearch-regexp-function #',function)
#',function))
(setq isearch-regexp nil))) (setq isearch-regexp nil)))
,@body ,@body
(setq isearch-success t isearch-adjusted t) (setq isearch-success t isearch-adjusted t)

View file

@ -861,6 +861,7 @@ tools are used, and when."
(let* ((ede-minor-mode nil) (let* ((ede-minor-mode nil)
(default-directory dir) (default-directory dir)
(semantic-symref-tool 'detect) (semantic-symref-tool 'detect)
(case-fold-search nil)
(res (semantic-symref-find-references-by-name symbol 'subdirs)) (res (semantic-symref-find-references-by-name symbol 'subdirs))
(hits (and res (oref res hit-lines))) (hits (and res (oref res hit-lines)))
(orig-buffers (buffer-list))) (orig-buffers (buffer-list)))

View file

@ -2473,8 +2473,6 @@ windows."
(when (window-right window) (when (window-right window)
(window--resize-reset-1 (window-right window) horizontal))) (window--resize-reset-1 (window-right window) horizontal)))
;; The following routine is used to manually resize the minibuffer
;; window and is currently used, for example, by ispell.el.
(defun window--resize-mini-window (window delta) (defun window--resize-mini-window (window delta)
"Resize minibuffer window WINDOW by DELTA pixels. "Resize minibuffer window WINDOW by DELTA pixels.
If WINDOW cannot be resized by DELTA pixels make it as large (or If WINDOW cannot be resized by DELTA pixels make it as large (or
@ -3338,34 +3336,42 @@ negative, shrink selected window by -DELTA lines or columns."
(cond (cond
((zerop delta)) ((zerop delta))
((window-size-fixed-p nil horizontal) ((window-size-fixed-p nil horizontal)
(error "Selected window has fixed size")) (user-error "Selected window has fixed size"))
((window-minibuffer-p) ((window-minibuffer-p)
(if horizontal (if horizontal
(error "Cannot resize minibuffer window horizontally") (user-error "Cannot resize minibuffer window horizontally")
(window--resize-mini-window (selected-window) delta))) (window--resize-mini-window
(selected-window) (* delta (frame-char-height)))))
((and (not horizontal) ((and (not horizontal)
(window-full-height-p) (window-full-height-p)
(eq (window-frame minibuffer-window) (selected-frame)) (eq (window-frame minibuffer-window) (selected-frame))
(not resize-mini-windows)) (not resize-mini-windows))
;; If the selected window is full height and `resize-mini-windows' ;; If the selected window is full height and `resize-mini-windows'
;; is nil, resize the minibuffer window. ;; is nil, resize the minibuffer window.
(window--resize-mini-window minibuffer-window (- delta))) (window--resize-mini-window
minibuffer-window (* (- delta) (frame-char-height))))
((window--resizable-p nil delta horizontal) ((window--resizable-p nil delta horizontal)
(window-resize nil delta horizontal)) (window-resize nil delta horizontal))
((window--resizable-p nil delta horizontal 'preserved) ((window--resizable-p nil delta horizontal 'preserved)
(window-resize nil delta horizontal 'preserved)) (window-resize nil delta horizontal 'preserved))
((eq this-command 'enlarge-window) ((eq this-command
(if horizontal 'enlarge-window-horizontally 'enlarge-window))
;; For backward compatibility don't signal an error unless this
;; command is `enlarge-window(-horizontally)'.
(user-error "Cannot enlarge selected window")) (user-error "Cannot enlarge selected window"))
(t (t
(error "Cannot enlarge selected window"))))) (window-resize
nil (if (> delta 0)
(window-max-delta nil horizontal)
(- (window-min-delta nil horizontal)))
horizontal)))))
(defun shrink-window (delta &optional horizontal) (defun shrink-window (delta &optional horizontal)
"Make the selected window DELTA lines smaller. "Make the selected window DELTA lines smaller.
Interactively, if no argument is given, make the selected window Interactively, if no argument is given, make the selected window
one line smaller. If optional argument HORIZONTAL is non-nil, one line smaller. If optional argument HORIZONTAL is non-nil,
make selected window narrower by DELTA columns. If DELTA is make selected window narrower by DELTA columns. If DELTA is
negative, enlarge selected window by -DELTA lines or columns. negative, enlarge selected window by -DELTA lines or columns."
Also see the `window-min-height' variable."
(interactive "p") (interactive "p")
(let ((minibuffer-window (minibuffer-window))) (let ((minibuffer-window (minibuffer-window)))
(when (window-preserved-size nil horizontal) (when (window-preserved-size nil horizontal)
@ -3373,26 +3379,35 @@ Also see the `window-min-height' variable."
(cond (cond
((zerop delta)) ((zerop delta))
((window-size-fixed-p nil horizontal) ((window-size-fixed-p nil horizontal)
(error "Selected window has fixed size")) (user-error "Selected window has fixed size"))
((window-minibuffer-p) ((window-minibuffer-p)
(if horizontal (if horizontal
(error "Cannot resize minibuffer window horizontally") (user-error "Cannot resize minibuffer window horizontally")
(window--resize-mini-window (selected-window) (- delta)))) (window--resize-mini-window
(selected-window) (* (- delta) (frame-char-height)))))
((and (not horizontal) ((and (not horizontal)
(window-full-height-p) (window-full-height-p)
(eq (window-frame minibuffer-window) (selected-frame)) (eq (window-frame minibuffer-window) (selected-frame))
(not resize-mini-windows)) (not resize-mini-windows))
;; If the selected window is full height and `resize-mini-windows' ;; If the selected window is full height and `resize-mini-windows'
;; is nil, resize the minibuffer window. ;; is nil, resize the minibuffer window.
(window--resize-mini-window minibuffer-window delta)) (window--resize-mini-window
minibuffer-window (* delta (frame-char-height))))
((window--resizable-p nil (- delta) horizontal) ((window--resizable-p nil (- delta) horizontal)
(window-resize nil (- delta) horizontal)) (window-resize nil (- delta) horizontal))
((window--resizable-p nil (- delta) horizontal 'preserved) ((window--resizable-p nil (- delta) horizontal 'preserved)
(window-resize nil (- delta) horizontal 'preserved)) (window-resize nil (- delta) horizontal 'preserved))
((eq this-command 'shrink-window) ((eq this-command
(if horizontal 'shrink-window-horizontally 'shrink-window))
;; For backward compatibility don't signal an error unless this
;; command is `shrink-window(-horizontally)'.
(user-error "Cannot shrink selected window")) (user-error "Cannot shrink selected window"))
(t (t
(error "Cannot shrink selected window"))))) (window-resize
nil (if (> delta 0)
(- (window-min-delta nil horizontal))
(window-max-delta nil horizontal))
horizontal)))))
(defun maximize-window (&optional window) (defun maximize-window (&optional window)
"Maximize WINDOW. "Maximize WINDOW.

View file

@ -579,7 +579,14 @@ Return one of:
(error "XML: (Well-Formed) Invalid character")) (error "XML: (Well-Formed) Invalid character"))
;; However, if we're parsing incrementally, then we need to deal ;; However, if we're parsing incrementally, then we need to deal
;; with stray CDATA. ;; with stray CDATA.
(xml-parse-string))))) (let ((s (xml-parse-string)))
(when (string-empty-p s)
;; We haven't consumed any input! We must throw an error in
;; order to prevent looping forever.
(error "XML: (Not Well-Formed) Could not parse: %s"
(buffer-substring-no-properties
(point) (min (+ (point) 10) (point-max)))))
s)))))
(defun xml-parse-string () (defun xml-parse-string ()
"Parse character data at point, and return it as a string. "Parse character data at point, and return it as a string.

View file

@ -0,0 +1,42 @@
;;; dabbrev-tests.el --- Test suite for dabbrev.
;; Copyright (C) 2016 Free Software Foundation, Inc.
;; Author: Alan Third <alan@idiocy.org>
;; Keywords: dabbrev
;; 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 <http://www.gnu.org/licenses/>.
;;; Commentary:
;;; Code:
(require 'ert)
(require 'dabbrev)
(ert-deftest dabbrev-expand-test ()
"Test for bug#1948.
When DABBREV-ELIMINATE-NEWLINES is non-nil (the default),
repeated calls to DABBREV-EXPAND can result in the source of
first expansion being replaced rather than the destination."
(with-temp-buffer
(insert "ab x\na\nab y")
(goto-char 8)
(save-window-excursion
(set-window-buffer nil (current-buffer))
;; M-/ SPC M-/ M-/
(execute-kbd-macro "\257 \257\257"))
(should (string= (buffer-string) "ab x\nab y\nab y"))))

View file

@ -72,7 +72,12 @@
;; Invalid XML names ;; Invalid XML names
"<0foo>abc</0foo>" "<0foo>abc</0foo>"
"<‿foo>abc</‿foo>" "<‿foo>abc</‿foo>"
"<f¿>abc</f¿>") "<f¿>abc</f¿>"
;; Two root tags
"<a/><b></b>"
;; Bug#16344
"<!----><x>< /x>"
"<a>< b/></a>")
"List of XML strings that should signal an error in the parser") "List of XML strings that should signal an error in the parser")
(defvar xml-parse-tests--qnames (defvar xml-parse-tests--qnames