Search code examples
emacsorg-mode

Does org-mode solve these 5 `hi-lock` problems?


For very many reference files, I am rather addicted to the combination of hi-lock, text-mode, and the very plain utility of TABs.

Here is a simple example. The file

hi-lock: (("===^^^===" (0 (quote compilation-line-number) t)))
hi-lock: (("http.?://.*" (0 (quote browse-url-button) t)))
===^^^===

===^^^===
Flutter Navigation
    Routes and Navigation
        Navigator       https://api.flutter.dev/flutter/widgets/Navigator-class.html
        Named Routes        https://docs.flutter.dev/cookbook/navigation/named-routes
===^^^===
etc..
===^^^===

renders as follows.

hi-lock and text-mode on Emacs

This works nicely.

  • I can insert lines to highlight the divisions between sections.
  • I see HTTP links clearly highlighted (even if I still need to cut-and-paste to access them).
  • The TABs, as mentioned, provide adequate "section" and "subsection" semantics.
  • It's just text. This is not a trivial advantage, because my OS (macOS) indexes .txt files. There might be a way to nudge it to index other extensions. Still, the commands of any other file formats (as with, notably, LaTeX) will get in the way.

But there are also several problems.

  • I need to manually maintain (an otherwise unnecessary) hi-lock header for each file.
  • I need to maintain regular expressions (though this can be fun for tricky cases).
  • The semantics of hi-lock are dubious. (Why is compilation-line-number chosen for a separating line?)
  • Maintaining a reasonable color scheme becomes difficult after a few colors.
  • Maintaining indentation with TABs is laborious (as you can see from the misalignment of the URLs).

Does org-mode solve these problems while maintaining the advantages of text-mode and hi-lock?

If you're comfortable with ORG, I would particularly like to see how the snippet above can be rendered in an equally—or better—looking way using ORG.

Related:


Solution

  • The spirit of the question is:

    1. I couldn't be bothered to write configurations so frequently.
    2. I'm seeking the largest signal-to-noise ratio.

    The following is a remedy (working) solution, on the path to migrating to org-mode from a combination of text-mode and hi-lock.

    Using the following .emacs file.

    (add-to-list 'default-frame-alist '(background-color . "black"))
    (add-to-list 'default-frame-alist '(foreground-color . "white"))
    (set-frame-font "-*-*-medium-r-normal--24-*-*-*-*-*-*-*")
    
    (setq org-startup-indented t)
    (require 'org-superstar)
    (add-hook 'org-mode-hook (lambda () (org-superstar-mode 1)))
    

    The following lines

    * Flutter Navigation
    ** Routes and Navigation
    - Navigator     https://api.flutter.dev/flutter/widgets/Navigator-class.html
    - Named Routes  https://docs.flutter.dev/cookbook/navigation/named-routes
    
    * etc..
    

    render as follows.

    Rendered org-mode frame

    Though this addresses neither the separating lines nor the tabs.

    Separating lines are easy, if they're meant for the output (PDF, etc) rather for the Emacs display itself.

    Also...

    • Open URLs with the system-wide browser ( 1, 2).