emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 3e99ff9 2/2: Merge branch 'master' of git.sv.gnu.org:/srv/git/ema


From: Michael Albinus
Subject: master 3e99ff9 2/2: Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs
Date: Thu, 7 Jan 2021 10:44:06 -0500 (EST)

branch: master
commit 3e99ff97e5411e6f999895fb80cf446399d57c59
Merge: f5b8e5a 40a0f8a
Author: Michael Albinus <michael.albinus@gmx.de>
Commit: Michael Albinus <michael.albinus@gmx.de>

    Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs
---
 doc/lispref/windows.texi                           |  6 ++
 etc/NEWS                                           |  9 +++
 lisp/gnus/mm-decode.el                             | 19 +++--
 lisp/net/pop3.el                                   |  2 +-
 lisp/net/socks.el                                  |  1 +
 lisp/textmodes/paragraphs.el                       | 63 ++++++---------
 lisp/window.el                                     | 61 ++++++++++-----
 src/window.c                                       | 13 ++++
 .../gnus/mm-decode-resources/8bit-multipart.bin    | 20 +++++
 test/lisp/gnus/mm-decode-tests.el                  | 89 ++++++++++++++++++++++
 .../paragraphs-resources/mark-paragraph.bin        |  9 +++
 test/lisp/textmodes/paragraphs-tests.el            | 23 ++++++
 12 files changed, 252 insertions(+), 63 deletions(-)

diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi
index b0906ac..f305d1a 100644
--- a/doc/lispref/windows.texi
+++ b/doc/lispref/windows.texi
@@ -2634,6 +2634,12 @@ window and displaying the buffer in that window.  It can 
fail if all
 windows are dedicated to other buffers (@pxref{Dedicated Windows}).
 @end defun
 
+@defun display-buffer-use-least-recent-window buffer alist
+This function is like @code{display-buffer-use-some-window}, but will
+not reuse the current window, and will use the least recently
+switched-to window.
+@end defun
+
 @defun display-buffer-in-direction buffer alist
 This function tries to display @var{buffer} at a location specified by
 @var{alist}.  For this purpose, @var{alist} should contain a
diff --git a/etc/NEWS b/etc/NEWS
index 48fb4b8..14d6b45 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -373,6 +373,15 @@ disabled entirely.
 
 ** Windows
 
++++
+*** New 'display-buffer' function 'display-buffer-use-least-recent-window'
+This is like 'display-buffer-use-some-window', but won't reuse the
+current window, and when called repeatedly will try not to reuse a
+previously selected window.
+
+*** New function 'window-bump-use-time'.
+This updates the use time of a window.
+
 *** The key prefix 'C-x 4 1' displays next command buffer in the same window.
 It's bound to the command 'same-window-prefix' that requests the buffer
 of the next command to be displayed in the same window.
diff --git a/lisp/gnus/mm-decode.el b/lisp/gnus/mm-decode.el
index 61946aa..2b0b61b 100644
--- a/lisp/gnus/mm-decode.el
+++ b/lisp/gnus/mm-decode.el
@@ -1264,11 +1264,20 @@ in HANDLE."
      (when (and (mm-handle-buffer handle)
                (buffer-name (mm-handle-buffer handle)))
        (with-temp-buffer
-        (mm-disable-multibyte)
-        (insert-buffer-substring (mm-handle-buffer handle))
-        (mm-decode-content-transfer-encoding
-         (mm-handle-encoding handle)
-         (mm-handle-media-type handle))
+        (if (and (eq (mm-handle-encoding handle) '8bit)
+                 (with-current-buffer (mm-handle-buffer handle)
+                   enable-multibyte-characters))
+            ;; Due to unfortunate historical reasons, we may have a
+            ;; multibyte buffer here, but if it's using an 8bit
+            ;; Content-Transfer-Encoding, then work around that by
+            ;; just ignoring the situation.
+            (insert-buffer-substring (mm-handle-buffer handle))
+          ;; Do the decoding.
+          (mm-disable-multibyte)
+          (insert-buffer-substring (mm-handle-buffer handle))
+          (mm-decode-content-transfer-encoding
+           (mm-handle-encoding handle)
+           (mm-handle-media-type handle)))
         ,@forms))))
 (put 'mm-with-part 'lisp-indent-function 1)
 (put 'mm-with-part 'edebug-form-spec '(body))
diff --git a/lisp/net/pop3.el b/lisp/net/pop3.el
index aa34fe7..dcac36f 100644
--- a/lisp/net/pop3.el
+++ b/lisp/net/pop3.el
@@ -463,7 +463,7 @@ Return non-nil if it is necessary to update the local UIDL 
file."
                (when (cdr elt)
                  (insert "(\"" (pop elt) "\"\n   ")
                  (while elt
-                   (insert (format "\"%s\" %s\n   " (pop elt) (pop elt))))
+                   (insert (format "%S %s\n   " (pop elt) (pop elt))))
                  (delete-char -4)
                  (insert ")\n  ")))
              (delete-char -3)
