Git Product home page Git Product logo

Comments (7)

minad avatar minad commented on August 20, 2024

That's not possible since the source block bracket is displayed in the fringe, we cannot indent that. You may want to disable block styling or try @jdtsmith's org-modern-indent package. Maybe we can also merge back some code from there such that indented source blocks and org-indent-mode work better.

from org-modern.

stardiviner avatar stardiviner commented on August 20, 2024

That's not possible since the source block bracket is displayed in the fringe, we cannot indent that.

I see. Thanks for answering.

You may want to disable block styling or try @jdtsmith's org-modern-indent package.

I tried the org-modern-indent mode. It does not indent the spaces before the source block. It works for org-indent-mode and put fringe line to source block ahead which looks more elegant and better.

Maybe we can also merge back some code from there such that indented source blocks and org-indent-mode work better.

If you merge this org-modern-indent style. I think keeping spaces before source block is possible. But I don't know whether it's complicated. If so, maybe not worth implemented my needs.

Regards,
stardiviner.

from org-modern.

stardiviner avatar stardiviner commented on August 20, 2024

As a record note.

I change the space in org-modern--block-fringe function like bellowing:

modified   org-modern.el
@@ -468,51 +468,51 @@ You can specify a font `:family'. The font families `Iosevka', `Hack' and
                                         (if (= 0 (mod i 2)) sp1 sp2)))))))))
 
 (defun org-modern--block-fringe ()
   "Prettify blocks with fringe bitmaps."
   ;; Do not add source block fringe markers if org-indent-mode is
   ;; enabled. org-indent-mode uses line prefixes for indentation.
   ;; Therefore we cannot have both.
   (unless (bound-and-true-p org-indent-mode)
     (save-excursion
       (goto-char (match-beginning 0))
       (add-text-properties
        (point) (min (line-end-position) (point-max))
        '(wrap-prefix
-         #(" " 0 1 (display (left-fringe org-modern--block-begin org-block-begin-line)))
+         #("    " 0 1 (display (left-fringe org-modern--block-begin org-block-begin-line)))
          line-prefix
-         #(" " 0 1 (display (left-fringe org-modern--block-begin org-block-begin-line)))))
+         #("    " 0 1 (display (left-fringe org-modern--block-begin org-block-begin-line)))))
       (forward-line)
       (while
           (cond
            ((eobp) nil)
            ((save-excursion
               (let ((case-fold-search t))
                 (re-search-forward
                  "^[ \t]*#\\+end_" (line-end-position) 'noerror)))
             (add-text-properties
              (point) (min (line-end-position) (point-max))
              '(wrap-prefix
-               #(" " 0 1 (display (left-fringe org-modern--block-end org-block-begin-line)))
+               #("    " 0 1 (display (left-fringe org-modern--block-end org-block-begin-line)))
                line-prefix
-               #(" " 0 1 (display (left-fringe org-modern--block-end org-block-begin-line)))))
+               #("    " 0 1 (display (left-fringe org-modern--block-end org-block-begin-line)))))
             nil)
            (t
             (add-text-properties
              (point) (min (1+ (line-end-position)) (point-max))
              '(wrap-prefix
-               #(" " 0 1 (display (left-fringe org-modern--block-inner org-block-begin-line)))
+               #("    " 0 1 (display (left-fringe org-modern--block-inner org-block-begin-line)))
                line-prefix
-               #(" " 0 1 (display (left-fringe org-modern--block-inner org-block-begin-line)))))
+               #("    " 0 1 (display (left-fringe org-modern--block-inner org-block-begin-line)))))
             (forward-line)
             t))))))

Then the block looks like this:

image

Need to study org-modern-indent source code.

from org-modern.

jdtsmith avatar jdtsmith commented on August 20, 2024

Maybe we can also merge back some code from there such that indented source blocks and org-indent-mode work better.

Perfectly happy to go this route and point people here. BTW, I also need to disable org-modern-hide-stars since it reduces heading indentation with org-indent, so perhaps that could be improved.

Note that org-modern-indent does rely on org-indent, since the latter sets a line-prefix which org-modern-indent tweaks.

The problem with "indenting myself with spaces" is what do you do with:

   #+begin_example
Not indented
   #+end_example

IMO the correct thing is, e.g.:

image

from org-modern.

minad avatar minad commented on August 20, 2024

@jdtsmith Uuuh. I don't know how to handle such a weird indentation but the example looks off. I think the border should be indented as deep as the begin/end keywords. I am glad that I don't have these issues with the fringe. πŸ˜…

from org-modern.

stardiviner avatar stardiviner commented on August 20, 2024

@minad Is it possible to use indentation spaces length from original block and pass them as variable into block styling function. And it will display like my upper screenshot. (I know this space gaps looks not fit intuition as fringe. Maybe provide an user custom option to toggle this behavior, and keep it disabled by default. WDYT?)

from org-modern.

jdtsmith avatar jdtsmith commented on August 20, 2024

@jdtsmith Uuuh. I don't know how to handle such a weird indentation but the example looks off. I think the border should be indented as deep as the begin/end keywords. I am glad that I don't have these issues with the fringe. πŸ˜…

Notice the arrow; where does that go? To treat hand-indented blocks you’d have to calculate the indent by examining the full block! So I don’t think @stardiviner’s request is that easy.

from org-modern.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.