commit cd6067965761ccf31c48a106596b5187e85120e1 (HEAD, refs/remotes/origin/master) Author: Lars Ingebrigtsen Date: Sun Feb 28 17:29:08 2016 +1100 Add a NEWS entry for the read-color change diff --git a/etc/NEWS b/etc/NEWS index 2cb46a1..6fe47d4 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2006,6 +2006,10 @@ coding-system of your choice when invoking functions like `prin1' and ** New possible value for `system-type': `nacl'. This is used by Google's Native Client (NaCl). +--- +** `read-color' will now display the color names using the color itself +as the background color. + ** Miscellaneous name change --- commit 8ed026d6176d02412b6c48d9dfbd9f3a345a86a6 Author: Jan Moringen Date: Sun Feb 28 17:27:23 2016 +1100 Show the face colours when completing in `read-color' * lisp/faces.el (defined-colors-with-face-attributes): New function. (readable-foreground-color, defined-colors-with-face-attributes) (readable-foreground-color): Ditto. (read-color): Use them (bug#5305). diff --git a/lisp/faces.el b/lisp/faces.el index bfb5d4c..b5e9fdc 100644 --- a/lisp/faces.el +++ b/lisp/faces.el @@ -1792,6 +1792,58 @@ If FRAME is nil, that stands for the selected frame." (mapcar 'car (tty-color-alist frame)))) (defalias 'x-defined-colors 'defined-colors) +(defun defined-colors-with-face-attributes (&optional frame) + "Return a list of colors supported for a particular frame. +See `defined-colors' for arguments and return value. In contrast +to `define-colors' the elements of the returned list are color +strings with text properties, that make the color names render +with the color they represent as background color." + (mapcar + (lambda (color-name) + (let ((foreground (readable-foreground-color color-name)) + (color (copy-sequence color-name))) + (propertize color 'face (list :foreground foreground + :background color)))) + (defined-colors frame))) + +(defun readable-foreground-color (color) + "Return a readable foreground color for background COLOR." + (let* ((rgb (color-values color)) + (max (apply #'max rgb)) + (black (car (color-values "black"))) + (white (car (color-values "white")))) + ;; Select black or white depending on which one is less similar to + ;; the brightest component. + (if (> (abs (- max black)) (abs (- max white))) + "black" + "white"))) + +(defun defined-colors-with-face-attributes (&optional frame) + "Return a list of colors supported for a particular frame. +See `defined-colors' for arguments and return value. In contrast +to `define-colors' the elements of the returned list are color +strings with text properties, that make the color names render +with the color they represent as background color." + (mapcar + (lambda (color-name) + (let ((foreground (readable-foreground-color color-name)) + (color (copy-sequence color-name))) + (propertize color 'face (list :foreground foreground + :background color)))) + (defined-colors frame))) + +(defun readable-foreground-color (color) + "Return a readable foreground color for background COLOR." + (let* ((rgb (color-values color)) + (max (apply #'max rgb)) + (black (car (color-values "black"))) + (white (car (color-values "white")))) + ;; Select black or white depending on which one is less similar to + ;; the brightest component. + (if (> (abs (- max black)) (abs (- max white))) + "black" + "white"))) + (declare-function xw-color-defined-p "xfns.c" (color &optional frame)) (defun color-defined-p (color &optional frame) @@ -1896,22 +1948,24 @@ resulting color name in the echo area." (colors (or facemenu-color-alist (append '("foreground at point" "background at point") (if allow-empty-name '("")) - (defined-colors)))) + (if (display-color-p) + (defined-colors-with-face-attributes) + (defined-colors))))) (color (completing-read (or prompt "Color (name or #RGB triplet): ") ;; Completing function for reading colors, accepting ;; both color names and RGB triplets. (lambda (string pred flag) (cond - ((null flag) ; Try completion. + ((null flag) ; Try completion. (or (try-completion string colors pred) (if (color-defined-p string) string))) - ((eq flag t) ; List all completions. + ((eq flag t) ; List all completions. (or (all-completions string colors pred) (if (color-defined-p string) (list string)))) - ((eq flag 'lambda) ; Test completion. + ((eq flag 'lambda) ; Test completion. (or (member string colors) (color-defined-p string))))) nil t))) commit 3ac844be4ec66728f33b3651f7cc87c4601dcc49 Author: Lars Ingebrigtsen Date: Sun Feb 28 15:34:33 2016 +1030 Clean up the code in parse-time-string-chars * lisp/calendar/parse-time.el (parse-time-string-chars): Clean up the code a bit. diff --git a/lisp/calendar/parse-time.el b/lisp/calendar/parse-time.el index fd26e77..6ba26a4 100644 --- a/lisp/calendar/parse-time.el +++ b/lisp/calendar/parse-time.el @@ -41,13 +41,11 @@ (defvar parse-time-val) (defsubst parse-time-string-chars (char) - (save-match-data - (let (str) - (cond ((eq char ?+) 1) - ((eq char ?-) -1) - ((eq char ?:) ?d) - ((string-match "[[:lower:]]" (setq str (string char))) ?a) - ((string-match "[[:digit:]]" str) ?0))))) + (cond ((<= ?a char ?z) ?a) + ((<= ?0 char ?9) ?0) + ((eq char ?+) 1) + ((eq char ?-) -1) + ((eq char ?:) ?d))) (defun parse-time-tokenize (string) "Tokenize STRING into substrings." commit 12d10d2599d5ce56880aad40529614a715454fe8 Author: Lars Ingebrigtsen Date: Sun Feb 28 15:30:30 2016 +1030 Add some tests for parse-time.el * test/lisp/calendar/parse-time-tests.el: New file. diff --git a/test/lisp/calendar/parse-time-tests.el b/test/lisp/calendar/parse-time-tests.el new file mode 100644 index 0000000..a227f5c --- /dev/null +++ b/test/lisp/calendar/parse-time-tests.el @@ -0,0 +1,52 @@ +;; parse-time-tests.el --- Test suite for parse-time.el + +;; Copyright (C) 2016 Free Software Foundation, Inc. + +;; Author: Lars Ingebrigtsen + +;; 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) +(require 'parse-time) + +(ert-deftest parse-time-tests () + (should (equal (parse-time-string "Mon, 22 Feb 2016 19:35:42 +0100") + '(42 35 19 22 2 2016 1 nil 3600))) + (should (equal (parse-time-string "22 Feb 2016 19:35:42 +0100") + '(42 35 19 22 2 2016 nil nil 3600))) + (should (equal (parse-time-string "22 Feb 2016 +0100") + '(nil nil nil 22 2 2016 nil nil 3600))) + (should (equal (parse-time-string "Mon, 22 Feb 16 19:35:42 +0100") + '(42 35 19 22 2 2016 1 nil 3600))) + (should (equal (parse-time-string "Mon, 22 February 2016 19:35:42 +0100") + '(42 35 19 22 2 2016 1 nil 3600))) + (should (equal (parse-time-string "Mon, 22 feb 2016 19:35:42 +0100") + '(42 35 19 22 2 2016 1 nil 3600))) + (should (equal (parse-time-string "Monday, 22 february 2016 19:35:42 +0100") + '(42 35 19 22 2 2016 1 nil 3600))) + (should (equal (parse-time-string "Monday, 22 february 2016 19:35:42 PDT") + '(42 35 19 22 2 2016 1 t -25200))) + + (should (equal (parse-iso8601-time-string "2016-02-28T15:28:09+1030") + '(22226 32353)))) + +(provide 'parse-time-tests) + +;;; parse-time-tests.el ends here commit e8146d49b04232348edb7b4fff339c89de4e8a76 Author: Dima Kogan Date: Sun Feb 28 15:18:45 2016 +1030 Strip out some leading whitespace when looking at logs * lisp/vc/vc-git.el (vc-git-expanded-log-entry): When looking at expanded git logs with `vc-print-root-log' (C-x v L, then by default), Emacs was stripping out all leading whitespace from git logs. I now strip exactly 2 leading spaces, which retains the indentation in the logs (bug#18110). diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 1c43e3e..8498cc8 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -970,7 +970,9 @@ or BRANCH^ (where \"^\" can be repeated)." (goto-char (point-min)) (unless (eobp) ;; Indent the expanded log entry. - (indent-region (point-min) (point-max) 2) + (while (re-search-forward "^ " nil t) + (replace-match "") + (forward-line)) (buffer-string)))) (defun vc-git-region-history (file buffer lfrom lto) commit f4b057c67f74e0a7a2c4ff03c19c8236989465d0 Author: Dima Kogan Date: Sun Feb 28 15:15:18 2016 +1030 Use a separate history variable for align-regexp * lisp/align.el (align-regexp-history): New variable (bug#16891). (align-regexp): Use it. diff --git a/etc/NEWS b/etc/NEWS index c12f4d1..2cb46a1 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -31,6 +31,11 @@ otherwise leave it unmarked. * Changes in Emacs 25.2 +--- +** `align-regexp' has a separate history for its interactive argument +`align-regexp' no longer shares its history with all other +history-less functions that use `read-string' + +++ ** The networking code has been reworked so that it's more asynchronous than it was (when specifying :nowait t in diff --git a/lisp/align.el b/lisp/align.el index 7e439f3..c3389dc 100644 --- a/lisp/align.el +++ b/lisp/align.el @@ -802,6 +802,9 @@ See the variable `align-exclude-rules-list' for more details.") (defvar align-highlight-overlays nil "The current overlays highlighting the text matched by a rule.") +(defvar align-regexp-history nil + "Input history for the full user-entered regex in `align-regexp'") + ;; Sample extension rule set, for vhdl-mode. This should properly be ;; in vhdl-mode.el itself. @@ -946,7 +949,7 @@ construct a rule to pass to `align-region', which does the real work." (list (region-beginning) (region-end)) (if current-prefix-arg (list (read-string "Complex align using regexp: " - "\\(\\s-*\\)") + "\\(\\s-*\\)" 'align-regexp-history) (string-to-number (read-string "Parenthesis group to modify (justify if negative): " "1")) commit e00974a7d1981d716d38ecf45b689dd30a381c65 Author: Phil Sung Date: Sun Feb 28 15:07:02 2016 +1030 Create subdirectories automatically in wdired * lisp/wdired.el (wdired-create-parent-directories): New variable (bug#6817). (wdired-create-parentdirs): New function. (wdired-do-renames): Use it. * doc/emacs/dired.texi (Wdired): Mention `wdired-create-parent-directories' diff --git a/doc/emacs/dired.texi b/doc/emacs/dired.texi index 13242d1..60542df 100644 --- a/doc/emacs/dired.texi +++ b/doc/emacs/dired.texi @@ -1294,6 +1294,10 @@ relative). To mark a file for deletion, delete the entire file name. To change the target of a symbolic link, edit the link target name which appears next to the link name. + If you edit the file names to create a new subdirectory, Wdired will +automatically create these new directories. To inhibit this behavior, +set @code{wdired-create-parent-directories} to @code{nil}. + The rest of the text in the buffer, such as the file sizes and modification dates, is marked read-only, so you can't edit it. However, if you set @code{wdired-allow-to-change-permissions} to diff --git a/etc/NEWS b/etc/NEWS index 29b013a..c12f4d1 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1426,6 +1426,12 @@ compression command is determined from the new `dired-compress-files-alist' variable. +++ +*** In wdired, when editing files to contain slash characters, +the resulting directories are automatically created. Whether +to do this or not is controlled by the +`wdired-create-parent-directories' variable. + ++++ *** `W' is now bound to `browse-url-of-dired-file', and is useful for viewing HTML files and the like. diff --git a/lisp/wdired.el b/lisp/wdired.el index 9f25879..d943dad 100644 --- a/lisp/wdired.el +++ b/lisp/wdired.el @@ -152,6 +152,16 @@ renamed by `dired-do-rename' and `dired-do-rename-regexp'." :version "24.3" :group 'wdired) +(defcustom wdired-create-parent-directories t + "If non-nil, create parent directories of destination files. +If non-nil, when you rename a file to a destination path within a +nonexistent directory, wdired will create any parent directories +necessary. When nil, attempts to rename a file into a +nonexistent directory will fail." + :version "25.2" + :type 'boolean + :group 'wdired) + (defvar wdired-mode-map (let ((map (make-sparse-keymap))) (define-key map "\C-x\C-s" 'wdired-finish-edit) @@ -490,6 +500,8 @@ non-nil means return old filename." (require 'dired-aux) (condition-case err (let ((dired-backup-overwrite nil)) + (and wdired-create-parent-directories + (wdired-create-parentdirs file-new)) (dired-rename-file file-ori file-new overwrite)) (error @@ -499,6 +511,11 @@ non-nil means return old filename." err))))))))) errors)) +(defun wdired-create-parentdirs (file-new) + "Create parent directories for FILE-NEW if they don't exist." + (and (not (file-exists-p (file-name-directory file-new))) + (message "Creating directory for file %s" file-new) + (make-directory (file-name-directory file-new) t))) (defun wdired-exit () "Exit wdired and return to dired mode. commit d5f270f2965f3c52963e2bf0057756e350d771d1 Author: Lars Ingebrigtsen Date: Sun Feb 28 14:03:50 2016 +1030 Return the correct error values from gnutls.c * src/gnutls.c (emacs_gnutls_read): Set errno to the value expected by process.c. (gnutls_try_handshake): Set gnutls_p to true earlier to avoid possible race condition with the process.c socket polling functions. diff --git a/src/gnutls.c b/src/gnutls.c index d1b34c5..988c010 100644 --- a/src/gnutls.c +++ b/src/gnutls.c @@ -403,6 +403,9 @@ gnutls_try_handshake (struct Lisp_Process *proc) gnutls_session_t state = proc->gnutls_state; int ret; + if (proc->is_non_blocking_client) + proc->gnutls_p = true; + do { ret = gnutls_handshake (state); @@ -414,9 +417,6 @@ gnutls_try_handshake (struct Lisp_Process *proc) proc->gnutls_initstage = GNUTLS_STAGE_HANDSHAKE_TRIED; - if (proc->is_non_blocking_client) - proc->gnutls_p = true; - if (ret == GNUTLS_E_SUCCESS) { /* Here we're finally done. */ @@ -541,7 +541,10 @@ emacs_gnutls_read (struct Lisp_Process *proc, char *buf, ptrdiff_t nbyte) gnutls_session_t state = proc->gnutls_state; if (proc->gnutls_initstage != GNUTLS_STAGE_READY) - return -1; + { + errno = EAGAIN; + return -1; + } rtnval = gnutls_record_recv (state, buf, nbyte); if (rtnval >= 0) commit b829c9e15b244e12a98e5dc75c8009d55b60bfab Author: Aaron S. Hawley Date: Sat Feb 27 19:01:24 2016 -0800 Don't make assumptions about mkdir. (Bug#22822) * test/Makefile.in (MKDIR_P): New, set by configure. (%.log): Use MKDIR_P. diff --git a/test/Makefile.in b/test/Makefile.in index b5954df..a5755fd 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -33,6 +33,8 @@ SHELL = @SHELL@ srcdir = @srcdir@ VPATH = $(srcdir) +MKDIR_P = @MKDIR_P@ + SEPCHAR = @SEPCHAR@ # We never change directory before running Emacs, so a relative file @@ -110,7 +112,7 @@ endif fi; \ echo Testing $$loadfile; \ stat=OK ; \ - mkdir --parents $(dir $@) ; \ + ${MKDIR_P} $(dir $@) ; \ $(emacs) -l ert -l $$loadfile \ --eval "(ert-run-tests-batch-and-exit ${SELECTOR_ACTUAL})" ${WRITE_LOG} commit c483d0530a7bc79fab377327e3228681297b1942 Author: Alexander Kuleshov Date: Sat Feb 27 19:27:31 2016 +0200 Support switching to hexl-mode from image-mode * lisp/image-mode.el (image-toggle-hex-display) (image-mode-to-text): New functions. (image-mode-map, image-minor-mode-map): Bind "C-c C-x" to image-toggle-hex-display. (image-mode-map): New menu item "Show as Hex". (image-mode): Update doc string and echo-area message. (image-toggle-display): Support toggle to hex. (Bug#22453) * doc/emacs/files.texi (File Conveniences): Document 'image-toggle-hex-display'. diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi index ab20d4a..bbb6070 100644 --- a/doc/emacs/files.texi +++ b/doc/emacs/files.texi @@ -1969,6 +1969,9 @@ point. Partial Completion mode offers other features extending major mode, you can type @kbd{C-c C-c} (@code{image-toggle-display}) to toggle between displaying the file as an image in the Emacs buffer, and displaying its underlying text (or raw byte) representation. +Additionally you can type @kbd{C-c C-x} (@code{image-toggle-hex-display}) +to toggle between displaying the file as an image in the Emacs buffer, +and displaying it in hex representation. Displaying the file as an image works only if Emacs is compiled with support for displaying such images. If the displayed image is wider or taller than the frame, the usual point motion keys (@kbd{C-f}, diff --git a/lisp/image-mode.el b/lisp/image-mode.el index e2037b9..3334d6a 100644 --- a/lisp/image-mode.el +++ b/lisp/image-mode.el @@ -24,8 +24,8 @@ ;;; Commentary: ;; Defines a major mode for visiting image files -;; that allows conversion between viewing the text of the file -;; and viewing the file as an image. Viewing the image +;; that allows conversion between viewing the text of the file, +;; hex of the file and viewing the file as an image. Viewing the image ;; works by putting a `display' text-property on the ;; image data, with the image-data still present underneath; if the ;; resulting buffer file is saved to another name it will correctly save @@ -375,6 +375,7 @@ call." (set-keymap-parent map special-mode-map) (set-keymap-parent map image-map) (define-key map "\C-c\C-c" 'image-toggle-display) + (define-key map "\C-c\C-x" 'image-toggle-hex-display) (define-key map (kbd "SPC") 'image-scroll-up) (define-key map (kbd "S-SPC") 'image-scroll-down) (define-key map (kbd "DEL") 'image-scroll-down) @@ -407,6 +408,8 @@ call." '("Image" ["Show as Text" image-toggle-display :active t :help "Show image as text"] + ["Show as Hex" image-toggle-hex-display :active t + :help "Show image as hex"] "--" ["Fit to Window Height" image-transform-fit-to-height :visible (eq image-type 'imagemagick) @@ -481,6 +484,7 @@ call." (defvar image-minor-mode-map (let ((map (make-sparse-keymap))) (define-key map "\C-c\C-c" 'image-toggle-display) + (define-key map "\C-c\C-x" 'image-toggle-hex-display) map) "Mode keymap for `image-minor-mode'.") @@ -491,8 +495,8 @@ call." ;;;###autoload (defun image-mode () "Major mode for image files. -You can use \\\\[image-toggle-display] -to toggle between display as an image and display as text. +You can use \\\\[image-toggle-display] or \\\\[image-toggle-hex-display] +to toggle between display as an image and display as text or hex. Key bindings: \\{image-mode-map}" @@ -531,7 +535,7 @@ Key bindings: (run-mode-hooks 'image-mode-hook) (let ((image (image-get-display-property)) (msg1 (substitute-command-keys - "Type \\[image-toggle-display] to view the image as ")) + "Type \\[image-toggle-display] or \\[image-toggle-hex-display] to view the image as ")) animated) (cond ((null image) @@ -560,7 +564,7 @@ mouse-3: Previous frame" ;;; (substitute-command-keys ;;; "\\[image-toggle-animation] to animate.")))) (t - (message "%s" (concat msg1 "text.")))))) + (message "%s" (concat msg1 "text or hex.")))))) (error (image-mode-as-text) @@ -586,19 +590,10 @@ actual image." (add-hook 'change-major-mode-hook (lambda () (image-minor-mode -1)) nil t))) ;;;###autoload -(defun image-mode-as-text () +(defun image-mode-to-text () "Set a non-image mode as major mode in combination with image minor mode. -A non-image major mode found from `auto-mode-alist' or Fundamental mode -displays an image file as text. `image-minor-mode' provides the key -\\\\[image-toggle-display] to switch back to `image-mode' -to display an image file as the actual image. - -You can use `image-mode-as-text' in `auto-mode-alist' when you want -to display an image file as text initially. - -See commands `image-mode' and `image-minor-mode' for more information -on these modes." - (interactive) +A non-mage major mode found from `auto-mode-alist' or fundamental mode +displays an image file as text." ;; image-mode-as-text = normal-mode + image-minor-mode (let ((previous-image-type image-type)) ; preserve `image-type' (if image-mode-previous-major-mode @@ -626,12 +621,49 @@ on these modes." ;; Enable image minor mode with `C-c C-c'. (image-minor-mode 1) ;; Show the image file as text. - (image-toggle-display-text) - (message "%s" (concat - (substitute-command-keys - "Type \\[image-toggle-display] to view the image as ") - (if (image-get-display-property) - "text" "an image") ".")))) + (image-toggle-display-text))) + +(defun image-mode-as-hex () + "Set a non-image mode as major mode in combination with image minor mode. +A non-mage major mode found from `auto-mode-alist' or fundamental mode +displays an image file as hex. `image-minor-mode' provides the key +\\\\[image-toggle-hex-display] to switch back to `image-mode' +to display an image file as the actual image. + +You can use `image-mode-as-hex' in `auto-mode-alist' when you want to +to display an image file as hex initially. + +See commands `image-mode' and `image-minor-mode' for more information +on these modes." + (interactive) + (image-mode-to-text) + ;; Turn on hexl-mode + (hexl-mode) + (message "%s" (concat + (substitute-command-keys + "Type \\[image-toggle-hex-display] or \\[image-toggle-display] to view the image as ") + (if (image-get-display-property) + "hex" "an image or text") "."))) + +(defun image-mode-as-text () + "Set a non-image mode as major mode in combination with image minor mode. +A non-image major mode found from `auto-mode-alist' or Fundamental mode +displays an image file as text. `image-minor-mode' provides the key +\\\\[image-toggle-display] to switch back to `image-mode' +to display an image file as the actual image. + +You can use `image-mode-as-text' in `auto-mode-alist' when you want +to display an image file as text initially. + +See commands `image-mode' and `image-minor-mode' for more information +on these modes." + (interactive) + (image-mode-to-text) + (message "%s" (concat + (substitute-command-keys + "Type \\[image-toggle-display] or \\[image-toggle-hex-display] to view the image as ") + (if (image-get-display-property) + "text" "an image or hex") "."))) (define-obsolete-function-alias 'image-mode-maybe 'image-mode "23.2") @@ -726,15 +758,27 @@ was inserted." (if (called-interactively-p 'any) (message "Repeat this command to go back to displaying the file as text")))) +(defun image-toggle-hex-display () + "Toggle between image and hex display." + (interactive) + (if (image-get-display-property) + (image-mode-as-hex) + (if (eq major-mode 'fundamental-mode) + (image-mode-as-hex) + (image-mode)))) + (defun image-toggle-display () "Toggle between image and text display. + If the current buffer is displaying an image file as an image, -call `image-mode-as-text' to switch to text. Otherwise, display -the image by calling `image-mode'." +call `image-mode-as-text' to switch to text or hex display. +Otherwise, display the image by calling `image-mode'" (interactive) (if (image-get-display-property) (image-mode-as-text) - (image-mode))) + (if (eq major-mode 'hexl-mode) + (image-mode-as-text) + (image-mode)))) (defun image-kill-buffer () "Kill the current buffer." commit 2fa05dcd5e79b9dcd5cf2923c11bbcb5c92ae148 Author: Eli Zaretskii Date: Sat Feb 27 13:58:16 2016 +0200 Remove unused code in coding.c * src/coding.c (decode_eol): Remove unused code that handled the case of coding->dst_object being nil. Replace it with an assertion. diff --git a/src/coding.c b/src/coding.c index e591bed..f5fe52e 100644 --- a/src/coding.c +++ b/src/coding.c @@ -6814,39 +6814,29 @@ decode_eol (struct coding_system *coding) else if (EQ (eol_type, Qdos)) { ptrdiff_t n = 0; + ptrdiff_t pos = coding->dst_pos; + ptrdiff_t pos_byte = coding->dst_pos_byte; + ptrdiff_t pos_end = pos_byte + coding->produced - 1; - if (NILP (coding->dst_object)) - { - /* Start deleting '\r' from the tail to minimize the memory - movement. */ - for (p = pend - 2; p >= pbeg; p--) - if (*p == '\r') - { - memmove (p, p + 1, pend-- - p - 1); - n++; - } - } - else - { - ptrdiff_t pos = coding->dst_pos; - ptrdiff_t pos_byte = coding->dst_pos_byte; - ptrdiff_t pos_end = pos_byte + coding->produced - 1; + /* This assertion is here instead of code, now deleted, that + handled the NILP case, which no longer happens with the + current codebase. */ + eassert (!NILP (coding->dst_object)); - while (pos_byte < pos_end) + while (pos_byte < pos_end) + { + p = BYTE_POS_ADDR (pos_byte); + if (*p == '\r' && p[1] == '\n') { - p = BYTE_POS_ADDR (pos_byte); - if (*p == '\r' && p[1] == '\n') - { - del_range_2 (pos, pos_byte, pos + 1, pos_byte + 1, 0); - n++; - pos_end--; - } - pos++; - if (coding->dst_multibyte) - pos_byte += BYTES_BY_CHAR_HEAD (*p); - else - pos_byte++; + del_range_2 (pos, pos_byte, pos + 1, pos_byte + 1, 0); + n++; + pos_end--; } + pos++; + if (coding->dst_multibyte) + pos_byte += BYTES_BY_CHAR_HEAD (*p); + else + pos_byte++; } coding->produced -= n; coding->produced_char -= n;