generalized outshine-sparse functions

This commit is contained in:
Thomas von Dein
2017-07-02 19:15:52 +02:00
parent 0f423fd7c6
commit 75f765f23b
2 changed files with 486 additions and 482 deletions

44
.emacs
View File

@@ -400,10 +400,14 @@
;; - Info mode: C-left+C-right history keys
;; - added loader for el2markdown
;; - removed smart-forward, it annoys me
;; - made tvd-outshine-jump more portable, do not use hardcoded
;; regexps anymore, use outshine functions
;; ** TODO
;; - fix C-c C-j to work in non-elisp buffers too, see FIXMEs there
;; and make it recursive like a path or the like
;; - check helpful https://github.com/wilfred/helpful
;; - check no-littering https://github.com/tarsius/no-littering
;; - submit novel + mark-copy-yank-things-mode to MELPA
@@ -1968,9 +1972,8 @@ col1, col2"
;; for config-general-mode (which inherits from conf-mode).
(add-hook 'config-general-mode-hook 'electric-indent-mode)
;; empty for now
(add-hook 'config-general-mode-hook '(lambda ()
t))
;; enable outshine
(add-hook 'config-general-mode-hook 'outline-minor-mode)
;; --------------------------------------------------------------------------------
;; ** Text Manupilation
@@ -2722,7 +2725,6 @@ down and unfold it, otherwise jump paragraph as usual."
org-fontify-done-headline t
org-pretty-entities t
org-confirm-babel-evaluate nil)
; shortcuts
(setq org-speed-commands-user
(quote (
@@ -2738,7 +2740,6 @@ down and unfold it, otherwise jump paragraph as usual."
("z" . org-refile) ; archive the (sub-)tree
("a" . org-attach) ; manage attachments
)))
; same as toggle
(local-set-key (kbd "C-t") 'org-todo)
@@ -3127,22 +3128,21 @@ specify another regex for cell splitting."
(add-hook 'emacs-lisp-mode-hook '(lambda ()
(outline-minor-mode)))
;; I do have my own outshine parser here. It generates an alist of all
;; headings with each position in buffer.
;; Generate an alist of all headings with each position in buffer and
;; use this later to jump to those positions with IDO.
(make-variable-buffer-local 'tvd-headings)
(defun tvd-outshine-is-heading-p (&optional line)
"return t if current line or LINE is a heading"
(tvd-starts-with (or line (tvd-get-line)) ";; *"))
(defun tvd-outshine-get-level (heading)
"return level of HEADING as number, or nil"
(if (string-match ";; \\(*+\\)" heading)
(length (match-string 1 heading))))
"Return level of HEADING as number, or nil"
(if (string-match " \\(*+\\) " heading) ; normal outline heading
(length (match-string 1 heading))
(when (string-match "^;;\\(;+\\) " heading) ; else look for elisp heading
(length (match-string 1 heading)))))
(defun tvd-outshine-cl-heading (heading)
"clean HEADING"
(replace-regexp-in-string ";; \\*+ " "" heading))
(let ((regex (cadar outshine-imenu-preliminary-generic-expression)))
(when (string-match regex heading)
(match-string-no-properties 1 heading))))
(defun tvd-outshine-parse-headings ()
"extract outshine headings of current buffer"
@@ -3153,7 +3153,7 @@ specify another regex for cell splitting."
(beginning-of-buffer)
(while (not (eobp))
(setq line (tvd-get-line))
(when (tvd-outshine-is-heading-p line)
(when (outline-on-heading-p t)
(add-to-list 'tvd-headings (cons (tvd-outshine-cl-heading line) (point))))
(forward-line)))))
@@ -3169,15 +3169,12 @@ specify another regex for cell splitting."
(setq l (tvd-outshine-get-level (tvd-get-line)))
(add-to-list 'tree (list (point) l))
(when (eq l 1)
(setq done t))
)
(setq done t)))
(outline-hide-other)
(dolist (pos tree)
(goto-char (car pos))
(outline-cycle))))
;; Using the functions above I now can just hit C-c C-j and IDO to
;; some heading, which is damn fast and great.
(defun tvd-outshine-jump ()
"jump to an outshine heading with IDO prompt,
update heading list if neccessary."
@@ -3210,6 +3207,11 @@ update heading list if neccessary."
("q" . widen)
)))))))
;; Narrowing now works within the headline rather than requiring to be on it
(advice-add 'outshine-narrow-to-subtree :before
(lambda (&rest args) (unless (outline-on-heading-p t)
(outline-previous-visible-heading 1))))
;; convert outshine buffer to org buffer using outorg, which is part
;; of outshine.
(defun outshine-to-org ()

File diff suppressed because it is too large Load Diff