diff --git a/lisp/net/socks.el b/lisp/net/socks.el
index 0d48fd7..96fafc8 100644
--- a/lisp/net/socks.el
+++ b/lisp/net/socks.el
@@ -385,6 +385,7 @@
          )
         )
        (process-put proc 'socks-state socks-state-authenticated)
+       (process-put proc 'socks-scratch "")
        (set-process-filter proc #'socks-filter)))
       proc)))
 
diff --git a/lisp/textmodes/paragraphs.el b/lisp/textmodes/paragraphs.el
index 217ae10..96edfd6 100644
--- a/lisp/textmodes/paragraphs.el
+++ b/lisp/textmodes/paragraphs.el
@@ -371,50 +371,33 @@ See `forward-paragraph' for more information."
 
 (defun mark-paragraph (&optional arg allow-extend)
   "Put point at beginning of this paragraph, mark at end.
-The paragraph marked is the one that contains point or follows
-point.
+The paragraph marked is the one that contains point or follows point.
 
-With argument ARG, puts mark at the end of this or a following
-paragraph, so that the number of paragraphs marked equals ARG.
+With argument ARG, puts mark at end of a following paragraph, so that
+the number of paragraphs marked equals ARG.
 
-If ARG is negative, point is put at the end of this paragraph,
-mark is put at the beginning of this or a previous paragraph.
+If ARG is negative, point is put at end of this paragraph, mark is put
+at beginning of this or a previous paragraph.
 
 Interactively (or if ALLOW-EXTEND is non-nil), if this command is
-repeated or (in Transient Mark mode) if the mark is active, it
-marks the next ARG paragraphs after the region already marked.
-This also means when activating the mark immediately before using
-this command, the current paragraph is only marked from point."
-  (interactive "P\np")
-  (let ((numeric-arg (prefix-numeric-value arg)))
-    (cond ((zerop numeric-arg))
-         ((and allow-extend
-               (or (and (eq last-command this-command) mark-active)
-                   (region-active-p)))
-          (if arg
-              (setq arg numeric-arg)
-            (if (< (mark) (point))
-                (setq arg -1)
-              (setq arg 1)))
-          (set-mark
-           (save-excursion
-             (goto-char (mark))
-             (forward-paragraph arg)
-             (point))))
-         ;; don't activate the mark when at eob
-         ((and (eobp) (> numeric-arg 0)))
-         (t
-          (unless (save-excursion
-                    (forward-line 0)
-                    (looking-at  paragraph-start))
-            (backward-paragraph (cond ((> numeric-arg 0) 1)
-                                       ((< numeric-arg 0) -1)
-                                       (t 0))))
-          (push-mark
-           (save-excursion
-             (forward-paragraph numeric-arg)
-             (point))
-            t t)))))
+repeated or (in Transient Mark mode) if the mark is active,
+it marks the next ARG paragraphs after the ones already marked."
+  (interactive "p\np")
+  (unless arg (setq arg 1))
+  (when (zerop arg)
+    (error "Cannot mark zero paragraphs"))
+  (cond ((and allow-extend
+             (or (and (eq last-command this-command) (mark t))
+                 (and transient-mark-mode mark-active)))
+        (set-mark
+         (save-excursion
+           (goto-char (mark))
+           (forward-paragraph arg)
+           (point))))
+       (t
+        (forward-paragraph arg)
+        (push-mark nil t t)
+        (backward-paragraph arg))))
 
 (defun kill-paragraph (arg)
   "Kill forward to end of paragraph.
diff --git a/lisp/window.el b/lisp/window.el
index cd13e66..37e1800 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -7243,6 +7243,7 @@ The actual non-nil value of this variable will be copied 
to the
           (const display-buffer-below-selected)
           (const display-buffer-at-bottom)
           (const display-buffer-in-previous-window)
+          (const display-buffer-use-least-recent-window)
           (const display-buffer-use-some-window)
           (const display-buffer-use-some-frame)
           (function :tag "Other function"))
@@ -7378,6 +7379,37 @@ fails, call `display-buffer-pop-up-frame'.")
 
 (defun display-buffer (buffer-or-name &optional action frame)
   "Display BUFFER-OR-NAME in some window, without selecting it.
+To change which window is used, set `display-buffer-base-action'
+to a list containing one of these \"action\" functions:
+
+ `display-buffer-same-window' -- Use the selected window.
+ `display-buffer-reuse-window' -- Use a window already showing
+    the buffer.
+ `display-buffer-in-previous-window' -- Use a window that did
+    show the buffer before.
+ `display-buffer-use-some-window' -- Use some existing window.
+ `display-buffer-use-least-recent-window' -- Try to avoid re-using
+    windows that have recently been switched to.
+ `display-buffer-pop-up-window' -- Pop up a new window.
+ `display-buffer-below-selected' -- Use or pop up a window below
+    the selected one.
+ `display-buffer-at-bottom' -- Use or pop up a window at the
+    bottom of the selected frame.
+ `display-buffer-pop-up-frame' -- Show the buffer on a new frame.
+ `display-buffer-in-child-frame' -- Show the buffer in a
+    child frame.
+ `display-buffer-no-window' -- Do not display the buffer and
+    have `display-buffer' return nil immediately.
+
+For instance:
+
+   (setq display-buffer-base-action '(display-buffer-at-bottom))
+
+Buffer display can be further customized to a very high degree;
+the rest of this docstring explains some of the many
+possibilities, and also see `(emacs)Window Choice' for more
+information.
+
 BUFFER-OR-NAME must be a buffer or a string naming a live buffer.
 Return the window chosen for displaying that buffer, or nil if no
 such window is found.
@@ -7403,23 +7435,8 @@ function in the combined function list in turn, passing 
the
 buffer as the first argument and the combined action alist as the
 second argument, until one of the functions returns non-nil.
 
-Action functions and the action they try to perform are:
- `display-buffer-same-window' -- Use the selected window.
- `display-buffer-reuse-window' -- Use a window already showing
-    the buffer.
- `display-buffer-in-previous-window' -- Use a window that did
-    show the buffer before.
- `display-buffer-use-some-window' -- Use some existing window.
- `display-buffer-pop-up-window' -- Pop up a new window.
- `display-buffer-below-selected' -- Use or pop up a window below
-    the selected one.
- `display-buffer-at-bottom' -- Use or pop up a window at the
-    bottom of the selected frame.
- `display-buffer-pop-up-frame' -- Show the buffer on a new frame.
- `display-buffer-in-child-frame' -- Show the buffer in a
-    child frame.
- `display-buffer-no-window' -- Do not display the buffer and
-    have `display-buffer' return nil immediately.
+See above for the action functions and the action they try to
+perform.
 
 Action alist entries are:
  `inhibit-same-window' -- A non-nil value prevents the same
@@ -8242,6 +8259,16 @@ indirectly called by the latter."
     (when (setq window (or best-window second-best-window))
       (window--display-buffer buffer window 'reuse alist))))
 
+(defun display-buffer-use-least-recent-window (buffer alist)
+  "Display BUFFER in an existing window, but that hasn't been used lately.
+This `display-buffer' action function is like
+`display-buffer-use-some-window', but will cycle through windows
+when displaying buffers repeatedly, and if there's only a single
+window, it will split the window."
+  (when-let ((window (display-buffer-use-some-window
+                      buffer (cons (cons 'inhibit-same-window t) alist))))
+    (window-bump-use-time window)))
+
 (defun display-buffer-use-some-window (buffer alist)
   "Display BUFFER in an existing window.
 Search for a usable window, set that window to the buffer, and
diff --git a/src/window.c b/src/window.c
index 58204c1..5e78aa4 100644
--- a/src/window.c
+++ b/src/window.c
@@ -8100,6 +8100,18 @@ and scrolling positions.  */)
     return Qt;
   return Qnil;
 }
+
+DEFUN ("window-bump-use-time", Fwindow_bump_use_time,
+       Swindow_bump_use_time, 1, 1, 0,
+       doc: /* Mark WINDOW as having been recently used.  */)
+  (Lisp_Object window)
+{
+  struct window *w = decode_valid_window (window);
+
+  w->use_time = ++window_select_count;
+  return Qnil;
+}
+
 
 
 static void init_window_once_for_pdumper (void);
@@ -8573,6 +8585,7 @@ displayed after a scrolling operation to be somewhat 
inaccurate.  */);
   defsubr (&Swindow_vscroll);
   defsubr (&Sset_window_vscroll);
   defsubr (&Scompare_window_configurations);
+  defsubr (&Swindow_bump_use_time);
   defsubr (&Swindow_list);
   defsubr (&Swindow_list_1);
   defsubr (&Swindow_prev_buffers);
diff --git a/test/lisp/gnus/mm-decode-resources/8bit-multipart.bin 
b/test/lisp/gnus/mm-decode-resources/8bit-multipart.bin
new file mode 100644
index 0000000..0b193a2
--- /dev/null
+++ b/test/lisp/gnus/mm-decode-resources/8bit-multipart.bin
@@ -0,0 +1,20 @@
+From: example <example@example.org>
+To: example <example@example.org>
+Content-Type: multipart/alternative; 
boundary="===============2877195075946974246=="
+Date: Thu, 29 Oct 2020 14:47:55 +0100
+MIME-Version: 1.0
+Subject: test
+
+--===============2877195075946974246==
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: 8bit
+
+ääää
+
+--===============2877195075946974246==
+Content-Type: text/html; charset="utf-8"
+Content-Transfer-Encoding: 8bit
+
+<!doctype html><html><head><meta http-equiv="content-type" content="text/html; 
charset=UTF-8"></head><body>ääää</body></html>
+
+--===============2877195075946974246==--
diff --git a/test/lisp/gnus/mm-decode-tests.el 
b/test/lisp/gnus/mm-decode-tests.el
new file mode 100644
index 0000000..74591f9
--- /dev/null
+++ b/test/lisp/gnus/mm-decode-tests.el
@@ -0,0 +1,89 @@
+;;; mm-decode-tests.el ---  -*- lexical-binding:t -*-
+
+;; Copyright (C) 2021 Free Software Foundation, Inc.
+
+;; 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, 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 <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;; Code:
+
+(require 'ert)
+(require 'ert-x)
+(require 'mm-decode)
+
+(ert-deftest test-mm-dissect-buffer ()
+  (with-temp-buffer
+    (set-buffer-multibyte nil)
+    (insert-file-contents-literally (ert-resource-file "8bit-multipart.bin"))
+    (while (search-forward "\r\n" nil t)
+      (replace-match "\n"))
+    (let ((handle (mm-dissect-buffer)))
+      (should (equal (mm-handle-media-type handle) "multipart/alternative"))
+      ;; Skip multipart type.
+      (pop handle)
+      (let ((part (pop handle)))
+        (should (equal (mm-handle-media-type part) "text/plain"))
+        (should (eq (mm-handle-encoding part) '8bit))
+        (with-current-buffer (mm-handle-buffer part)
+          (should (equal (decode-coding-string
+                          (buffer-string)
+                          (intern (mail-content-type-get (mm-handle-type part)
+                                                         'charset)))
+                         "ääää\n"))))
+      (let ((part (pop handle)))
+        (should (equal (mm-handle-media-type part) "text/html"))
+        (should (eq (mm-handle-encoding part) '8bit))
+        (with-current-buffer (mm-handle-buffer part)
+          (should (equal (decode-coding-string
+                          (buffer-string)
+                          (intern (mail-content-type-get (mm-handle-type part)
+                                                         'charset)))
+                         "<!doctype html><html><head><meta 
http-equiv=\"content-type\" content=\"text/html; 
charset=UTF-8\"></head><body>ääää</body></html>\n")))))))
+
+(ert-deftest test-mm-with-part-unibyte ()
+  (with-temp-buffer
+    (set-buffer-multibyte nil)
+    (insert-file-contents-literally (ert-resource-file "8bit-multipart.bin"))
+    (while (search-forward "\r\n" nil t)
+      (replace-match "\n"))
+    (let ((handle (mm-dissect-buffer)))
+      (pop handle)
+      (let ((part (pop handle)))
+        (should (equal (decode-coding-string
+                        (mm-with-part part
+                          (buffer-string))
+                        (intern (mail-content-type-get (mm-handle-type part)
+                                                       'charset)))
+                       "ääää\n"))))))
+
+(ert-deftest test-mm-with-part-multibyte ()
+  (with-temp-buffer
+    (set-buffer-multibyte t)
+    (nnheader-insert-file-contents (ert-resource-file "8bit-multipart.bin"))
+    (while (search-forward "\r\n" nil t)
+      (replace-match "\n"))
+    (let ((handle (mm-dissect-buffer)))
+      (pop handle)
+      (let ((part (pop handle)))
+        (should (equal (decode-coding-string
+                        (mm-with-part part
+                          (buffer-string))
+                        (intern (mail-content-type-get (mm-handle-type part)
+                                                       'charset)))
+                       "ääää\n"))))))
+
+;;; mm-decode-tests.el ends here
diff --git a/test/lisp/textmodes/paragraphs-resources/mark-paragraph.bin 
b/test/lisp/textmodes/paragraphs-resources/mark-paragraph.bin
new file mode 100644
index 0000000..1905477
--- /dev/null
+++ b/test/lisp/textmodes/paragraphs-resources/mark-paragraph.bin
@@ -0,0 +1,9 @@
+First
+paragraph
+
+Second
+
+Third
+paragraph
+
+No line end
\ No newline at end of file
diff --git a/test/lisp/textmodes/paragraphs-tests.el 
b/test/lisp/textmodes/paragraphs-tests.el
index bf7f370..7121690 100644
--- a/test/lisp/textmodes/paragraphs-tests.el
+++ b/test/lisp/textmodes/paragraphs-tests.el
@@ -24,6 +24,7 @@
 ;;; Code:
 
 (require 'ert)
+(require 'ert-x)
 ;; (require 'paragraphs) ; loaded by default
 
 (ert-deftest paragraphs-tests-sentence-end ()
@@ -161,5 +162,27 @@
     (should (equal (buffer-string)
                    "First sentence.  Third sentence.  Second sentence."))))
 
+(ert-deftest test-mark-paragraphs ()
+  (with-current-buffer
+      (find-file-noselect (ert-resource-file "mark-paragraph.bin"))
+    (goto-char (point-max))
+    ;; Just a sanity check that the file hasn't changed.
+    (should (= (point) 54))
+    (mark-paragraph)
+    (should (= (point) 42))
+    (should (= (mark) 54))
+    ;; Doesn't move.
+    (mark-paragraph)
+    (should (= (point) 42))
+    (should (= (mark) 54))
+    (forward-line -1)
+    (mark-paragraph)
+    (should (= (point) 25))
+    (should (= (mark) 42))
+    (goto-char (point-min))
+    (mark-paragraph)
+    (should (= (point) 1))
+    (should (= (mark) 17))))
+
 (provide 'paragraphs-tests)
 ;;; paragraphs-tests.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]