| 38 | | ;; Some features: |
|---|
| 39 | | ;; |
|---|
| 40 | | ;; - classic outline-mode topic-oriented navigation and exposure adjustment |
|---|
| 41 | | ;; - topic-oriented editing including coherent topic and subtopic |
|---|
| 42 | | ;; creation, promotion, demotion, cut/paste across depths, etc |
|---|
| 43 | | ;; - incremental search with dynamic exposure and reconcealment of text |
|---|
| 44 | | ;; - customizable bullet format enbles programming-language specific |
|---|
| 45 | | ;; outlining, for ultimate code-folding editing. (allout code itself is |
|---|
| 46 | | ;; formatted as an outline - do ESC-x eval-current-buffer in allout.el |
|---|
| 47 | | ;; to try it out.) |
|---|
| 48 | | ;; - configurable per-file initial exposure settings |
|---|
| 49 | | ;; - symmetric-key and key-pair topic encryption, plus symmetric passphrase |
|---|
| | 34 | ;; - Classic outline-mode topic-oriented navigation and exposure adjustment |
|---|
| | 35 | ;; - Topic-oriented editing including coherent topic and subtopic |
|---|
| | 36 | ;; creation, promotion, demotion, cut/paste across depths, etc. |
|---|
| | 37 | ;; - Incremental search with dynamic exposure and reconcealment of text |
|---|
| | 38 | ;; - Customizable bullet format - enables programming-language specific |
|---|
| | 39 | ;; outlining, for code-folding editing. (Allout code itself is to try it; |
|---|
| | 40 | ;; formatted as an outline - do ESC-x eval-current-buffer in allout.el; but |
|---|
| | 41 | ;; emacs local file variables need to be enabled when the |
|---|
| | 42 | ;; file was visited - see `enable-local-variables'.) |
|---|
| | 43 | ;; - Configurable per-file initial exposure settings |
|---|
| | 44 | ;; - Symmetric-key and key-pair topic encryption, plus symmetric passphrase |
|---|
| 128 | | ;;;_ = allout-layout |
|---|
| 129 | | (defvar allout-layout nil |
|---|
| 130 | | "*Layout specification and provisional mode trigger for allout outlines. |
|---|
| 131 | | |
|---|
| 132 | | Buffer-specific. |
|---|
| 133 | | |
|---|
| 134 | | A list value specifies a default layout for the current buffer, to be |
|---|
| 135 | | applied upon activation of `allout-mode'. Any non-nil value will |
|---|
| 136 | | automatically trigger `allout-mode' \(provided `allout-init' has been called |
|---|
| 137 | | to enable this behavior). |
|---|
| 138 | | |
|---|
| 139 | | See the docstring for `allout-init' for details on setting up for |
|---|
| 140 | | auto-mode-activation, and for `allout-expose-topic' for the format of |
|---|
| 141 | | the layout specification. |
|---|
| 142 | | |
|---|
| 143 | | You can associate a particular outline layout with a file by setting |
|---|
| 144 | | this var via the file's local variables. For example, the following |
|---|
| 145 | | lines at the bottom of an Emacs Lisp file: |
|---|
| 146 | | |
|---|
| 147 | | ;;;Local variables: |
|---|
| 148 | | ;;;allout-layout: \(0 : -1 -1 0) |
|---|
| 149 | | ;;;End: |
|---|
| 150 | | |
|---|
| 151 | | will, modulo the above-mentioned conditions, cause the mode to be |
|---|
| 152 | | activated when the file is visited, followed by the equivalent of |
|---|
| 153 | | `\(allout-expose-topic 0 : -1 -1 0)'. \(This is the layout used for |
|---|
| 154 | | the allout.el, itself.) |
|---|
| | 129 | ;;;_ = allout-default-layout |
|---|
| | 130 | (defcustom allout-default-layout '(-2 : 0) |
|---|
| | 131 | "*Default allout outline layout specification. |
|---|
| | 132 | |
|---|
| | 133 | This setting specifies the outline exposure to use when |
|---|
| | 134 | `allout-layout' has the local value `t'. This docstring describes the |
|---|
| | 135 | layout specifications. |
|---|
| | 136 | |
|---|
| | 137 | A list value specifies a default layout for the current buffer, |
|---|
| | 138 | to be applied upon activation of `allout-mode'. Any non-nil |
|---|
| | 139 | value will automatically trigger `allout-mode', provided |
|---|
| | 140 | `allout-init' has been called to enable this behavior. |
|---|
| | 141 | |
|---|
| | 142 | The types of elements in the layout specification are: |
|---|
| | 143 | |
|---|
| | 144 | integer - dictate the relative depth to open the corresponding topic(s), |
|---|
| | 145 | where: |
|---|
| | 146 | - negative numbers force the topic to be closed before opening |
|---|
| | 147 | to the absolute value of the number, so all siblings are open |
|---|
| | 148 | only to that level. |
|---|
| | 149 | - positive numbers open to the relative depth indicated by the |
|---|
| | 150 | number, but do not force already opened subtopics to be closed. |
|---|
| | 151 | - 0 means to close topic - hide all subitems. |
|---|
| | 152 | : - repeat spec - apply the preceeding element to all siblings at |
|---|
| | 153 | current level, *up to* those siblings that would be covered by specs |
|---|
| | 154 | following the `:' on the list. Ie, apply to all topics at level but |
|---|
| | 155 | trailing ones accounted for by trailing specs. \(Only the first of |
|---|
| | 156 | multiple colons at the same level is honored - later ones are ignored.) |
|---|
| | 157 | * - completely exposes the topic, including bodies |
|---|
| | 158 | + - exposes all subtopics, but not the bodies |
|---|
| | 159 | - - exposes the body of the corresponding topic, but not subtopics |
|---|
| | 160 | list - a nested layout spec, to be applied intricately to its |
|---|
| | 161 | corresponding item(s) |
|---|
| | 162 | |
|---|
| | 163 | Examples: |
|---|
| | 164 | '(-2 : 0) |
|---|
| | 165 | Collapse the top-level topics to show their children and |
|---|
| | 166 | grandchildren, but completely collapse the final top-level topic. |
|---|
| | 167 | '(-1 () : 1 0) |
|---|
| | 168 | Close the first topic so only the immediate subtopics are shown, |
|---|
| | 169 | leave the subsequent topics exposed as they are until the second |
|---|
| | 170 | second to last topic, which is exposed at least one level, and |
|---|
| | 171 | completely close the last topic. |
|---|
| | 172 | '(-2 : -1 *) |
|---|
| | 173 | Expose children and grandchildren of all topics at current |
|---|
| | 174 | level except the last two; expose children of the second to |
|---|
| | 175 | last and completely expose the last one, including its subtopics. |
|---|
| | 176 | |
|---|
| | 177 | See `allout-expose-topic' for more about the exposure process. |
|---|
| 158 | | is modulo the setting of `allout-use-mode-specific-leader', which see.") |
|---|
| 159 | | (make-variable-buffer-local 'allout-layout) |
|---|
| | 181 | is modulo the setting of `allout-use-mode-specific-leader', which see." |
|---|
| | 182 | :type 'allout-layout-type |
|---|
| | 183 | :group 'allout) |
|---|
| | 184 | ;;;_ : allout-layout-type |
|---|
| | 185 | (define-widget 'allout-layout-type 'lazy |
|---|
| | 186 | "Allout layout format customization basic building blocks." |
|---|
| | 187 | :type '(repeat |
|---|
| | 188 | (choice (integer :tag "integer (<= zero is strict)") |
|---|
| | 189 | (const :tag ": (repeat prior)" :) |
|---|
| | 190 | (const :tag "* (completely expose)" *) |
|---|
| | 191 | (const :tag "+ (expose all offspring, headlines only)" +) |
|---|
| | 192 | (const :tag "- (expose topic body but not offspring)" -) |
|---|
| | 193 | (allout-layout-type :tag "<Nested layout>")))) |
|---|
| | 194 | |
|---|
| | 641 | ;;;_ = allout-layout nil |
|---|
| | 642 | (defvar allout-layout nil ; LEAVE GLOBAL VALUE NIL - see docstring. |
|---|
| | 643 | "Buffer-specific setting for allout layout. |
|---|
| | 644 | |
|---|
| | 645 | In buffers where this is non-nil \(and if `allout-init' has been run, to |
|---|
| | 646 | enable this behavior), `allout-mode' will be automatically activated. The |
|---|
| | 647 | layout dictated by the value will be used to set the initial exposure when |
|---|
| | 648 | `allout-mode' is activated. |
|---|
| | 649 | |
|---|
| | 650 | \*You should not setq-default this variable non-nil unless you want every |
|---|
| | 651 | visited file to be treated as an allout file.* |
|---|
| | 652 | |
|---|
| | 653 | The value would typically be set by a file local variable. For |
|---|
| | 654 | example, the following lines at the bottom of an Emacs Lisp file: |
|---|
| | 655 | |
|---|
| | 656 | ;;;Local variables: |
|---|
| | 657 | ;;;allout-layout: \(0 : -1 -1 0) |
|---|
| | 658 | ;;;End: |
|---|
| | 659 | |
|---|
| | 660 | dictate activation of `allout-mode' mode when the file is visited |
|---|
| | 661 | \(presuming allout-init was already run), followed by the |
|---|
| | 662 | equivalent of `\(allout-expose-topic 0 : -1 -1 0)'. \(This is |
|---|
| | 663 | the layout used for the allout.el source file.) |
|---|
| | 664 | |
|---|
| | 665 | `allout-default-layout' describes the specification format. |
|---|
| | 666 | `allout-layout' can additionally have the value `t', in which |
|---|
| | 667 | case the value of `allout-default-layout' is used.") |
|---|
| | 668 | (make-variable-buffer-local 'allout-layout) |
|---|
| | 669 | ;;;###autoload |
|---|
| | 670 | (put 'allout-layout 'safe-local-variable t) |
|---|
| | 671 | |
|---|
| 958 | | ;;;_ = allout-pre-was-isearching nil |
|---|
| 959 | | (defvar allout-pre-was-isearching nil |
|---|
| 960 | | "Cue for isearch-dynamic-exposure mechanism, implemented in |
|---|
| 961 | | allout-pre- and -post-command-hooks.") |
|---|
| 962 | | (make-variable-buffer-local 'allout-pre-was-isearching) |
|---|
| 963 | | ;;;_ = allout-isearch-prior-pos nil |
|---|
| 964 | | (defvar allout-isearch-prior-pos nil |
|---|
| 965 | | "Cue for isearch-dynamic-exposure tracking, used by |
|---|
| 966 | | `allout-isearch-expose'.") |
|---|
| 967 | | (make-variable-buffer-local 'allout-isearch-prior-pos) |
|---|
| 968 | | ;;;_ = allout-isearch-did-quit |
|---|
| 969 | | (defvar allout-isearch-did-quit nil |
|---|
| 970 | | "Distinguishes isearch conclusion and cancellation. |
|---|
| 971 | | |
|---|
| 972 | | Maintained by allout-isearch-abort \(which is wrapped around the real |
|---|
| 973 | | isearch-abort), and monitored by allout-isearch-expose for action.") |
|---|
| 974 | | (make-variable-buffer-local 'allout-isearch-did-quit) |
|---|
| 977 | | "Enable internal outline operations to alter read-only text." |
|---|
| 978 | | `(let ((was-inhibit-r-o inhibit-read-only)) |
|---|
| 979 | | (unwind-protect |
|---|
| 980 | | (progn |
|---|
| 981 | | (setq inhibit-read-only t) |
|---|
| 982 | | ,expr) |
|---|
| 983 | | (setq inhibit-read-only was-inhibit-r-o) |
|---|
| 984 | | ) |
|---|
| 985 | | ) |
|---|
| 986 | | ) |
|---|
| 987 | | ;;;_ = allout-undo-aggregation |
|---|
| 988 | | (defvar allout-undo-aggregation 30 |
|---|
| 989 | | "Amount of successive self-insert actions to bunch together per undo. |
|---|
| 990 | | |
|---|
| 991 | | This is purely a kludge variable, regulating the compensation for a bug in |
|---|
| 992 | | the way that `before-change-functions' and undo interact.") |
|---|
| 993 | | (make-variable-buffer-local 'allout-undo-aggregation) |
|---|
| | 1016 | "Enable internal outline operations to alter invisible text." |
|---|
| | 1017 | `(let ((inhibit-read-only t)) |
|---|
| | 1018 | ,expr)) |
|---|
| | 1019 | ;;;_ = allout-mode-hook |
|---|
| | 1020 | (defvar allout-mode-hook nil |
|---|
| | 1021 | "*Hook that's run when allout mode starts.") |
|---|
| | 1022 | ;;;_ = allout-overlay-category |
|---|
| | 1023 | (defvar allout-overlay-category nil |
|---|
| | 1024 | "Symbol for use in allout invisible-text overlays as the category.") |
|---|
| | 1025 | ;;;_ = allout-view-change-hook |
|---|
| | 1026 | (defvar allout-view-change-hook nil |
|---|
| | 1027 | "*Hook that's run after allout outline visibility changes.") |
|---|
| | 1028 | |
|---|
| | 1029 | ;;;_ = allout-outside-normal-auto-fill-function |
|---|
| | 1030 | (defvar allout-outside-normal-auto-fill-function nil |
|---|
| | 1031 | "Value of normal-auto-fill-function outside of allout mode. |
|---|
| | 1032 | |
|---|
| | 1033 | Used by allout-auto-fill to do the mandated normal-auto-fill-function |
|---|
| | 1034 | wrapped within allout's automatic fill-prefix setting.") |
|---|
| | 1035 | (make-variable-buffer-local 'allout-outside-normal-auto-fill-function) |
|---|
| | 1238 | ;;;_ > allout-set-overlay-category |
|---|
| | 1239 | (defun allout-set-overlay-category () |
|---|
| | 1240 | "Set the properties of the allout invisible-text overlay." |
|---|
| | 1241 | (setplist 'allout-overlay-category nil) |
|---|
| | 1242 | (put 'allout-overlay-category 'invisible 'allout) |
|---|
| | 1243 | (put 'allout-overlay-category 'evaporate t) |
|---|
| | 1244 | ;; XXX We use isearch-open-invisible *and* isearch-mode-end-hook. The |
|---|
| | 1245 | ;; latter would be sufficient, but it seems that a separate behavior - |
|---|
| | 1246 | ;; the _transient_ opening of invisible text during isearch - is keyed to |
|---|
| | 1247 | ;; presence of the isearch-open-invisible property - even though this |
|---|
| | 1248 | ;; property controls the isearch _arrival_ behavior. This is the case at |
|---|
| | 1249 | ;; least in emacs 21, 22.0, and xemacs 21.4. |
|---|
| | 1250 | (put 'allout-overlay-category 'isearch-open-invisible |
|---|
| | 1251 | 'allout-isearch-end-handler) |
|---|
| | 1252 | (if (featurep 'xemacs) |
|---|
| | 1253 | (put 'allout-overlay-category 'start-open t) |
|---|
| | 1254 | (put 'allout-overlay-category 'insert-in-front-hooks |
|---|
| | 1255 | '(allout-overlay-insert-in-front-handler))) |
|---|
| | 1256 | (if (featurep 'xemacs) |
|---|
| | 1257 | (progn (make-variable-buffer-local 'before-change-functions) |
|---|
| | 1258 | (add-hook 'before-change-functions |
|---|
| | 1259 | 'allout-before-change-handler)) |
|---|
| | 1260 | (put 'allout-overlay-category 'modification-hooks |
|---|
| | 1261 | '(allout-overlay-interior-modification-handler)))) |
|---|
| 1294 | | Encrypted Entries |
|---|
| 1295 | | |
|---|
| 1296 | | Outline mode supports easily togglable gpg encryption of topics, with |
|---|
| 1297 | | niceties like support for symmetric and key-pair modes, passphrase timeout, |
|---|
| 1298 | | passphrase consistency checking, user-provided hinting for symmetric key |
|---|
| 1299 | | mode, and auto-encryption of topics pending encryption on save. The aim is |
|---|
| 1300 | | to enable reliable topic privacy while preventing accidents like neglected |
|---|
| 1301 | | encryption, encryption with a mistaken passphrase, forgetting which |
|---|
| 1302 | | passphrase was used, and other practical pitfalls. |
|---|
| | 1361 | Topic Encryption |
|---|
| | 1362 | |
|---|
| | 1363 | Outline mode supports gpg encryption of topics, with support for |
|---|
| | 1364 | symmetric and key-pair modes, passphrase timeout, passphrase |
|---|
| | 1365 | consistency checking, user-provided hinting for symmetric key |
|---|
| | 1366 | mode, and auto-encryption of topics pending encryption on save. |
|---|
| | 1367 | \(Topics pending encryption are, by default, automatically |
|---|
| | 1368 | encrypted during file saves; if you're editing the contents of |
|---|
| | 1369 | such a topic, it is automatically decrypted for continued |
|---|
| | 1370 | editing.) The aim is reliable topic privacy while preventing |
|---|
| | 1371 | accidents like neglected encryption before saves, forgetting |
|---|
| | 1372 | which passphrase was used, and other practical pitfalls. |
|---|
| 1319 | | Thus, by positioning the cursor on a topic bullet, you can execute |
|---|
| 1320 | | the outline navigation and manipulation commands with a single |
|---|
| 1321 | | keystroke. Non-literal chars never get this special translation, so |
|---|
| 1322 | | you can use them to get away from the hot-spot, and back to normal |
|---|
| 1323 | | operation. |
|---|
| | 1388 | Thus, by positioning the cursor on a topic bullet, you can |
|---|
| | 1389 | execute the outline navigation and manipulation commands with a |
|---|
| | 1390 | single keystroke. Regular navigation keys (eg, \\[forward-char], \\[next-line]) never get |
|---|
| | 1391 | this special translation, so you can use them to get out of the |
|---|
| | 1392 | hot-spot and back to normal operation. |
|---|
| 1539 | | (let* ((fill-func-var (if (string-match "^18" emacs-version) |
|---|
| 1540 | | 'auto-fill-hook |
|---|
| 1541 | | 'auto-fill-function)) |
|---|
| 1542 | | (fill-func (symbol-value fill-func-var))) |
|---|
| 1543 | | ;; Register prevailing fill func for use by allout-auto-fill: |
|---|
| 1544 | | (allout-resumptions 'allout-former-auto-filler (list fill-func)) |
|---|
| 1545 | | ;; Register allout-auto-fill to be used if filling is active: |
|---|
| 1546 | | (allout-resumptions fill-func-var '(allout-auto-fill))) |
|---|
| | 1609 | ;; Register prevailing fill func for use by allout-auto-fill: |
|---|
| | 1610 | (allout-resumptions 'allout-former-auto-filler (list auto-fill-function)) |
|---|
| | 1611 | ;; Register allout-auto-fill to be used if filling is active: |
|---|
| | 1612 | (allout-resumptions 'auto-fill-function '(allout-auto-fill)) |
|---|
| | 1613 | (allout-resumptions 'allout-outside-normal-auto-fill-function |
|---|
| | 1614 | (list normal-auto-fill-function)) |
|---|
| | 1615 | (allout-resumptions 'normal-auto-fill-function '(allout-auto-fill)) |
|---|
| 1578 | | (if (and do-layout |
|---|
| 1579 | | allout-auto-activation |
|---|
| 1580 | | (listp allout-layout) |
|---|
| 1581 | | (and (not (eq allout-auto-activation 'activate)) |
|---|
| 1582 | | (if (eq allout-auto-activation 'ask) |
|---|
| 1583 | | (if (y-or-n-p (format "Expose %s with layout '%s'? " |
|---|
| 1584 | | (buffer-name) |
|---|
| 1585 | | allout-layout)) |
|---|
| 1586 | | t |
|---|
| 1587 | | (message "Skipped %s layout." (buffer-name)) |
|---|
| 1588 | | nil) |
|---|
| 1589 | | t))) |
|---|
| 1590 | | (save-excursion |
|---|
| 1591 | | (message "Adjusting '%s' exposure..." (buffer-name)) |
|---|
| 1592 | | (goto-char 0) |
|---|
| 1593 | | (allout-this-or-next-heading) |
|---|
| 1594 | | (condition-case err |
|---|
| 1595 | | (progn |
|---|
| 1596 | | (apply 'allout-expose-topic (list allout-layout)) |
|---|
| 1597 | | (message "Adjusting '%s' exposure... done." (buffer-name))) |
|---|
| 1598 | | ;; Problem applying exposure - notify user, but don't |
|---|
| 1599 | | ;; interrupt, eg, file visit: |
|---|
| 1600 | | (error (message "%s" (car (cdr err))) |
|---|
| 1601 | | (sit-for 1))))) |
|---|
| | 1643 | (let ((use-layout (if (listp allout-layout) |
|---|
| | 1644 | allout-layout |
|---|
| | 1645 | allout-default-layout))) |
|---|
| | 1646 | (if (and do-layout |
|---|
| | 1647 | allout-auto-activation |
|---|
| | 1648 | use-layout |
|---|
| | 1649 | (and (not (eq allout-auto-activation 'activate)) |
|---|
| | 1650 | (if (eq allout-auto-activation 'ask) |
|---|
| | 1651 | (if (y-or-n-p (format "Expose %s with layout '%s'? " |
|---|
| | 1652 | (buffer-name) |
|---|
| | 1653 | use-layout)) |
|---|
| | 1654 | t |
|---|
| | 1655 | (message "Skipped %s layout." (buffer-name)) |
|---|
| | 1656 | nil) |
|---|
| | 1657 | t))) |
|---|
| | 1658 | (save-excursion |
|---|
| | 1659 | (message "Adjusting '%s' exposure..." (buffer-name)) |
|---|
| | 1660 | (goto-char 0) |
|---|
| | 1661 | (allout-this-or-next-heading) |
|---|
| | 1662 | (condition-case err |
|---|
| | 1663 | (progn |
|---|
| | 1664 | (apply 'allout-expose-topic (list use-layout)) |
|---|
| | 1665 | (message "Adjusting '%s' exposure... done." (buffer-name))) |
|---|
| | 1666 | ;; Problem applying exposure - notify user, but don't |
|---|
| | 1667 | ;; interrupt, eg, file visit: |
|---|
| | 1668 | (error (message "%s" (car (cdr err))) |
|---|
| | 1669 | (sit-for 1)))))) |
|---|
| | 1675 | |
|---|
| | 1676 | ;;;_ - Position Assessment |
|---|
| | 1677 | ;;;_ > allout-hidden-p (&optional pos) |
|---|
| | 1678 | (defsubst allout-hidden-p (&optional pos) |
|---|
| | 1679 | "Non-nil if the character after point is invisible." |
|---|
| | 1680 | (get-char-property (or pos (point)) 'invisible)) |
|---|
| | 1681 | |
|---|
| | 1682 | ;;;_ > allout-overlay-insert-in-front-handler (ol after beg end |
|---|
| | 1683 | ;;; &optional prelen) |
|---|
| | 1684 | (defun allout-overlay-insert-in-front-handler (ol after beg end |
|---|
| | 1685 | &optional prelen) |
|---|
| | 1686 | "Shift the overlay so stuff inserted in front of it are excluded." |
|---|
| | 1687 | (if after |
|---|
| | 1688 | (move-overlay ol (1+ beg) (overlay-end ol)))) |
|---|
| | 1689 | ;;;_ > allout-overlay-interior-modification-handler (ol after beg end |
|---|
| | 1690 | ;;; &optional prelen) |
|---|
| | 1691 | (defun allout-overlay-interior-modification-handler (ol after beg end |
|---|
| | 1692 | &optional prelen) |
|---|
| | 1693 | "Get confirmation before making arbitrary changes to invisible text. |
|---|
| | 1694 | |
|---|
| | 1695 | We expose the invisible text and ask for confirmation. Refusal or |
|---|
| | 1696 | keyboard-quit abandons the changes, with keyboard-quit additionally |
|---|
| | 1697 | reclosing the opened text. |
|---|
| | 1698 | |
|---|
| | 1699 | No confirmation is necessary when inhibit-read-only is set - eg, allout |
|---|
| | 1700 | internal functions use this feature cohesively bunch changes." |
|---|
| | 1701 | |
|---|
| | 1702 | (when (and (not inhibit-read-only) (not after)) |
|---|
| | 1703 | (let ((start (point)) |
|---|
| | 1704 | (ol-start (overlay-start ol)) |
|---|
| | 1705 | (ol-end (overlay-end ol)) |
|---|
| | 1706 | (msg "Change within concealed text disallowed.") |
|---|
| | 1707 | opened |
|---|
| | 1708 | first) |
|---|
| | 1709 | (goto-char beg) |
|---|
| | 1710 | (while (< (point) end) |
|---|
| | 1711 | (when (allout-hidden-p) |
|---|
| | 1712 | (allout-show-to-offshoot) |
|---|
| | 1713 | (if (allout-hidden-p) |
|---|
| | 1714 | (save-excursion (forward-char 1) |
|---|
| | 1715 | (allout-show-to-offshoot))) |
|---|
| | 1716 | (when (not first) |
|---|
| | 1717 | (setq opened t) |
|---|
| | 1718 | (setq first (point)))) |
|---|
| | 1719 | (goto-char (if (featurep 'xemacs) |
|---|
| | 1720 | (next-property-change (1+ (point)) nil end) |
|---|
| | 1721 | (next-char-property-change (1+ (point)) end)))) |
|---|
| | 1722 | (when first |
|---|
| | 1723 | (goto-char first) |
|---|
| | 1724 | (condition-case nil |
|---|
| | 1725 | (if (not |
|---|
| | 1726 | (yes-or-no-p |
|---|
| | 1727 | (substitute-command-keys |
|---|
| | 1728 | (concat "Modify concealed text? (\"no\" just aborts," |
|---|
| | 1729 | " \\[keyboard-quit] also reconceals) ")))) |
|---|
| | 1730 | (progn (goto-char start) |
|---|
| | 1731 | (error "Concealed-text change refused."))) |
|---|
| | 1732 | (quit (allout-flag-region ol-start ol-end nil) |
|---|
| | 1733 | (allout-flag-region ol-start ol-end t) |
|---|
| | 1734 | (error "Concealed-text change abandoned, text reconcealed.")))) |
|---|
| | 1735 | (goto-char start)))) |
|---|
| | 1736 | ;;;_ > allout-before-change-handler (beg end) |
|---|
| | 1737 | (defun allout-before-change-handler (beg end) |
|---|
| | 1738 | "Protect against changes to invisible text. |
|---|
| | 1739 | |
|---|
| | 1740 | See allout-overlay-interior-modification-handler for details. |
|---|
| | 1741 | |
|---|
| | 1742 | This before-change handler is used only where modification-hooks |
|---|
| | 1743 | overlay property is not supported." |
|---|
| | 1744 | (if (not (allout-mode-p)) |
|---|
| | 1745 | nil |
|---|
| | 1746 | (allout-overlay-interior-modification-handler nil nil beg end nil))) |
|---|
| | 1747 | ;;;_ > allout-isearch-end-handler (&optional overlay) |
|---|
| | 1748 | (defun allout-isearch-end-handler (&optional overlay) |
|---|
| | 1749 | "Reconcile allout outline exposure on arriving in hidden text after isearch. |
|---|
| | 1750 | |
|---|
| | 1751 | Optional OVERLAY parameter is for when this function is used by |
|---|
| | 1752 | `isearch-open-invisible' overlay property. It is otherwise unused, so this |
|---|
| | 1753 | function can also be used as an `isearch-mode-end-hook'." |
|---|
| | 1754 | |
|---|
| | 1755 | (if (and (allout-mode-p) (allout-hidden-p)) |
|---|
| | 1756 | (allout-show-to-offshoot))) |
|---|
| 1713 | | (defmacro allout-current-depth () |
|---|
| 1714 | | "Return nesting depth of visible topic most immediately containing point." |
|---|
| 1715 | | '(save-excursion |
|---|
| 1716 | | (if (allout-back-to-current-heading) |
|---|
| 1717 | | (max 1 |
|---|
| 1718 | | (- allout-recent-prefix-end |
|---|
| 1719 | | allout-recent-prefix-beginning |
|---|
| 1720 | | allout-header-subtraction)) |
|---|
| 1721 | | 0))) |
|---|
| | 1858 | (defun allout-current-depth () |
|---|
| | 1859 | "Return depth of visible topic most immediately containing point. |
|---|
| | 1860 | |
|---|
| | 1861 | Return zero if point is not within any topic." |
|---|
| | 1862 | (save-excursion |
|---|
| | 1863 | (if (allout-back-to-current-heading) |
|---|
| | 1864 | (max 1 |
|---|
| | 1865 | (- allout-recent-prefix-end |
|---|
| | 1866 | allout-recent-prefix-beginning |
|---|
| | 1867 | allout-header-subtraction)) |
|---|
| | 1868 | 0))) |
|---|
| 1786 | | ;;;_ - Navigation macros |
|---|
| | 1933 | ;;;_ - Navigation routines |
|---|
| | 1934 | ;;;_ > allout-beginning-of-current-line () |
|---|
| | 1935 | (defun allout-beginning-of-current-line () |
|---|
| | 1936 | "Like beginning of line, but to visible text." |
|---|
| | 1937 | |
|---|
| | 1938 | ;; XXX We would use `(move-beginning-of-line 1)', but it gets |
|---|
| | 1939 | ;; stuck on some hidden newlines, eg at column 80, as of GNU Emacs 22.0.50. |
|---|
| | 1940 | ;; Conversely, `beginning-of-line' can make no progress in other |
|---|
| | 1941 | ;; situations. Both are necessary, in the order used below. |
|---|
| | 1942 | (move-beginning-of-line 1) |
|---|
| | 1943 | (beginning-of-line) |
|---|
| | 1944 | (while (or (not (bolp)) (allout-hidden-p)) |
|---|
| | 1945 | (beginning-of-line) |
|---|
| | 1946 | (if (or (allout-hidden-p) (not (bolp))) |
|---|
| | 1947 | (forward-char -1)))) |
|---|
| | 1948 | ;;;_ > allout-end-of-current-line () |
|---|
| | 1949 | (defun allout-end-of-current-line () |
|---|
| | 1950 | "Move to the end of line, past concealed text if any." |
|---|
| | 1951 | ;; XXX This is for symmetry with `allout-beginning-of-current-line' - |
|---|
| | 1952 | ;; `move-end-of-line' doesn't suffer the same problem as |
|---|
| | 1953 | ;; `move-beginning-of-line'. |
|---|
| | 1954 | (end-of-line) |
|---|
| | 1955 | (while (allout-hidden-p) |
|---|
| | 1956 | (end-of-lin |
|---|