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

Fix error when calling org-overview #46

Merged
merged 1 commit into from Sep 10, 2015
Merged

Conversation

kaushalmodi
Copy link
Contributor

When org-overview or similar commands were called which then call
outline-hide-sublevels, the command wasn't getting executed because
it gave an error saying "Before First Headline". The issue was seen if
the org file had prelude code as below

  #+STARTUP: indent
  * First headline

The error was issued when calling the hide-subtree function inside
outline-hide-sublevels. The issue is resolved by this fix.

When `org-overview` or similar commands were called which then call
`outline-hide-sublevels`, the command wasn't getting executed because
it gave an error saying "Before First Headline". The issue was seen if
the org file had prelude code as below

      #+STARTUP: indent
      * First headline

The error was issued when calling the `hide-subtree` function inside
`outline-hide-sublevels`. The issue is resolved by this fix.
@kaushalmodi
Copy link
Contributor Author

I haven't done a through study of why the outline functions are being overridden in this package.

But as of the current emacs 25.0 build from the trunk, the outline-hide-sublevels function is defined as below:

(defun outline-hide-sublevels (levels)
  "Hide everything but the top LEVELS levels of headers, in whole buffer."
  (interactive (list
        (cond
         (current-prefix-arg (prefix-numeric-value current-prefix-arg))
         ((save-excursion (beginning-of-line)
                  (looking-at outline-regexp))
          (funcall outline-level))
         (t 1))))
  (if (< levels 1)
      (error "Must keep at least one level of headers"))
  (save-excursion
    (let* (outline-view-change-hook
           (beg (progn
                  (goto-char (point-min))
                  ;; Skip the prelude, if any.
                  (unless (outline-on-heading-p t) (outline-next-heading))
                  (point)))
           (end (progn
                  (goto-char (point-max))
                  ;; Keep empty last line, if available.
                  (if (bolp) (1- (point)) (point)))))
      (if (< end beg)
      (setq beg (prog1 end (setq end beg))))
      ;; First hide everything.
      (outline-flag-region beg end t)
      ;; Then unhide the top level headers.
      (outline-map-region
       (lambda ()
     (if (<= (funcall outline-level) levels)
         (outline-show-heading)))
       beg end)
      ;; Finally unhide any trailing newline.
      (goto-char (point-max))
      (if (and (bolp) (not (bobp)) (outline-invisible-p (1- (point))))
          (outline-flag-region (1- (point)) (point) nil))))
  (run-hooks 'outline-view-change-hook))

This original definition already has a fix to this issue.

tj64 added a commit that referenced this pull request Sep 10, 2015
Fix error when calling `org-overview`
@tj64 tj64 merged commit e9f4366 into tj64:master Sep 10, 2015
@tj64
Copy link
Owner

tj64 commented Sep 10, 2015

Hi, thanks for the patch, and sorry for my very late reaction. Now I did it again - apply a patch without testing, but my gut feeling tells me it should be ok ;-)
Let me know if problems arise.

@kaushalmodi
Copy link
Contributor Author

Thanks for merging.

I have been using my forked outshine version ever since I submitted that
patch and everything has been fine related to that fix :).

I use outshine daily on the latest master branch versions of emacs and
org-mode.
On Sep 10, 2015 3:27 PM, "Thorsten" notifications@github.com wrote:

Hi, thanks for the patch, and sorry for my very late reaction. Now I did
it again - apply a patch without testing, but my gut feeling tells me it
should be ok ;-)
Let me know if problems arise.


Reply to this email directly or view it on GitHub
#46 (comment).

@tj64
Copy link
Owner

tj64 commented Sep 10, 2015

Ok, great, then everything should be fine.
Thanks to you!

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

Successfully merging this pull request may close these issues.

None yet

3 participants