[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [BUG] Source block indentation does not work properly for yaml-mode
From: |
Ihor Radchenko |
Subject: |
Re: [BUG] Source block indentation does not work properly for yaml-mode [9.6.6 ( @ /home/user/.emacs.d/elpa/org-9.6.6/)] |
Date: |
Wed, 28 Jun 2023 09:21:28 +0000 |
Sébastien Miquel <sebastien.miquel@posteo.eu> writes:
> Here are two patches, the first that removes the special case logic
> for LaTeX fragments, and the second that implements what you suggest,
> and applies on top of the first one. Does that look ok to you ?
Thanks!
> + ;; Apply WRITE-BACK function on edit buffer contents.
> + (goto-char (point-min))
> + (when (functionp write-back) (save-excursion (funcall write-back)))
> (set-marker marker nil))))
`save-excursion' is no longer necessary here.
> (defun org-src--edit-element
> @@ -1150,7 +1149,14 @@ Throw an error when not at such a table."
> (lambda ()
> ;; Blank lines break things, replace with a single newline.
> (while (re-search-forward "\n[ \t]*\n" nil t) (replace-match "\n"))
> - ;; If within a table a newline would disrupt the structure,
> + ;; Trim contents.
It would be nice to have a bit more context about the purpose in the
comment here.
> Subject: [PATCH] org-src.el: Use native value of `indent-tabs-mode' for
> indentation
>
> * lisp/org-src.el (org-src--contents-for-write-back): Preserve the
> native indentation (spaces vs tabs). If necessary, add a common org
> indentation to the block according to org's `indent-tabs-mode'.
> (org-src-font-lock-fontify-block): In case of mixed indentation,
> display the tab characters with a fixed width, according to the native
> tab width value.
> * testing/lisp/test-org-src.el (test-org-src/indented-blocks): Update
> tests. Indentation no longer obeys `indent-tabs-mode' from the org
> buffer, but is separated in two parts.
> diff --git a/lisp/org-src.el b/lisp/org-src.el
> index 5c272c7f5..5a1030c42 100644
> --- a/lisp/org-src.el
> +++ b/lisp/org-src.el
> ...
> - (skip-chars-forward " \t")
> - (when (or (not (eolp)) ; not a blank
> line
> - (and (eq (point) (marker-position marker)) ; current line
> + (when (or (not (eolp)) ; not an empty line
> + ;; If the current line is empty, we may
> + ;; want to indent it.
> + (and (eq (point) (marker-position marker))
> preserve-blank-line))
Do we still need this dance with special case for current line?
> + ;; Display tab indentation characters preceded by spaces as spaces
> + (unless org-src-preserve-indentation
unless? Don't we rather want to preserve the original indentation
alignment when `org-src-preserve-indentation' is t?
> + (save-excursion
> + (goto-char start)
> + (while (re-search-forward "^[ ]+\\([\t]+\\)" end t)
Why just tabs at indentation? It would make sense to preserve width of
all the tabs.
> + (let* ((b (match-beginning 1))
> + (e (match-end 1))
> + (s (make-string (* (- e b) native-tab-width) ? )))
> + (add-text-properties b e `(display ,s))))))
Will the actual tab width be always equal to native-tab-width? What
about tab stops? May it be more reliable to use different of column
numbers in the src mode buffer after/before the tab?
> @@ -318,19 +318,21 @@ This is a tab:\t.
> argument2))
> #+END_SRC"
> (setq-local indent-tabs-mode t)
> - (let ((org-edit-src-content-indentation 2)
> + (let ((tab-width 8)
> + (org-edit-src-content-indentation 2)
Why is setting tab-width necessary? 8 is the default value.
> #+BEGIN_SRC emacs-lisp<point>
> - (progn\n (function argument1\n\t\targument2))
> + (progn\n (function argument1\n \targument2))
I think it would be a bit more readable to convert this string into
actual multi-line, where the alignment is visible when reading the test
source.
--
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>
- Re: [BUG] Source block indentation does not work properly for yaml-mode [9.6.6 ( @ /home/user/.emacs.d/elpa/org-9.6.6/)], (continued)
- Re: [BUG] Source block indentation does not work properly for yaml-mode [9.6.6 ( @ /home/user/.emacs.d/elpa/org-9.6.6/)], Sébastien Miquel, 2023/06/19
- Re: [BUG] Source block indentation does not work properly for yaml-mode [9.6.6 ( @ /home/user/.emacs.d/elpa/org-9.6.6/)], Ihor Radchenko, 2023/06/20
- Re: [BUG] Source block indentation does not work properly for yaml-mode [9.6.6 ( @ /home/user/.emacs.d/elpa/org-9.6.6/)], Sébastien Miquel, 2023/06/21
- Re: [BUG] Source block indentation does not work properly for yaml-mode [9.6.6 ( @ /home/user/.emacs.d/elpa/org-9.6.6/)], Ihor Radchenko, 2023/06/25
- Re: [BUG] Source block indentation does not work properly for yaml-mode [9.6.6 ( @ /home/user/.emacs.d/elpa/org-9.6.6/)], Sébastien Miquel, 2023/06/26
- Re: [BUG] Source block indentation does not work properly for yaml-mode [9.6.6 ( @ /home/user/.emacs.d/elpa/org-9.6.6/)], Sébastien Miquel, 2023/06/26
- Re: [BUG] Source block indentation does not work properly for yaml-mode [9.6.6 ( @ /home/user/.emacs.d/elpa/org-9.6.6/)], Ihor Radchenko, 2023/06/26
- Re: [BUG] Source block indentation does not work properly for yaml-mode [9.6.6 ( @ /home/user/.emacs.d/elpa/org-9.6.6/)], Sébastien Miquel, 2023/06/26
- Re: [BUG] Source block indentation does not work properly for yaml-mode [9.6.6 ( @ /home/user/.emacs.d/elpa/org-9.6.6/)], Ihor Radchenko, 2023/06/26
- Re: [BUG] Source block indentation does not work properly for yaml-mode [9.6.6 ( @ /home/user/.emacs.d/elpa/org-9.6.6/)], Sébastien Miquel, 2023/06/27
- Re: [BUG] Source block indentation does not work properly for yaml-mode [9.6.6 ( @ /home/user/.emacs.d/elpa/org-9.6.6/)],
Ihor Radchenko <=
- Re: [BUG] Source block indentation does not work properly for yaml-mode [9.6.6 ( @ /home/user/.emacs.d/elpa/org-9.6.6/)], Sébastien Miquel, 2023/06/29
- Re: [BUG] Source block indentation does not work properly for yaml-mode [9.6.6 ( @ /home/user/.emacs.d/elpa/org-9.6.6/)], Ihor Radchenko, 2023/06/30
- Re: [BUG] Source block indentation does not work properly for yaml-mode [9.6.6 ( @ /home/user/.emacs.d/elpa/org-9.6.6/)], Sébastien Miquel, 2023/06/30