Headline-style converted back to old-school.

To confirm to the formatting requirements of package.el - and be able to add
outshine.el to MELPA - headlines were converted from 'org-style' to
'oldschool' and a few additional lines added.
master
tj 13 years ago
parent addb1cd34e
commit 84c19c17d7
  1. 92
      outshine.el

@ -4,7 +4,7 @@
;; Version: 1.0 ;; Version: 1.0
;; URL: https://github.com/tj64/outshine ;; URL: https://github.com/tj64/outshine
;; ;;
;; ** MetaData ;;;; MetaData
;; :PROPERTIES: ;; :PROPERTIES:
;; :copyright: Thorsten_Jolitz ;; :copyright: Thorsten_Jolitz
;; :copyright-from: 2013 ;; :copyright-from: 2013
@ -21,10 +21,18 @@
;; :git-clone: git://github.com/tj64/outshine.git ;; :git-clone: git://github.com/tj64/outshine.git
;; :END: ;; :END:
;; ** Commentary ;;;; Commentary
;; *** About outshine ;;;;; About outshine
;; [NOTE: For the sake of adding this library to MELPA, headlines had to be
;; converted back from 'Org-mode style' to 'oldschool', and a few extra lines
;; of required information had to be added on top of the MetaData section -
;; just to comply with the required file formatting. All outshine, outorg and
;; navi-mode functionality still works with this file. See my
;; [[https://github.com/tj64/iorg][iOrg]] repository for examples of
;; Emacs-Lisp and PicoLisp files structured 'the outshine way'.]
;; This library merges, modifies and extends two existing extension-libraries ;; This library merges, modifies and extends two existing extension-libraries
;; for `outline' (minor) mode: `outline-magic' (by Carsten Dominik) and ;; for `outline' (minor) mode: `outline-magic' (by Carsten Dominik) and
;; `out-xtra' (by Per Abrahamsen). It offers all the functionality of ;; `out-xtra' (by Per Abrahamsen). It offers all the functionality of
@ -47,7 +55,7 @@
;; in temporary Org-mode buffers) and `navi-mode.el' (fast navigation and ;; in temporary Org-mode buffers) and `navi-mode.el' (fast navigation and
;; remote-control via modified occur-buffers). ;; remote-control via modified occur-buffers).
;; *** Installation ;;;;; Installation
;; Download `outshine.el' and copy it to a location where Emacs can find it, ;; Download `outshine.el' and copy it to a location where Emacs can find it,
;; and use this in your '.emacs' to get started: ;; and use this in your '.emacs' to get started:
@ -103,29 +111,29 @@
;; or whatever. The prefix can only be changed before outline (minor) mode is ;; or whatever. The prefix can only be changed before outline (minor) mode is
;; loaded. ;; loaded.
;; *** Emacs Version ;;;;; Emacs Version
;; `outshine.el' works with [GNU Emacs 24.2.1 (x86_64-unknown-linux-gnu, GTK+ ;; `outshine.el' works with [GNU Emacs 24.2.1 (x86_64-unknown-linux-gnu, GTK+
;; Version 3.6.4) of 2013-01-20 on eric]. No attempts of testing with older ;; Version 3.6.4) of 2013-01-20 on eric]. No attempts of testing with older
;; versions or other types of Emacs have been made (yet). ;; versions or other types of Emacs have been made (yet).
;; ** ChangeLog ;;;; ChangeLog
;; | date | author(s) | version | ;; | date | author(s) | version |
;; |-----------------+-----------------+---------| ;; |-----------------+-----------------+---------|
;; | <2013-05-03 Fr> | Thorsten Jolitz | 1.0 | ;; | <2013-05-03 Fr> | Thorsten Jolitz | 1.0 |
;; | <2013-02-20 Mi> | Thorsten Jolitz | 0.9 | ;; | <2013-02-20 Mi> | Thorsten Jolitz | 0.9 |
;; * Requires ;;; Requires
(require 'outline) (require 'outline)
(require 'easymenu) (require 'easymenu)
;; necessary before Emacs 24.3 ;; necessary before Emacs 24.3
(require 'newcomment) (require 'newcomment)
;; * Variables ;;; Variables
;; ** Consts ;;;; Consts
(defconst outshine-version "1.0" (defconst outshine-version "1.0"
"outshine version number.") "outshine version number.")
@ -143,7 +151,7 @@ Used to override any major-mode specific file-local settings")
(defconst outshine-oldschool-elisp-outline-regexp-base "[;]+" (defconst outshine-oldschool-elisp-outline-regexp-base "[;]+"
"Oldschool Emacs Lisp base for calculating the outline-regexp") "Oldschool Emacs Lisp base for calculating the outline-regexp")
;; ** Vars ;;;; Vars
;; "\C-c" conflicts with other modes like e.g. ESS ;; "\C-c" conflicts with other modes like e.g. ESS
(defvar outline-minor-mode-prefix "\M-#" (defvar outline-minor-mode-prefix "\M-#"
@ -209,12 +217,12 @@ them set by set, separated by a nil element. See the example for
(make-variable-buffer-local (make-variable-buffer-local
'outshine-imenu-generic-expression) 'outshine-imenu-generic-expression)
;; ** Hooks ;;;; Hooks
(defvar outshine-hook nil (defvar outshine-hook nil
"Functions to run after `outshine' is loaded.") "Functions to run after `outshine' is loaded.")
;; ** Faces ;;;; Faces
;; from `org-compat.el' ;; from `org-compat.el'
(defun outshine-compatible-face (inherits specs) (defun outshine-compatible-face (inherits specs)
@ -369,8 +377,8 @@ any other entries, and any resulting duplicates will be removed entirely."
"Face used for level 8 headlines." "Face used for level 8 headlines."
:group 'outshine-faces) :group 'outshine-faces)
;; ** Customs ;;;; Customs
;; *** Custom Groups ;;;;; Custom Groups
(defgroup outshine nil (defgroup outshine nil
"Enhanced library for outline navigation in source code buffers." "Enhanced library for outline navigation in source code buffers."
@ -383,7 +391,7 @@ any other entries, and any resulting duplicates will be removed entirely."
:group 'outshine) :group 'outshine)
;; *** Custom Vars ;;;;; Custom Vars
(defcustom outshine-imenu-show-headlines-p t (defcustom outshine-imenu-show-headlines-p t
"Non-nil means use calculated outline-regexp for imenu." "Non-nil means use calculated outline-regexp for imenu."
@ -484,9 +492,9 @@ t Everywhere except in headlines"
"Suppress visibility-state-change messages when non-nil.") "Suppress visibility-state-change messages when non-nil.")
;; * Defuns ;;; Defuns
;; ** Functions ;;;; Functions
;; *** Define keys with fallback ;;;;; Define keys with fallback
;; copied and adapted from Alexander Vorobiev ;; copied and adapted from Alexander Vorobiev
;; http://www.mail-archive.com/emacs-orgmode@gnu.org/msg70648.html ;; http://www.mail-archive.com/emacs-orgmode@gnu.org/msg70648.html
@ -520,7 +528,7 @@ recover it by stripping off \"-map\" from KEYMAP name."
(call-interactively original-func) (call-interactively original-func)
(error nil))))))) (error nil)))))))
;; *** Normalize regexps ;;;;; Normalize regexps
;; from http://emacswiki.org/emacs/ElispCookbook#toc6 ;; from http://emacswiki.org/emacs/ElispCookbook#toc6
(defun outshine-chomp (str) (defun outshine-chomp (str)
@ -558,7 +566,7 @@ recover it by stripping off \"-map\" from KEYMAP name."
(setq outshine-normalized-outline-regexp-base (setq outshine-normalized-outline-regexp-base
(outshine-chomp outshine-outline-regexp-base)))) (outshine-chomp outshine-outline-regexp-base))))
;; *** Calculate outline-regexp and outline-level ;;;;; Calculate outline-regexp and outline-level
;; dealing with special case of oldschool headers in elisp (;;;+) ;; dealing with special case of oldschool headers in elisp (;;;+)
(defun outshine-modern-header-style-in-elisp-p (&optional buffer) (defun outshine-modern-header-style-in-elisp-p (&optional buffer)
@ -652,7 +660,7 @@ Based on `comment-start' and `comment-add'."
m-strg m-strg
""))))))) "")))))))
;; *** Set outline-regexp und outline-level ;;;;; Set outline-regexp und outline-level
(defun outshine-set-local-outline-regexp-and-level (defun outshine-set-local-outline-regexp-and-level
(start-regexp &optional fun end-regexp) (start-regexp &optional fun end-regexp)
@ -668,7 +676,7 @@ Set optionally `outline-level' to FUN and
(make-local-variable 'outline-heading-end-regexp) (make-local-variable 'outline-heading-end-regexp)
(setq outline-heading-end-regexp end-regexp))) (setq outline-heading-end-regexp end-regexp)))
;; *** Show number of lines in hidden body ;;;;; Show number of lines in hidden body
;; Calc and show line number of hidden body for all visible headlines ;; Calc and show line number of hidden body for all visible headlines
(defun outshine-write-hidden-lines-cookies () (defun outshine-write-hidden-lines-cookies ()
@ -730,7 +738,7 @@ Set optionally `outline-level' to FUN and
;; (add-hook 'outline-view-change-hook ;; (add-hook 'outline-view-change-hook
;; 'outshine-write-hidden-lines-cookies) ;; 'outshine-write-hidden-lines-cookies)
;; *** Return outline-string at given level ;;;;; Return outline-string at given level
(defun outshine-calc-outline-string-at-level (level) (defun outshine-calc-outline-string-at-level (level)
"Return outline-string at level LEVEL." "Return outline-string at level LEVEL."
@ -771,7 +779,7 @@ top-level heading first."
`(,(outshine-calc-outline-string-at-level (+ i 2)) . ,(+ i 2)) `(,(outshine-calc-outline-string-at-level (+ i 2)) . ,(+ i 2))
'APPEND)))) 'APPEND))))
;; *** Fontify the headlines ;;;;; Fontify the headlines
(defun outshine-fontify-headlines (outline-regexp) (defun outshine-fontify-headlines (outline-regexp)
;; (interactive) ;; (interactive)
@ -841,7 +849,7 @@ top-level heading first."
(,heading-7-regexp 1 'outshine-level-7 t) (,heading-7-regexp 1 'outshine-level-7 t)
(,heading-8-regexp 1 'outshine-level-8 t))))) (,heading-8-regexp 1 'outshine-level-8 t)))))
;; *** Outshine hook-function ;;;;; Outshine hook-function
(defun outshine-hook-function () (defun outshine-hook-function ()
"Add this function to outline-minor-mode-hook" "Add this function to outline-minor-mode-hook"
@ -870,8 +878,8 @@ top-level heading first."
;; ;; add this to your .emacs ;; ;; add this to your .emacs
;; (add-hook 'outline-minor-mode-hook 'outshine-hook-function) ;; (add-hook 'outline-minor-mode-hook 'outshine-hook-function)
;; *** Additional outline functions ;;;;; Additional outline functions
;; **** Functions from `outline-magic' ;;;;;; Functions from `outline-magic'
(defun outline-cycle-emulate-tab () (defun outline-cycle-emulate-tab ()
"Check if TAB should be emulated at the current position." "Check if TAB should be emulated at the current position."
@ -1029,9 +1037,9 @@ If yes, return this character."
(>= level 1000)) (>= level 1000))
;; ** Commands ;;;; Commands
;; *** Additional outline commands ;;;;; Additional outline commands
;; **** Commands from `out-xtra' ;;;;;; Commands from `out-xtra'
(defun outline-hide-sublevels (keep-levels) (defun outline-hide-sublevels (keep-levels)
"Hide everything except the first KEEP-LEVEL headers." "Hide everything except the first KEEP-LEVEL headers."
@ -1067,7 +1075,7 @@ If yes, return this character."
(show-children) (show-children)
(setq last (point))))))) (setq last (point)))))))
;; **** Commands from `outline-magic' ;;;;;; Commands from `outline-magic'
(defun outline-next-line () (defun outline-next-line ()
"Forward line, but mover over invisible line ends. "Forward line, but mover over invisible line ends.
@ -1278,7 +1286,7 @@ may have changed."
;; **** Commands from `outline-mode-easy-bindings' ;;;;;; Commands from `outline-mode-easy-bindings'
;; Copied from: http://emacswiki.org/emacs/OutlineMinorMode ;; Copied from: http://emacswiki.org/emacs/OutlineMinorMode
@ -1385,7 +1393,7 @@ may have changed."
(outshine-hide-hidden-lines-cookies) (outshine-hide-hidden-lines-cookies)
(outshine-show-hidden-lines-cookies))) (outshine-show-hidden-lines-cookies)))
;; *** Overridden outline commands ;;;;; Overridden outline commands
;; overriding 'outline-insert-heading' ;; overriding 'outline-insert-heading'
;; copied and adapted form outline.el, taking into account modes ;; copied and adapted form outline.el, taking into account modes
@ -1420,7 +1428,7 @@ This function takes `comment-end' into account."
(forward-char -1)) (forward-char -1))
(run-hooks 'outline-insert-heading-hook))) (run-hooks 'outline-insert-heading-hook)))
;; *** iMenu and idoMenu Support ;;;;; iMenu and idoMenu Support
(defun outshine-imenu-with-navi-regexp (defun outshine-imenu-with-navi-regexp
(kbd-key &optional PREFER-IMENU-P LAST-PARENTH-EXPR-P) (kbd-key &optional PREFER-IMENU-P LAST-PARENTH-EXPR-P)
@ -1524,7 +1532,7 @@ i.e. the text following the regexp match until the next space character."
"Headline: "))))) "Headline: ")))))
;; * Menus and Keybindings ;;; Menus and Keybindings
;; FIXME ;; FIXME
;; From: Stefan Monnier <monnier@iro.umontreal.ca> ;; From: Stefan Monnier <monnier@iro.umontreal.ca>
@ -1551,8 +1559,8 @@ i.e. the text following the regexp match until the next space character."
;; (lambda () (interactive) (if foo (CMD))), bind it to ;; (lambda () (interactive) (if foo (CMD))), bind it to
;; (menu-item "" CMD :filter (lambda (cmd) (if foo cmd))). ;; (menu-item "" CMD :filter (lambda (cmd) (if foo cmd))).
;; ** Menus ;;;; Menus
;; *** Advertise Bindings ;;;;; Advertise Bindings
(put 'outshine-insert-heading :advertised-binding [M-ret]) (put 'outshine-insert-heading :advertised-binding [M-ret])
(put 'outline-cycle :advertised-binding [?\t]) (put 'outline-cycle :advertised-binding [?\t])
@ -1569,7 +1577,7 @@ i.e. the text following the regexp match until the next space character."
(put 'outline-up-heading :advertised-binding [?\M-# ?\M-u]) (put 'outline-up-heading :advertised-binding [?\M-# ?\M-u])
(put 'outorg-edit-as-org :advertised-binding [?\M-# ?\M-#]) (put 'outorg-edit-as-org :advertised-binding [?\M-# ?\M-#])
;; *** Define Menu ;;;;; Define Menu
(easy-menu-define outshine-menu outline-minor-mode-map "Outshine menu" (easy-menu-define outshine-menu outline-minor-mode-map "Outshine menu"
'("Outshine" '("Outshine"
@ -1606,8 +1614,8 @@ i.e. the text following the regexp match until the next space character."
;; get rid of "Outline" menu item ;; get rid of "Outline" menu item
(define-key outline-minor-mode-map [menu-bar outline] 'undefined) (define-key outline-minor-mode-map [menu-bar outline] 'undefined)
;; ** Keybindings ;;;; Keybindings
;; *** Principal Keybindings ;;;;; Principal Keybindings
;; Adapted from `org-mode' and `outline-mode-easy-bindings' ;; Adapted from `org-mode' and `outline-mode-easy-bindings'
(let ((map outline-minor-mode-map)) (let ((map outline-minor-mode-map))
@ -1639,7 +1647,7 @@ i.e. the text following the regexp match until the next space character."
map (kbd "M-<down>") 'outline-next-visible-heading)) map (kbd "M-<down>") 'outline-next-visible-heading))
;; *** Other Keybindings ;;;;; Other Keybindings
;; Set the outline-minor-mode-prefix key in your init-file ;; Set the outline-minor-mode-prefix key in your init-file
;; before loading outline-mode ;; before loading outline-mode
@ -1680,7 +1688,7 @@ i.e. the text following the regexp match until the next space character."
(define-key map "\M-#" 'outorg-edit-as-org) (define-key map "\M-#" 'outorg-edit-as-org)
(define-key map "#" 'outorg-edit-as-org)) (define-key map "#" 'outorg-edit-as-org))
;; * Run hooks and provide ;;; Run hooks and provide
(run-hooks 'outshine-hook) (run-hooks 'outshine-hook)

Loading…
Cancel
Save