emacs-orgmode
[Top][All Lists]
Advanced

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

[O] Bugs in org-cycle-internal-local?


From: Rémi Vanicat
Subject: [O] Bugs in org-cycle-internal-local?
Date: Mon, 17 Dec 2012 22:43:52 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux)

Hello,

I've tried to use visibility cycling in outline minor mode[1] with ruby,
and I've a problem with when hiding some subtree: when the next subtree
on the same level begin with space char, its heading is put on the same
line than the current one:

Something like:

  def get(info, attr, default=nil)

  end

  def initialize

become

  def get(info, attr, default=nil)... def initialize

when I expect
  def get(info, attr, default=nil)...
  def initialize

The problem seem to come from the org-cycle-internal-local function that
wrongly put the end of the subtree in the middle of a line, if the
beginning of this line is all white character.






Here is the code I use to setup ruby-mode for interesting integration
with outline-minor-mode and org cycling facilities:

#+begin_src emacs-lisp
  (defvar my-ruby-outline-regexp "### \\| *def\\>\\| *module\\>\\| *class\\>")

  (defun my-ruby-outline-level ()
    "compute the level of a outline for ruby"
    (save-match-data
     (cond
       ((looking-at "###") 1)
       ((looking-at "\\( *\\)")
        (+ 2 (length (match-string 1)))))))

  (defun define-ruby-outline ()
    (make-local-variable 'outline-regexp)
    (setq outline-regexp my-ruby-outline-regexp)
    (make-local-variable 'outline-level)
    (setq outline-level #'my-ruby-outline-level)
    (outline-minor-mode))

  (add-hook 'ruby-mode-hook 'define-ruby-outline)

  (eval-after-load 'outline
    '(progn
      (define-key outline-minor-mode-map [(control tab)] 'org-cycle)
      (define-key outline-minor-mode-map [(backtab)] 'org-global-cycle)))
#+end_src



[1]:http://orgmode.org/worg/org-faq.html#use-visibility-cycling-in-outline-mode

-- 
Rémi Vanicat




reply via email to

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