all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: Psionic K <psionik@positron.solutions>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] Unindentation fixup for code blocks
Date: Sun, 21 Jan 2024 12:04:53 +0000	[thread overview]
Message-ID: <874jf6hoyi.fsf@localhost> (raw)
In-Reply-To: <87o7dtkx8r.fsf@localhost>

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

Ihor Radchenko <yantar92@posteo.net> writes:

> Thanks! This patch does apply.
> I am not yet sure if I like this patch or the previous one more. I am
> thinking about combining them and implementing something like
> `org-move-to-text-column'.

I do not see immediate use of `org-move-to-text-column', so let's keep
things simple.

I am attaching an amended patch with modified commit message and
docstring describing the invisible text is accounted as visible.
I also added TINYCHANGE cookie as you do not appear to have FSF
copyright assignment.

Let me know if you want to make any changes to the new version of the
patch.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: v2-0001-org-do-remove-indentation-Ignore-invisible-text.patch --]
[-- Type: text/x-patch, Size: 1815 bytes --]

From b7eb76647395eac256602bdecaab4aea3ffbe68c Mon Sep 17 00:00:00 2001
Message-ID: <b7eb76647395eac256602bdecaab4aea3ffbe68c.1705838536.git.yantar92@posteo.net>
From: Psionik K <73710933+psionic-k@users.noreply.github.com>
Date: Wed, 10 Jan 2024 22:37:28 +0900
Subject: [PATCH v2] org-do-remove-indentation: Ignore invisible text

* lisp/org-macs.el (org-do-remove-indentation): Set
`buffer-invisibility-spec' to nil before detecting the column or
moving to a column.

This fixes src_block indentation removal for org-modern-mode but will
also correct other cases of hidden indentation.

TINYCHANGE
---
 lisp/org-macs.el | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lisp/org-macs.el b/lisp/org-macs.el
index 8def5cbb2..fc4fd7975 100644
--- a/lisp/org-macs.el
+++ b/lisp/org-macs.el
@@ -388,6 +388,8 @@ (defmacro org-current-text-indentation ()
 
 (defun org-do-remove-indentation (&optional n skip-fl)
   "Remove the maximum common indentation from the buffer.
+Do not consider invisible text when calculating indentation.
+
 When optional argument N is a positive integer, remove exactly
 that much characters from indentation, if possible.  When
 optional argument SKIP-FL is non-nil, skip the first
@@ -408,7 +410,8 @@ (defun org-do-remove-indentation (&optional n skip-fl)
 	;; Remove exactly N indentation, but give up if not possible.
         (when skip-fl (forward-line))
 	(while (not (eobp))
-	  (let ((ind (progn (skip-chars-forward " \t") (current-column))))
+	  (let* ((buffer-invisibility-spec nil) ; do not treat invisible text specially
+                 (ind (progn (skip-chars-forward " \t") (current-column))))
 	    (cond ((< ind n)
                    (if (eolp) (delete-region (line-beginning-position) (point))
                      (throw :exit nil)))
-- 
2.43.0


[-- Attachment #3: Type: text/plain, Size: 224 bytes --]


-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

  reply	other threads:[~2024-01-21 12:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-10  9:20 [PATCH] Unindentation fixup for code blocks Psionic K
2024-01-10 12:28 ` Ihor Radchenko
2024-01-10 13:55   ` Psionic K
2024-01-10 15:45     ` Ihor Radchenko
2024-01-21 12:04       ` Ihor Radchenko [this message]
2024-03-12 12:26         ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874jf6hoyi.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=psionik@positron.solutions \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.