emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Suggestion to increase usefulness of TAB key / 'org-cycle' function


From: Fraga, Eric
Subject: Re: Suggestion to increase usefulness of TAB key / 'org-cycle' function
Date: Fri, 28 Apr 2023 09:45:20 +0000
User-agent: gnus (Emacs 30.0.50)

Hi Philipp,

On Friday, 28 Apr 2023 at 10:49, Philipp Kiefer wrote:
> Well, it could simplify things a good deal further if, on issuing the
> command when point is *not* on a parent heading, (non-global)
> org-cycle would instead fold the subtree that point is in, i. e. do
> 'outline-up-heading' and 'hide-subtree' on the parent heading. 

You could always bind TAB to your own command that does this.  As an
illustration, I have TAB bound to my own function that invokes
completion instead unless I'm on an org heading!

--8<---------------cut here---------------start------------->8---
(defun esf/complete-or-indent ()
  (interactive)
  (cond
   ;; ((eq 'message-mode major-mode)
   ;;  (message-tab))
   ((and (eq 'message-mode major-mode)
         (message-point-in-header-p)
         (looking-back "^\\(To\\|B?[Cc]c\\): *.*" (line-beginning-position))) 
    (if (looking-back " ")
        (progn
          (message "try inserting alias abbrev")
          (insert (symbol-value (intern-soft (completing-read "Expand alias: " 
mail-abbrevs nil t) mail-abbrevs))))
      (progn
        (message "try eudc")
        (eudc-expand-try-all))))
   ((eq 'message-mode major-mode)
    (completion-at-point))
   ((org-table-p)
    (org-cycle))
   ((looking-back "[ \t\n]")
    (if (eq 'org-mode major-mode)
        (if (looking-back "^\\(\\*+ \\| *|\\)[^\\n]*")     ;a heading or table 
line
            (org-cycle)
          (indent-for-tab-command)
          )
      (indent-for-tab-command))
    )
   (t
    ;;(consult-company)
    (completion-at-point)
    )))
--8<---------------cut here---------------end--------------->8---

You could use a similar (and much simpler) approach to get what you
want.

HTH,
eric

-- 
: Eric S Fraga, with org release_9.6.4-335-ge065b5 in Emacs 30.0.50


reply via email to

[Prev in Thread] Current Thread [Next in Thread]