unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#68881: 30.0.50; [PATCH] Field properties confuse 'outline-minor-mode'
@ 2024-02-01 23:51 Jim Porter
  2024-02-07 17:37 ` Juri Linkov
  0 siblings, 1 reply; 11+ messages in thread
From: Jim Porter @ 2024-02-01 23:51 UTC (permalink / raw)
  To: 68881

[-- Attachment #1: Type: text/plain, Size: 960 bytes --]

I'd like to add support for 'outline-minor-mode' in Eshell. However, 
Eshell's use of field properties confuses outline.el. Attached is a WIP 
patch + demo code for Eshell that should resolve this.

The main issue was that outline.el uses 'line-beginning-position' and 
friends, which respects field boundaries, but I think we want to avoid 
that for 'outline-minor-mode'. Maybe we could use 'pos-bol' and friends 
instead, but my understanding is that 'line-beginning-position' respects 
display directionality (which we probably want), but 'pos-bol' doesn't.

You can try things out here by starting Eshell and activating 
'outline-minor-mode'. You can also see the problems by applying only the 
Eshell part of the patch.

Any thoughts? Is this the right way to go about this? (Note: I think the 
Eshell side of things will take more work, which I'll address in a later 
bug. However, this should be enough to show off the problems on the 
outline.el side.)

[-- Attachment #2: 0001-WIP-Make-outline.el-able-to-handle-buffers-with-fiel.patch --]
[-- Type: text/plain, Size: 5860 bytes --]

From fad64a23e38fbc43cee121db78f00e255df3ecd8 Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Thu, 1 Feb 2024 13:58:20 -0800
Subject: [PATCH] [WIP] Make outline.el able to handle buffers with field
 properties

* lisp/outline.el (outline-back-to-heading, outline-on-heading-p)
(outline-next-visible-heading, outline-mark-subtree)
(outline-hide-sublevels, outline--insert-button)
(outline--fix-up-all-buttons): Inhibit field text motion.

* lisp/eshell/em-prompt.el (eshell-outline-search): New function (for
testing only).
(eshell-prompt-initialize): Initialize outline-mode variables.
---
 lisp/eshell/em-prompt.el | 14 +++++++++++++-
 lisp/outline.el          | 32 +++++++++++++++++++++-----------
 2 files changed, 34 insertions(+), 12 deletions(-)

diff --git a/lisp/eshell/em-prompt.el b/lisp/eshell/em-prompt.el
index 3662c1fa895..bf3a24689f8 100644
--- a/lisp/eshell/em-prompt.el
+++ b/lisp/eshell/em-prompt.el
@@ -107,6 +107,14 @@ eshell-prompt-repeat-map
 
 ;;; Functions:
 
+(defun eshell-outline-search (&optional bound move backward looking-at)
+  "Search for outline headings.  See `outline-search-function'."
+  ;; FIXME: This probably isn't the right way to do things.  Does it
+  ;; work with multiline prompts?  Still, it's useful for a proof of
+  ;; concept.
+  (outline-search-text-property 'field 'prompt bound move backward
+                                looking-at))
+
 (define-minor-mode eshell-prompt-mode
   "Minor mode for eshell-prompt module.
 
@@ -117,7 +125,11 @@ eshell-prompt-initialize
   "Initialize the prompting code."
   (unless eshell-non-interactive-p
     (add-hook 'eshell-post-command-hook 'eshell-emit-prompt nil t)
-    (eshell-prompt-mode)))
+    (eshell-prompt-mode)
+
+    (setq-local outline-search-function #'eshell-outline-search
+                outline-level (lambda () 1)
+                outline-minor-mode-use-buttons 'in-margins)))
 
 (defun eshell-emit-prompt ()
   "Emit a prompt if eshell is being used interactively."
diff --git a/lisp/outline.el b/lisp/outline.el
index b50708c1a7b..e7e8d269640 100644
--- a/lisp/outline.el
+++ b/lisp/outline.el
@@ -686,7 +686,8 @@ 'outline-before-first-heading
 (defun outline-back-to-heading (&optional invisible-ok)
   "Move to previous heading line, or beg of this line if it's a heading.
 Only visible heading lines are considered, unless INVISIBLE-OK is non-nil."
-  (beginning-of-line)
+  (let ((inhibit-field-text-motion t))
+    (beginning-of-line))
   (or (outline-on-heading-p invisible-ok)
       (let (found)
 	(save-excursion
@@ -705,7 +706,8 @@ outline-on-heading-p
   "Return t if point is on a (visible) heading line.
 If INVISIBLE-OK is non-nil, an invisible heading line is ok too."
   (save-excursion
-    (beginning-of-line)
+    (let ((inhibit-field-text-motion t))
+      (beginning-of-line))
     (and (bolp) (or invisible-ok (not (outline-invisible-p)))
 	 (if outline-search-function
              (funcall outline-search-function nil nil nil t)
@@ -941,9 +943,10 @@ outline-next-visible-heading
 A heading line is one that starts with a `*' (or that
 `outline-regexp' matches)."
   (interactive "p")
-  (if (< arg 0)
-      (beginning-of-line)
-    (end-of-line))
+  (let ((inhibit-field-text-motion t))
+    (if (< arg 0)
+        (beginning-of-line)
+      (end-of-line)))
   (let ((regexp (unless outline-search-function
                   (concat "^\\(?:" outline-regexp "\\)")))
         found-heading-p)
@@ -963,7 +966,9 @@ outline-next-visible-heading
                           (re-search-forward regexp nil 'move)))
 		  (outline-invisible-p (match-beginning 0))))
       (setq arg (1- arg)))
-    (if found-heading-p (beginning-of-line))))
+    (if found-heading-p
+        (let ((inhibit-field-text-motion t))
+          (beginning-of-line)))))
 
 (defun outline-previous-visible-heading (arg)
   "Move to the previous heading line.
@@ -980,7 +985,8 @@ outline-mark-subtree
   (let ((beg))
     (if (outline-on-heading-p)
 	;; we are already looking at a heading
-	(beginning-of-line)
+        (let ((inhibit-field-text-motion t))
+          (beginning-of-line))
       ;; else go back to previous heading
       (outline-previous-visible-heading 1))
     (setq beg (point))
@@ -1183,7 +1189,8 @@ outline-hide-sublevels
 		(cond
 		 (current-prefix-arg (prefix-numeric-value current-prefix-arg))
 		 ((save-excursion
-                    (beginning-of-line)
+                    (let ((inhibit-field-text-motion t))
+                      (beginning-of-line))
 		    (if outline-search-function
                         (funcall outline-search-function nil nil nil t)
                       (looking-at outline-regexp)))
@@ -1834,13 +1841,15 @@ outline--create-button-icons
 (defun outline--insert-button (type)
   (with-silent-modifications
     (save-excursion
-      (beginning-of-line)
+      (let ((inhibit-field-text-motion t))
+        (beginning-of-line))
       (let ((icon (nth (if (eq type 'close) 1 0) outline--button-icons))
             (o (seq-find (lambda (o) (overlay-get o 'outline-button))
                          (overlays-at (point)))))
         (unless o
           (when (eq outline-minor-mode-use-buttons 'insert)
-            (let ((inhibit-read-only t))
+            (let ((inhibit-read-only t)
+                  (inhibit-field-text-motion t))
               (insert (apply #'propertize "  " (text-properties-at (point))))
               (beginning-of-line)))
           (setq o (make-overlay (point) (1+ (point))))
@@ -1866,7 +1875,8 @@ outline--fix-up-all-buttons
     (when from
       (save-excursion
         (goto-char from)
-        (setq from (line-beginning-position))))
+        (let ((inhibit-field-text-motion t))
+          (setq from (line-beginning-position)))))
     (outline-map-region
      (lambda ()
        (let ((close-p (save-excursion
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* bug#68881: 30.0.50; [PATCH] Field properties confuse 'outline-minor-mode'
  2024-02-01 23:51 bug#68881: 30.0.50; [PATCH] Field properties confuse 'outline-minor-mode' Jim Porter
@ 2024-02-07 17:37 ` Juri Linkov
  2024-02-10 18:22   ` Jim Porter
  0 siblings, 1 reply; 11+ messages in thread
From: Juri Linkov @ 2024-02-07 17:37 UTC (permalink / raw)
  To: Jim Porter; +Cc: 68881

> I'd like to add support for 'outline-minor-mode' in Eshell. However,
> Eshell's use of field properties confuses outline.el. Attached is a WIP
> patch + demo code for Eshell that should resolve this.
>
> The main issue was that outline.el uses 'line-beginning-position' and
> friends, which respects field boundaries, but I think we want to avoid that
> for 'outline-minor-mode'. Maybe we could use 'pos-bol' and friends instead,
> but my understanding is that 'line-beginning-position' respects display
> directionality (which we probably want), but 'pos-bol' doesn't.

I'm not aware of any cases that would require restricting
outlines to field boundaries.

> You can try things out here by starting Eshell and activating
> 'outline-minor-mode'. You can also see the problems by applying only the
> Eshell part of the patch.

Thanks.  I tried and confirm that your outline.el patch fixes the issue.

> Any thoughts? Is this the right way to go about this? (Note: I think the
> Eshell side of things will take more work, which I'll address in a later
> bug. However, this should be enough to show off the problems on the
> outline.el side.)

There is also one occurrence of 'line-end-position' in outline.el.
Should it have 'inhibit-field-text-motion' as well?





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#68881: 30.0.50; [PATCH] Field properties confuse 'outline-minor-mode'
  2024-02-07 17:37 ` Juri Linkov
@ 2024-02-10 18:22   ` Jim Porter
  2024-02-10 19:23     ` Eli Zaretskii
  2024-02-11 17:40     ` Juri Linkov
  0 siblings, 2 replies; 11+ messages in thread
From: Jim Porter @ 2024-02-10 18:22 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 68881

[-- Attachment #1: Type: text/plain, Size: 1361 bytes --]

On 2/7/2024 9:37 AM, Juri Linkov wrote:
>> The main issue was that outline.el uses 'line-beginning-position' and
>> friends, which respects field boundaries, but I think we want to avoid that
>> for 'outline-minor-mode'. Maybe we could use 'pos-bol' and friends instead,
>> but my understanding is that 'line-beginning-position' respects display
>> directionality (which we probably want), but 'pos-bol' doesn't.
> 
> I'm not aware of any cases that would require restricting
> outlines to field boundaries.

Thanks. After reading the source (generally a good idea), I now see that 
'line-beginning-position' doesn't respect display directionality, so 
there's no reason to use it over 'pos-bol' and friends. I've therefore 
updated the patch to use those, which makes things a bit simpler.

(In any case, I think for RTL, we'd want to use the logical ordering of 
the text anyway, but possibly add the outline buttons on the right side 
of the window instead. That's out of scope for this bug though.)

> There is also one occurrence of 'line-end-position' in outline.el.
> Should it have 'inhibit-field-text-motion' as well?

Thanks for the catch. Updated this as well.

(I also split out the Eshell demonstration patch so that I can drop the 
commit more easily before merging. It's still attached here though in 
case you or anyone else want to try it out.)

[-- Attachment #2: 0001-Make-outline.el-ignore-field-properties-in-text.patch --]
[-- Type: text/plain, Size: 4687 bytes --]

From 29a36c1c32bce66468b85aa931fe2c7a8cc491e2 Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Thu, 1 Feb 2024 13:58:20 -0800
Subject: [PATCH 1/2] Make outline.el ignore field properties in text

* lisp/outline.el (outline-back-to-heading, outline-on-heading-p)
(outline-next-visible-heading, outline-mark-subtree)
(outline-hide-sublevels, outline--insert-button)
(outline--fix-up-all-buttons): Inhibit field text motion (bug#68881).
---
 lisp/outline.el | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/lisp/outline.el b/lisp/outline.el
index b50708c1a7b..33447472100 100644
--- a/lisp/outline.el
+++ b/lisp/outline.el
@@ -686,7 +686,7 @@ 'outline-before-first-heading
 (defun outline-back-to-heading (&optional invisible-ok)
   "Move to previous heading line, or beg of this line if it's a heading.
 Only visible heading lines are considered, unless INVISIBLE-OK is non-nil."
-  (beginning-of-line)
+  (forward-line 0)
   (or (outline-on-heading-p invisible-ok)
       (let (found)
 	(save-excursion
@@ -705,7 +705,7 @@ outline-on-heading-p
   "Return t if point is on a (visible) heading line.
 If INVISIBLE-OK is non-nil, an invisible heading line is ok too."
   (save-excursion
-    (beginning-of-line)
+    (forward-line 0)
     (and (bolp) (or invisible-ok (not (outline-invisible-p)))
 	 (if outline-search-function
              (funcall outline-search-function nil nil nil t)
@@ -725,7 +725,7 @@ outline-insert-heading
 		(not (string-match (concat "\\`\\(?:" outline-regexp "\\)")
 				   (concat head " "))))
       (setq head (concat head " ")))
-    (unless (bolp) (end-of-line) (newline))
+    (unless (bolp) (goto-char (pos-bol)) (newline))
     (insert head)
     (unless (eolp)
       (save-excursion (newline-and-indent)))
@@ -941,9 +941,7 @@ outline-next-visible-heading
 A heading line is one that starts with a `*' (or that
 `outline-regexp' matches)."
   (interactive "p")
-  (if (< arg 0)
-      (beginning-of-line)
-    (end-of-line))
+  (goto-char (if (< arg 0) (pos-bol) (pos-eol)))
   (let ((regexp (unless outline-search-function
                   (concat "^\\(?:" outline-regexp "\\)")))
         found-heading-p)
@@ -963,7 +961,7 @@ outline-next-visible-heading
                           (re-search-forward regexp nil 'move)))
 		  (outline-invisible-p (match-beginning 0))))
       (setq arg (1- arg)))
-    (if found-heading-p (beginning-of-line))))
+    (if found-heading-p (forward-line 0))))
 
 (defun outline-previous-visible-heading (arg)
   "Move to the previous heading line.
@@ -980,7 +978,7 @@ outline-mark-subtree
   (let ((beg))
     (if (outline-on-heading-p)
 	;; we are already looking at a heading
-	(beginning-of-line)
+        (forward-line 0)
       ;; else go back to previous heading
       (outline-previous-visible-heading 1))
     (setq beg (point))
@@ -1183,7 +1181,7 @@ outline-hide-sublevels
 		(cond
 		 (current-prefix-arg (prefix-numeric-value current-prefix-arg))
 		 ((save-excursion
-                    (beginning-of-line)
+                    (forward-line 0)
 		    (if outline-search-function
                         (funcall outline-search-function nil nil nil t)
                       (looking-at outline-regexp)))
@@ -1243,7 +1241,7 @@ outline-toggle-children
   (interactive)
   (save-excursion
     (outline-back-to-heading)
-    (if (not (outline-invisible-p (line-end-position)))
+    (if (not (outline-invisible-p (pos-eol)))
         (outline-hide-subtree)
       (outline-show-children)
       (outline-show-entry))))
@@ -1834,7 +1832,7 @@ outline--create-button-icons
 (defun outline--insert-button (type)
   (with-silent-modifications
     (save-excursion
-      (beginning-of-line)
+      (forward-line 0)
       (let ((icon (nth (if (eq type 'close) 1 0) outline--button-icons))
             (o (seq-find (lambda (o) (overlay-get o 'outline-button))
                          (overlays-at (point)))))
@@ -1842,7 +1840,7 @@ outline--insert-button
           (when (eq outline-minor-mode-use-buttons 'insert)
             (let ((inhibit-read-only t))
               (insert (apply #'propertize "  " (text-properties-at (point))))
-              (beginning-of-line)))
+              (forward-line 0)))
           (setq o (make-overlay (point) (1+ (point))))
           (overlay-put o 'outline-button t)
           (overlay-put o 'evaporate t))
@@ -1866,7 +1864,7 @@ outline--fix-up-all-buttons
     (when from
       (save-excursion
         (goto-char from)
-        (setq from (line-beginning-position))))
+        (setq from (pos-bol))))
     (outline-map-region
      (lambda ()
        (let ((close-p (save-excursion
-- 
2.25.1


[-- Attachment #3: 0002-DO-NOT-MERGE-Test-commit-for-previous-patch.patch --]
[-- Type: text/plain, Size: 1557 bytes --]

From fa7e4acaa80799055866866f1cf3f9c7b3ff55e5 Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Fri, 9 Feb 2024 22:18:35 -0800
Subject: [PATCH 2/2] [DO NOT MERGE] Test commit for previous patch

---
 lisp/eshell/em-prompt.el | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/lisp/eshell/em-prompt.el b/lisp/eshell/em-prompt.el
index 3662c1fa895..bf3a24689f8 100644
--- a/lisp/eshell/em-prompt.el
+++ b/lisp/eshell/em-prompt.el
@@ -107,6 +107,14 @@ eshell-prompt-repeat-map
 
 ;;; Functions:
 
+(defun eshell-outline-search (&optional bound move backward looking-at)
+  "Search for outline headings.  See `outline-search-function'."
+  ;; FIXME: This probably isn't the right way to do things.  Does it
+  ;; work with multiline prompts?  Still, it's useful for a proof of
+  ;; concept.
+  (outline-search-text-property 'field 'prompt bound move backward
+                                looking-at))
+
 (define-minor-mode eshell-prompt-mode
   "Minor mode for eshell-prompt module.
 
@@ -117,7 +125,11 @@ eshell-prompt-initialize
   "Initialize the prompting code."
   (unless eshell-non-interactive-p
     (add-hook 'eshell-post-command-hook 'eshell-emit-prompt nil t)
-    (eshell-prompt-mode)))
+    (eshell-prompt-mode)
+
+    (setq-local outline-search-function #'eshell-outline-search
+                outline-level (lambda () 1)
+                outline-minor-mode-use-buttons 'in-margins)))
 
 (defun eshell-emit-prompt ()
   "Emit a prompt if eshell is being used interactively."
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* bug#68881: 30.0.50; [PATCH] Field properties confuse 'outline-minor-mode'
  2024-02-10 18:22   ` Jim Porter
@ 2024-02-10 19:23     ` Eli Zaretskii
  2024-02-10 21:14       ` Jim Porter
  2024-02-11 17:40     ` Juri Linkov
  1 sibling, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2024-02-10 19:23 UTC (permalink / raw)
  To: Jim Porter; +Cc: 68881, juri

> Cc: 68881@debbugs.gnu.org
> Date: Sat, 10 Feb 2024 10:22:16 -0800
> From: Jim Porter <jporterbugs@gmail.com>
> 
> On 2/7/2024 9:37 AM, Juri Linkov wrote:
> >> The main issue was that outline.el uses 'line-beginning-position' and
> >> friends, which respects field boundaries, but I think we want to avoid that
> >> for 'outline-minor-mode'. Maybe we could use 'pos-bol' and friends instead,
> >> but my understanding is that 'line-beginning-position' respects display
> >> directionality (which we probably want), but 'pos-bol' doesn't.
> > 
> > I'm not aware of any cases that would require restricting
> > outlines to field boundaries.
> 
> Thanks. After reading the source (generally a good idea), I now see that 
> 'line-beginning-position' doesn't respect display directionality, so 
> there's no reason to use it over 'pos-bol' and friends. I've therefore 
> updated the patch to use those, which makes things a bit simpler.
> 
> (In any case, I think for RTL, we'd want to use the logical ordering of 
> the text anyway, but possibly add the outline buttons on the right side 
> of the window instead. That's out of scope for this bug though.)

I don't understand what text directionality has to do with the issue
at hand.  If you elaborate, I could perhaps be of assistance in this
matter.





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#68881: 30.0.50; [PATCH] Field properties confuse 'outline-minor-mode'
  2024-02-10 19:23     ` Eli Zaretskii
@ 2024-02-10 21:14       ` Jim Porter
  2024-02-11  6:07         ` Eli Zaretskii
  0 siblings, 1 reply; 11+ messages in thread
From: Jim Porter @ 2024-02-10 21:14 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 68881, juri

On 2/10/2024 11:23 AM, Eli Zaretskii wrote:
> I don't understand what text directionality has to do with the issue
> at hand.  If you elaborate, I could perhaps be of assistance in this
> matter.

I think nothing in this case. I just wasn't sure initially whether 
'pos-bol' and 'line-beginning-position' handled directionality 
differently. Since they handle it the same way, I think there's no harm 
in using 'pos-bol' in this case.





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#68881: 30.0.50; [PATCH] Field properties confuse 'outline-minor-mode'
  2024-02-10 21:14       ` Jim Porter
@ 2024-02-11  6:07         ` Eli Zaretskii
  2024-02-11  7:08           ` Jim Porter
  0 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2024-02-11  6:07 UTC (permalink / raw)
  To: Jim Porter; +Cc: 68881, juri

> Date: Sat, 10 Feb 2024 13:14:34 -0800
> Cc: 68881@debbugs.gnu.org, juri@linkov.net
> From: Jim Porter <jporterbugs@gmail.com>
> 
> On 2/10/2024 11:23 AM, Eli Zaretskii wrote:
> > I don't understand what text directionality has to do with the issue
> > at hand.  If you elaborate, I could perhaps be of assistance in this
> > matter.
> 
> I think nothing in this case. I just wasn't sure initially whether 
> 'pos-bol' and 'line-beginning-position' handled directionality 
> differently. Since they handle it the same way, I think there's no harm 
> in using 'pos-bol' in this case.

They both go to the smallest buffer position of the line (modulo the
fields issue).  If an LTR line starts with RTL characters, that buffer
position will not be the leftmost one, but that's all.  (I don't think
we have a function to go to the position that is the leftmost on
display, probably because that was never needed.)





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#68881: 30.0.50; [PATCH] Field properties confuse 'outline-minor-mode'
  2024-02-11  6:07         ` Eli Zaretskii
@ 2024-02-11  7:08           ` Jim Porter
  0 siblings, 0 replies; 11+ messages in thread
From: Jim Porter @ 2024-02-11  7:08 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 68881, juri

On 2/10/2024 10:07 PM, Eli Zaretskii wrote:
> They both go to the smallest buffer position of the line (modulo the
> fields issue).  If an LTR line starts with RTL characters, that buffer
> position will not be the leftmost one, but that's all.  (I don't think
> we have a function to go to the position that is the leftmost on
> display, probably because that was never needed.)

Looking further in the outline.el code, it seems that RTL support is 
handled elsewhere, so as far as I can tell (as a non-RTL user), 
everything's good on the text directionality front.





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#68881: 30.0.50; [PATCH] Field properties confuse 'outline-minor-mode'
  2024-02-10 18:22   ` Jim Porter
  2024-02-10 19:23     ` Eli Zaretskii
@ 2024-02-11 17:40     ` Juri Linkov
  2024-02-11 18:19       ` Jim Porter
  1 sibling, 1 reply; 11+ messages in thread
From: Juri Linkov @ 2024-02-11 17:40 UTC (permalink / raw)
  To: Jim Porter; +Cc: 68881

>> There is also one occurrence of 'line-end-position' in outline.el.
>> Should it have 'inhibit-field-text-motion' as well?
>
> Thanks for the catch. Updated this as well.

Here is another catch:

> @@ -725,7 +725,7 @@ outline-insert-heading
>  		(not (string-match (concat "\\`\\(?:" outline-regexp "\\)")
>  				   (concat head " "))))
>        (setq head (concat head " ")))
> -    (unless (bolp) (end-of-line) (newline))
> +    (unless (bolp) (goto-char (pos-bol)) (newline))

This looks like a typo.





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#68881: 30.0.50; [PATCH] Field properties confuse 'outline-minor-mode'
  2024-02-11 17:40     ` Juri Linkov
@ 2024-02-11 18:19       ` Jim Porter
  2024-02-12 18:25         ` Juri Linkov
  0 siblings, 1 reply; 11+ messages in thread
From: Jim Porter @ 2024-02-11 18:19 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 68881

[-- Attachment #1: Type: text/plain, Size: 380 bytes --]

On 2/11/2024 9:40 AM, Juri Linkov wrote:
>> @@ -725,7 +725,7 @@ outline-insert-heading
>>   		(not (string-match (concat "\\`\\(?:" outline-regexp "\\)")
>>   				   (concat head " "))))
>>         (setq head (concat head " ")))
>> -    (unless (bolp) (end-of-line) (newline))
>> +    (unless (bolp) (goto-char (pos-bol)) (newline))
> 
> This looks like a typo.

So it is. Fixed.

[-- Attachment #2: 0001-Make-outline.el-ignore-field-properties-in-text.patch --]
[-- Type: text/plain, Size: 4687 bytes --]

From 6dc4b7802ef36a50647ebf2a1e9a1982fb9edbb3 Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Thu, 1 Feb 2024 13:58:20 -0800
Subject: [PATCH 1/4] Make outline.el ignore field properties in text

* lisp/outline.el (outline-back-to-heading, outline-on-heading-p)
(outline-next-visible-heading, outline-mark-subtree)
(outline-hide-sublevels, outline--insert-button)
(outline--fix-up-all-buttons): Inhibit field text motion (bug#68881).
---
 lisp/outline.el | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/lisp/outline.el b/lisp/outline.el
index b50708c1a7b..5ac0f0707f1 100644
--- a/lisp/outline.el
+++ b/lisp/outline.el
@@ -686,7 +686,7 @@ 'outline-before-first-heading
 (defun outline-back-to-heading (&optional invisible-ok)
   "Move to previous heading line, or beg of this line if it's a heading.
 Only visible heading lines are considered, unless INVISIBLE-OK is non-nil."
-  (beginning-of-line)
+  (forward-line 0)
   (or (outline-on-heading-p invisible-ok)
       (let (found)
 	(save-excursion
@@ -705,7 +705,7 @@ outline-on-heading-p
   "Return t if point is on a (visible) heading line.
 If INVISIBLE-OK is non-nil, an invisible heading line is ok too."
   (save-excursion
-    (beginning-of-line)
+    (forward-line 0)
     (and (bolp) (or invisible-ok (not (outline-invisible-p)))
 	 (if outline-search-function
              (funcall outline-search-function nil nil nil t)
@@ -725,7 +725,7 @@ outline-insert-heading
 		(not (string-match (concat "\\`\\(?:" outline-regexp "\\)")
 				   (concat head " "))))
       (setq head (concat head " ")))
-    (unless (bolp) (end-of-line) (newline))
+    (unless (bolp) (goto-char (pos-eol)) (newline))
     (insert head)
     (unless (eolp)
       (save-excursion (newline-and-indent)))
@@ -941,9 +941,7 @@ outline-next-visible-heading
 A heading line is one that starts with a `*' (or that
 `outline-regexp' matches)."
   (interactive "p")
-  (if (< arg 0)
-      (beginning-of-line)
-    (end-of-line))
+  (goto-char (if (< arg 0) (pos-bol) (pos-eol)))
   (let ((regexp (unless outline-search-function
                   (concat "^\\(?:" outline-regexp "\\)")))
         found-heading-p)
@@ -963,7 +961,7 @@ outline-next-visible-heading
                           (re-search-forward regexp nil 'move)))
 		  (outline-invisible-p (match-beginning 0))))
       (setq arg (1- arg)))
-    (if found-heading-p (beginning-of-line))))
+    (if found-heading-p (forward-line 0))))
 
 (defun outline-previous-visible-heading (arg)
   "Move to the previous heading line.
@@ -980,7 +978,7 @@ outline-mark-subtree
   (let ((beg))
     (if (outline-on-heading-p)
 	;; we are already looking at a heading
-	(beginning-of-line)
+        (forward-line 0)
       ;; else go back to previous heading
       (outline-previous-visible-heading 1))
     (setq beg (point))
@@ -1183,7 +1181,7 @@ outline-hide-sublevels
 		(cond
 		 (current-prefix-arg (prefix-numeric-value current-prefix-arg))
 		 ((save-excursion
-                    (beginning-of-line)
+                    (forward-line 0)
 		    (if outline-search-function
                         (funcall outline-search-function nil nil nil t)
                       (looking-at outline-regexp)))
@@ -1243,7 +1241,7 @@ outline-toggle-children
   (interactive)
   (save-excursion
     (outline-back-to-heading)
-    (if (not (outline-invisible-p (line-end-position)))
+    (if (not (outline-invisible-p (pos-eol)))
         (outline-hide-subtree)
       (outline-show-children)
       (outline-show-entry))))
@@ -1834,7 +1832,7 @@ outline--create-button-icons
 (defun outline--insert-button (type)
   (with-silent-modifications
     (save-excursion
-      (beginning-of-line)
+      (forward-line 0)
       (let ((icon (nth (if (eq type 'close) 1 0) outline--button-icons))
             (o (seq-find (lambda (o) (overlay-get o 'outline-button))
                          (overlays-at (point)))))
@@ -1842,7 +1840,7 @@ outline--insert-button
           (when (eq outline-minor-mode-use-buttons 'insert)
             (let ((inhibit-read-only t))
               (insert (apply #'propertize "  " (text-properties-at (point))))
-              (beginning-of-line)))
+              (forward-line 0)))
           (setq o (make-overlay (point) (1+ (point))))
           (overlay-put o 'outline-button t)
           (overlay-put o 'evaporate t))
@@ -1866,7 +1864,7 @@ outline--fix-up-all-buttons
     (when from
       (save-excursion
         (goto-char from)
-        (setq from (line-beginning-position))))
+        (setq from (pos-bol))))
     (outline-map-region
      (lambda ()
        (let ((close-p (save-excursion
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* bug#68881: 30.0.50; [PATCH] Field properties confuse 'outline-minor-mode'
  2024-02-11 18:19       ` Jim Porter
@ 2024-02-12 18:25         ` Juri Linkov
  2024-02-13  4:03           ` Jim Porter
  0 siblings, 1 reply; 11+ messages in thread
From: Juri Linkov @ 2024-02-12 18:25 UTC (permalink / raw)
  To: Jim Porter; +Cc: 68881

>>> @@ -725,7 +725,7 @@ outline-insert-heading
>>>   		(not (string-match (concat "\\`\\(?:" outline-regexp "\\)")
>>>   				   (concat head " "))))
>>>         (setq head (concat head " ")))
>>> -    (unless (bolp) (end-of-line) (newline))
>>> +    (unless (bolp) (goto-char (pos-bol)) (newline))
>> This looks like a typo.
>
> So it is. Fixed.

Thanks.  I see no more problems.





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#68881: 30.0.50; [PATCH] Field properties confuse 'outline-minor-mode'
  2024-02-12 18:25         ` Juri Linkov
@ 2024-02-13  4:03           ` Jim Porter
  0 siblings, 0 replies; 11+ messages in thread
From: Jim Porter @ 2024-02-13  4:03 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 68881-done

On 2/12/2024 10:25 AM, Juri Linkov wrote:
>>>> @@ -725,7 +725,7 @@ outline-insert-heading
>>>>    		(not (string-match (concat "\\`\\(?:" outline-regexp "\\)")
>>>>    				   (concat head " "))))
>>>>          (setq head (concat head " ")))
>>>> -    (unless (bolp) (end-of-line) (newline))
>>>> +    (unless (bolp) (goto-char (pos-bol)) (newline))
>>> This looks like a typo.
>>
>> So it is. Fixed.
> 
> Thanks.  I see no more problems.

Thanks. Merged as d570864bebf, so closing this now.

(I'll file a new bug later for adding outline-minor-mode support to 
Eshell once I've worked out all the remaining issues.)





^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-02-13  4:03 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-01 23:51 bug#68881: 30.0.50; [PATCH] Field properties confuse 'outline-minor-mode' Jim Porter
2024-02-07 17:37 ` Juri Linkov
2024-02-10 18:22   ` Jim Porter
2024-02-10 19:23     ` Eli Zaretskii
2024-02-10 21:14       ` Jim Porter
2024-02-11  6:07         ` Eli Zaretskii
2024-02-11  7:08           ` Jim Porter
2024-02-11 17:40     ` Juri Linkov
2024-02-11 18:19       ` Jim Porter
2024-02-12 18:25         ` Juri Linkov
2024-02-13  4:03           ` Jim Porter

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).