emacs-diffs
[Top][All Lists]
Advanced

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

feature/android 714c4253858: Merge remote-tracking branch 'origin/master


From: Po Lu
Subject: feature/android 714c4253858: Merge remote-tracking branch 'origin/master' into feature/android
Date: Thu, 29 Jun 2023 20:37:59 -0400 (EDT)

branch: feature/android
commit 714c425385861d2a9e7b6bc95c27c3f9b1eca0aa
Merge: df761843f00 361bf8a1132
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Merge remote-tracking branch 'origin/master' into feature/android
---
 etc/NEWS.29             |  4 +++-
 lisp/gnus/nnagent.el    | 23 ++++++++++++-----------
 lisp/misc.el            | 33 +++++++++++++++++++++++++++------
 lisp/treesit.el         |  3 +--
 test/lisp/misc-tests.el | 14 ++++++++++++++
 5 files changed, 57 insertions(+), 20 deletions(-)

diff --git a/etc/NEWS.29 b/etc/NEWS.29
index ca0d602e9ad..aa3b758a815 100644
--- a/etc/NEWS.29
+++ b/etc/NEWS.29
@@ -696,7 +696,9 @@ between these modes while the user is inputting a command 
by hitting
 'duplicate-line' duplicates the current line the specified number of times.
 'duplicate-dwim' duplicates the region if it is active.  If not, it
 works like 'duplicate-line'.  An active rectangular region is
-duplicated on its right-hand side.
+duplicated on its right-hand side.  The new user option
+'duplicate-line-final-position' specifies where to move point
+after duplicating the line.
 
 ---
 ** Files with the ".eld" extension are now visited in 'lisp-data-mode'.
diff --git a/lisp/gnus/nnagent.el b/lisp/gnus/nnagent.el
index 61ec66155e4..30d5514a8b7 100644
--- a/lisp/gnus/nnagent.el
+++ b/lisp/gnus/nnagent.el
@@ -118,17 +118,18 @@
   (gnus-request-accept-article "nndraft:queue" nil t t))
 
 (deffoo nnagent-request-set-mark (group action server)
-  (insert "(gnus-agent-synchronize-group-flags \""
-         group
-         "\" '")
-  (gnus-pp action)
-  (insert " \""
-         (gnus-method-to-server gnus-command-method)
-         "\"")
-  (insert ")\n")
-  (let ((coding-system-for-write nnheader-file-coding-system))
-    (write-region (point-min) (point-max) (gnus-agent-lib-file "flags")
-                 t 'silent))
+  (with-temp-buffer
+    (insert "(gnus-agent-synchronize-group-flags \""
+           group
+           "\" '")
+    (gnus-pp action)
+    (insert " \""
+           (gnus-method-to-server gnus-command-method)
+           "\"")
+    (insert ")\n")
+    (let ((coding-system-for-write nnheader-file-coding-system))
+      (write-region (point-min) (point-max) (gnus-agent-lib-file "flags")
+                   t 'silent)))
   ;; Also set the marks for the original back end that keeps marks in
   ;; the local system.
   (let ((gnus-agent nil))
diff --git a/lisp/misc.el b/lisp/misc.el
index ab083728a69..dd4ebb4cde2 100644
--- a/lisp/misc.el
+++ b/lisp/misc.el
@@ -63,6 +63,19 @@ Also see the `duplicate-line' command."
                                 (+ n (point)))))))
     (insert string)))
 
+(defcustom duplicate-line-final-position 0
+  "Where to put point after duplicating the line with `duplicate-line'.
+When 0, leave point on the original line.
+When 1, move point to the first new line.
+When -1, move point to the last new line.
+The same column is preserved after moving to a new line."
+  :type '(choice (const :tag "Leave point on old line" 0)
+                 (const :tag "Move point to first new line" 1)
+                 (const :tag "Move point to last new line" -1)
+                 (integer))
+  :group 'editing
+  :version "29.1")
+
 (defun duplicate--insert-copies (n string)
   "Insert N copies of STRING at point."
   (insert (mapconcat #'identity (make-list n string))))
@@ -71,18 +84,26 @@ Also see the `duplicate-line' command."
 (defun duplicate-line (&optional n)
   "Duplicate the current line N times.
 Interactively, N is the prefix numeric argument, and defaults to 1.
+The user option `duplicate-line-final-position' specifies where to
+move point after duplicating the line.
 Also see the `copy-from-above-command' command."
   (interactive "p")
   (unless n
     (setq n 1))
   (let ((line (concat (buffer-substring (line-beginning-position)
                                         (line-end-position))
-                      "\n")))
-    (save-excursion
-      (forward-line 1)
-      (unless (bolp)
-        (insert "\n"))
-      (duplicate--insert-copies n line))))
+                      "\n"))
+        (pos (point))
+        (col (current-column)))
+    (forward-line 1)
+    (unless (bolp)
+      (insert "\n"))
+    (duplicate--insert-copies n line)
+    (unless (< duplicate-line-final-position 0)
+      (goto-char pos))
+    (unless (eq duplicate-line-final-position 0)
+      (forward-line duplicate-line-final-position)
+      (move-to-column col))))
 
 (declare-function rectangle--duplicate-right "rect" (n))
 
diff --git a/lisp/treesit.el b/lisp/treesit.el
index df13dd9f424..81920834329 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -3094,8 +3094,7 @@ nil, the grammar is installed to the standard location, 
the
     (condition-case err
         (progn
           (apply #'treesit--install-language-grammar-1
-                 ;; The nil is OUT-DIR.
-                 (cons nil recipe))
+                 (cons out-dir recipe))
 
           ;; Check that the installed language grammar is loadable.
           (pcase-let ((`(,available . ,err)
diff --git a/test/lisp/misc-tests.el b/test/lisp/misc-tests.el
index f1d22e099b9..ea27ea1653b 100644
--- a/test/lisp/misc-tests.el
+++ b/test/lisp/misc-tests.el
@@ -88,6 +88,20 @@
     (duplicate-line 2)
     (should (equal (buffer-string) "abc\ndefg\ndefg\ndefg\nh\n"))
     (should (equal (point) 7)))
+  ;; Duplicate a line (twice) and move point to the first duplicated line.
+  (with-temp-buffer
+    (insert "abc\ndefg\nh\n")
+    (goto-char 7)
+    (let ((duplicate-line-final-position 1)) (duplicate-line 2))
+    (should (equal (buffer-string) "abc\ndefg\ndefg\ndefg\nh\n"))
+    (should (equal (point) 12)))
+  ;; Duplicate a line (twice) and move point to the last duplicated line.
+  (with-temp-buffer
+    (insert "abc\ndefg\nh\n")
+    (goto-char 7)
+    (let ((duplicate-line-final-position -1)) (duplicate-line 2))
+    (should (equal (buffer-string) "abc\ndefg\ndefg\ndefg\nh\n"))
+    (should (equal (point) 17)))
   ;; Duplicate a non-terminated line.
   (with-temp-buffer
     (insert "abc")



reply via email to

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