From: "Sébastien Miquel" <sebastien.miquel@posteo.eu>
To: Greg Minshall <minshall@umich.edu>
Cc: org-mode-email <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] extra space at the end of lines in source
Date: Wed, 23 Jun 2021 17:29:42 +0000 [thread overview]
Message-ID: <c91cb5f1-44ff-f29b-b63d-7024d130f78a@posteo.eu> (raw)
In-Reply-To: <2701993.1624421325@apollo2.minshall.org>
[-- Attachment #1: Type: text/plain, Size: 768 bytes --]
Greg Minshall writes:
> - the next time i open the Org Src buffer, whatever lint-like process is
> running for that language may complain about extra spaces at the end
> of a line. (does that mean my experience is different from yours, or
> at least from your expectation?)
If I try your original examples with `emacs -q' I do not get extra
whitespace in
the org src buffer. Those two spaces in the original org buffer -- that
are due
to `org-edit-src-content-indentation' -- are removed in the org src
buffer. If
you do not find it to be the case, then I'm missing something.
Anyway, here's a patch that cleans up blank lines, except the current
one. It
preserves the fix for the original issue.
Can you try it out ?
Regards,
--
Sébastien Miquel
[-- Attachment #2: 0001-org-src.el-org-src-contents-for-write-back-Do-not-in.patch --]
[-- Type: text/x-patch, Size: 2600 bytes --]
From 405c2be7487c564e72a9f01a940f96dc19ff16ad Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Miquel?= <sebastien.miquel@posteo.eu>
Date: Wed, 23 Jun 2021 15:25:58 +0200
Subject: [PATCH] org-src.el (org-src--contents-for-write-back): Do not indent
blank lines
* lisp/org-src.el (org-src--contents-for-write-back): Do not indent
blank lines, except for the current line.
This was the original behaviour for all blank lines, before `857ae366b3`.
---
lisp/org-src.el | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/lisp/org-src.el b/lisp/org-src.el
index 79f002e56..faacb53e3 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -443,14 +443,20 @@ Assume point is in the corresponding edit buffer."
0))))
(use-tabs? (and (> org-src--tab-width 0) t))
(source-tab-width org-src--tab-width)
- (contents (org-with-wide-buffer (buffer-string)))
- (write-back org-src--allow-write-back))
+ (contents (org-with-wide-buffer
+ (let ((eol (progn (end-of-line) (point))))
+ (list (buffer-substring (point-min) eol)
+ (buffer-substring eol (point-max))))))
+ (write-back org-src--allow-write-back)
+ marker)
(with-current-buffer write-back-buf
;; Reproduce indentation parameters from source buffer.
(setq indent-tabs-mode use-tabs?)
(when (> source-tab-width 0) (setq tab-width source-tab-width))
;; Apply WRITE-BACK function on edit buffer contents.
- (insert (org-no-properties contents))
+ (insert (org-no-properties (car contents)))
+ (setq marker (point-marker))
+ (insert (org-no-properties (car (cdr contents))))
(goto-char (point-min))
(when (functionp write-back) (save-excursion (funcall write-back)))
;; Add INDENTATION-OFFSET to every line in buffer,
@@ -458,10 +464,13 @@ Assume point is in the corresponding edit buffer."
(when (> indentation-offset 0)
(while (not (eobp))
(skip-chars-forward " \t")
- (let ((i (current-column)))
- (delete-region (line-beginning-position) (point))
- (indent-to (+ i indentation-offset)))
- (forward-line))))))
+ (when (or (not (eolp)) ; ignore blank lines
+ (eq (point) (marker-position marker)))
+ (let ((i (current-column)))
+ (delete-region (line-beginning-position) (point))
+ (indent-to (+ i indentation-offset))))
+ (forward-line)))
+ (set-marker marker nil))))
(defun org-src--edit-element
(datum name &optional initialize write-back contents remote)
--
2.32.0
next prev parent reply other threads:[~2021-06-23 17:30 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-22 11:35 extra space at the end of lines in source Greg Minshall
2021-06-22 13:45 ` Sébastien Miquel
2021-06-22 19:21 ` Greg Minshall
2021-06-22 21:00 ` Sébastien Miquel
2021-06-23 4:08 ` Greg Minshall
2021-06-23 6:08 ` Tim Cross
2021-06-23 17:29 ` Sébastien Miquel [this message]
2021-06-24 8:55 ` [PATCH] " Greg Minshall
2021-06-26 8:37 ` Sébastien Miquel
2021-06-26 15:53 ` Greg Minshall
2021-07-10 14:27 ` Greg Minshall
2021-09-26 5:48 ` Bastien
2021-09-26 13:40 ` Greg Minshall
2021-06-22 23:56 ` Tim Cross
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
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c91cb5f1-44ff-f29b-b63d-7024d130f78a@posteo.eu \
--to=sebastien.miquel@posteo.eu \
--cc=emacs-orgmode@gnu.org \
--cc=minshall@umich.edu \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.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).