org mode 时按tab,怎么设置只在children和folded之间切换


#1

大佬们,问个问题哈,默认的emacs 还有spacemacs这些,在org mode时,在headline,按tab时会在children,subtree,folded之间切换,

但是我用doom emacs的时候,按tab时只会在children和folded之间切换,

这个是怎么设置的呢?我想在spacemacs实现这个要怎么配置呀?


#2

用doom,在org-mode里面C-h k TAB,找到那个函数,抄之


#3

不对呀老哥,我之前也看了C-h k tab,

显示的函数是org-cycle,这个是org.el内置的函数


#4

那估计是org自带有变量控制这个行为


#5

刚刚翻了下doom emacs,这样就可以了

(defun +org-cycle-only-current-subtree-h (&optional arg)
  "Toggle the local fold at the point (as opposed to cycling through all levels
with `org-cycle')."
  (interactive "P")
  (unless (eq this-command 'org-shifttab)
    (save-excursion
      (org-beginning-of-line)
      (let (invisible-p)
        (when (and (org-at-heading-p)
                   (or org-cycle-open-archived-trees
                       (not (member org-archive-tag (org-get-tags))))
                   (or (not arg)
                       (setq invisible-p (outline-invisible-p (line-end-position)))))
          (unless invisible-p
            (setq org-cycle-subtree-status 'subtree))
          (org-cycle-internal-local)
          t)))))

(add-hook 'org-tab-first-hook #'+org-cycle-only-current-subtree-h t)