Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: item and value on the same line using org-columns #3

Open
piyo opened this issue Jan 25, 2020 · 0 comments
Open

feature request: item and value on the same line using org-columns #3

piyo opened this issue Jan 25, 2020 · 0 comments

Comments

@piyo
Copy link

piyo commented Jan 25, 2020

I don't use this package very much but I suggest showing the item and value on the same line. org makes this possible using the built-in org-columns.

I have made a modification that achieves this. The following code:

  • inserts metadata for org-columns rendering
  • tells org-mode to show all headers and subheaders ("content")
  • increases the depth by one
  • encodes the sysctl item value as a org-property ":VALUE:", for org-columns input.
  • moves the cursor back to the top of the buffer
(defun sysctl-construct-tree (lines-list)
  "Turn LINES-LIST into an org hierarchy."
  ;; org-columns formatting
  (insert "* sysctl\n")
  (insert ":PROPERTIES:\n"
          ":COLUMNS: %40ITEM(Item) %80VALUE(Value)" "\n"
          ":END:\n"
          "#+STARTUP: content\n")
  (let (path)
    (dolist (line lines-list)
      (let ((line-path (car line))
            (line-value (cdr line))
            (depth 1))
        (while line-path
          (unless (string= (nth (- depth 1) path)
                           (car line-path))
            (insert (concat (make-string (+ 1 depth) ?*) " " (car line-path) "\n"))
            (sysctl--readonly-previous-line))
          (setq line-path (cdr line-path)
                depth (1+ depth)))
        (setq path (car line))
        (insert (concat ":PROPERTIES:\n" ;; shown as org-property for org-column
                        ":VALUE: " line-value "\n"
                        ":END:\n")))))
 (goto-line 0))

How to use it:

  1. Redefine sysctl-construct-tree as shown above.
  2. M-x sysctl
  3. C-u C-c C-x C-c (org-columns) to turn on org-columns mode and show the item and value org-column overlay.
  4. Press q anywhere on the overlays to remove org-columns overlays.

Pros:

  • Able to see the item name and value on one line
  • Able to leverage org-columns editing mode

Cons:

  • Does not work for multi-line entries.
  • Not yet working for org-column editing mode

Tested on:

  • Emacs 26.1
  • org-plus-contrib 20191230 package
  • Debian 10 Linux x64

References:
https://orgmode.org/manual/Column-view.html
https://orgmode.org/worg/org-tutorials/org-column-view-tutorial.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant