Changeset 4148 for trunk/lisp/allout.el
- Timestamp:
- 08/18/06 08:35:31 (2 years ago)
- Files:
-
- trunk/lisp/allout.el (modified) (56 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lisp/allout.el
r4131 r4148 214 214 (if (fboundp 'booleanp) 'booleanp '(lambda (x) (member x '(t nil))))) 215 215 216 ;;;_ = allout-beginning-of-line-cycles 217 (defcustom allout-beginning-of-line-cycles t 218 "*If non-nil, \\[allout-beginning-of-line] will cycle through smart-placement options. 219 220 Cycling only happens on when the command is repeated, not when it 221 follows a different command. 222 223 Smart-placement means that repeated calls to this function will 224 advance as follows: 225 226 - if the cursor is on a non-headline body line and not on the first column: 227 then it goes to the first column 228 - if the cursor is on the first column of a non-headline body line: 229 then it goes to the start of the headline within the item body 230 - if the cursor is on the headline and not the start of the headline: 231 then it goes to the start of the headline 232 - if the cursor is on the start of the headline: 233 then it goes to the bullet character \(for hotspot navigation\) 234 - if the cursor is on the bullet character: 235 then it goes to the first column of that line \(the headline\) 236 - if the cursor is on the first column of the headline: 237 then it goes to the start of the headline within the item body. 238 239 In this fashion, you can use the beginning-of-line command to do 240 its normal job and then, when repeated, advance through the 241 entry, cycling back to start. 242 243 If this configuration variable is nil, then the cursor is just 244 advanced to the beginning of the line and remains there on 245 repeated calls." 246 :type 'boolean :group 'allout) 247 ;;;_ = allout-end-of-line-cycles 248 (defcustom allout-end-of-line-cycles t 249 "*If non-nil, \\[allout-end-of-line] will cycle through smart-placement options. 250 251 Cycling only happens on when the command is repeated, not when it 252 follows a different command. 253 254 Smart-placement means that repeated calls to this function will 255 advance as follows: 256 257 - if the cursor is not on the end-of-line, 258 then it goes to the end-of-line 259 - if the cursor is on the end-of-line but not the end-of-entry, 260 then it goes to the end-of-entry, exposing it if necessary 261 - if the cursor is on the end-of-entry, 262 then it goes to the end of the head line 263 264 In this fashion, you can use the end-of-line command to do its 265 normal job and then, when repeated, advance through the entry, 266 cycling back to start. 267 268 If this configuration variable is nil, then the cursor is just 269 advanced to the end of the line and remains there on repeated 270 calls." 271 :type 'boolean :group 'allout) 272 216 273 ;;;_ = allout-header-prefix 217 274 (defcustom allout-header-prefix "." 275 ;; this string is treated as literal match. it will be `regexp-quote'd, so 276 ;; one cannot use regular expressions to match varying header prefixes. 218 277 "*Leading string which helps distinguish topic headers. 219 278 220 279 Outline topic header lines are identified by a leading topic 221 280 header prefix, which mostly have the value of this var at their front. 222 \(Level 1 topics are exceptions. They consist of only a single 223 character, which is typically set to the `allout-primary-bullet'. Many 224 outlines start at level 2 to avoid this discrepancy." 281 Level 1 topics are exceptions. They consist of only a single 282 character, which is typically set to the `allout-primary-bullet'." 225 283 :type 'string 226 284 :group 'allout) … … 301 359 "*When non-nil, use mode-specific topic-header prefixes. 302 360 303 Allout outline mode will use the mode-specific `allout-mode-leaders' 304 and/or comment-start string, if any, to lead the topic prefix string, 305 so topic headers look like comments in the programming language. 306 307 String values are used as they stand. 361 Allout outline mode will use the mode-specific `allout-mode-leaders' or 362 comment-start string, if any, to lead the topic prefix string, so topic 363 headers look like comments in the programming language. It will also use 364 the comment-start string, with an '_' appended, for `allout-primary-bullet'. 365 366 String values are used as literals, not regular expressions, so 367 do not escape any regulare-expression characters. 308 368 309 369 Value t means to first check for assoc value in `allout-mode-leaders' … … 314 374 `comment-start' to use only one of them, respectively. 315 375 316 Value nil means to always use the default \(`.'). 317 318 comment-start strings that do not end in spaces are tripled, and an 319 `_' underscore is tacked on the end, to distinguish them from regular 320 comment strings. comment-start strings that do end in spaces are not 321 tripled, but an underscore is substituted for the space. [This 322 presumes that the space is for appearance, not comment syntax. You 323 can use `allout-mode-leaders' to override this behavior, when 324 incorrect.]" 376 Value nil means to always use the default \(`.') and leave 377 `allout-primary-bullet' unaltered. 378 379 comment-start strings that do not end in spaces are tripled in 380 the header-prefix, and an `_' underscore is tacked on the end, to 381 distinguish them from regular comment strings. comment-start 382 strings that do end in spaces are not tripled, but an underscore 383 is substituted for the space. [This presumes that the space is 384 for appearance, not comment syntax. You can use 385 `allout-mode-leaders' to override this behavior, when 386 undesired.]" 325 387 :type '(choice (const t) (const nil) string 326 388 (const allout-mode-leaders) … … 335 397 "Specific allout-prefix leading strings per major modes. 336 398 337 Entries will be used instead or in lieu of mode-specific 338 comment-start strings. See also `allout-use-mode-specific-leader'. 399 Use this if the mode's comment-start string isn't what you 400 prefer, or if the mode lacks a comment-start string. See 401 `allout-use-mode-specific-leader' for more details. 339 402 340 403 If you're constructing a string that will comment-out outline 341 404 structuring so it can be included in program code, append an extra 342 405 character, like an \"_\" underscore, to distinguish the lead string 343 from regular comments that start at bol.")406 from regular comments that start at the beginning-of-line.") 344 407 345 408 ;;;_ = allout-old-style-prefixes … … 829 892 (allout-reset-header-lead header-lead) 830 893 header-lead) 831 ;;;_ > allout-infer-header-lead ()832 (defun allout-infer-header-lead ()833 "Determine appropriate `allout-header-prefix' .894 ;;;_ > allout-infer-header-lead-and-primary-bullet () 895 (defun allout-infer-header-lead-and-primary-bullet () 896 "Determine appropriate `allout-header-prefix' and `allout-primary-bullet'. 834 897 835 898 Works according to settings of: … … 875 938 (if (not leader) 876 939 nil 877 (if (string= leader allout-header-prefix) 878 nil ; no change, nothing to do. 879 (setq allout-header-prefix leader) 880 allout-header-prefix)))) 940 (setq allout-header-prefix leader) 941 (if (not allout-old-style-prefixes) 942 ;; setting allout-primary-bullet makes the top level topics use - 943 ;; actually, be - the special prefix: 944 (setq allout-primary-bullet leader)) 945 allout-header-prefix))) 946 (defalias 'allout-infer-header-lead 947 'allout-infer-header-lead-and-primary-bullet) 881 948 ;;;_ > allout-infer-body-reindent () 882 949 (defun allout-infer-body-reindent () … … 931 998 (setq allout-header-subtraction (1- (length allout-header-prefix))) 932 999 ;; Produce the new allout-regexp: 933 (setq allout-regexp (concat "\\( \\"934 allout-header-prefix935 "[ \t]*["936 allout-bullets-string937 "]\\)\\|\\"938 allout-primary-bullet939 "+\\|\^l"))1000 (setq allout-regexp (concat "\\(" 1001 (regexp-quote allout-header-prefix) 1002 "[ \t]*[" 1003 allout-bullets-string 1004 "]\\)\\|" 1005 (regexp-quote allout-primary-bullet) 1006 "+\\|\^l")) 940 1007 (setq allout-line-boundary-regexp 941 1008 (concat "\\(\n\\)\\(" allout-regexp "\\)")) … … 966 1033 keymap-list) 967 1034 map)) 968 ;;;_ = allout-prior-bindings - being deprecated.969 (defvar allout-prior-bindings nil970 "Variable for use in V18, with allout-added-bindings, for971 resurrecting, on mode deactivation, bindings that existed before972 activation. Being deprecated.")973 ;;;_ = allout-added-bindings - being deprecated974 (defvar allout-added-bindings nil975 "Variable for use in V18, with allout-prior-bindings, for976 resurrecting, on mode deactivation, bindings that existed before977 activation. Being deprecated.")978 1035 ;;;_ : Menu bar 979 1036 (defvar allout-mode-exposure-menu) … … 1051 1108 ;;;_ > allout-add-resumptions (&rest pairs) 1052 1109 (defun allout-add-resumptions (&rest pairs) 1053 "Set name/value pairs.1110 "Set name/value PAIRS. 1054 1111 1055 1112 Old settings are preserved for later resumption using `allout-do-resumptions'. 1056 1113 1114 The new values are set as a buffer local. On resumption, the prior buffer 1115 scope of the variable is restored along with its value. If it was a void 1116 buffer-local value, then it is left as nil on resumption. 1117 1057 1118 The pairs are lists whose car is the name of the variable and car of the 1058 cdr is the new value: '(some-var some-value)'. 1059 1060 The new value is set as a buffer local. 1061 1062 If the variable was not previously buffer-local, then that is noted and the 1063 `allout-do-resumptions' will just `kill-local-variable' of that binding. 1064 1065 If it previously was buffer-local, the old value is noted and resurrected 1066 by `allout-do-resumptions'. \(If the local value was previously void, then 1067 it is left as nil on resumption.\) 1119 cdr is the new value: '(some-var some-value)'. The pairs can actually be 1120 triples, where the third element qualifies the disposition of the setting, 1121 as described further below. 1122 1123 If the optional third element is the symbol 'extend, then the new value 1124 created by `cons'ing the second element of the pair onto the front of the 1125 existing value. 1126 1127 If the optional third element is the symbol 'append, then the new value is 1128 extended from the existing one by `append'ing a list containing the second 1129 element of the pair onto the end of the existing value. 1130 1131 Extension, and resumptions in general, should not be used for hook 1132 functions - use the 'local mode of `add-hook' for that, instead. 1068 1133 1069 1134 The settings are stored on `allout-mode-prior-settings'." … … 1071 1136 (let* ((pair (pop pairs)) 1072 1137 (name (car pair)) 1073 (value (cadr pair))) 1138 (value (cadr pair)) 1139 (qualifier (if (> (length pair) 2) 1140 (caddr pair))) 1141 prior-value) 1074 1142 (if (not (symbolp name)) 1075 1143 (error "Pair's name, %S, must be a symbol, not %s" 1076 1144 name (type-of name))) 1145 (setq prior-value (condition-case err 1146 (symbol-value name) 1147 (void-variable nil))) 1077 1148 (when (not (assoc name allout-mode-prior-settings)) 1078 1149 ;; Not already added as a resumption, create the prior setting entry. 1079 1150 (if (local-variable-p name) 1080 1151 ;; is already local variable - preserve the prior value: 1081 (push (list name (condition-case err 1082 (symbol-value name) 1083 (void-variable nil))) 1084 allout-mode-prior-settings) 1152 (push (list name prior-value) allout-mode-prior-settings) 1085 1153 ;; wasn't local variable, indicate so for resumption by killing 1086 1154 ;; local value, and make it local: 1087 1155 (push (list name) allout-mode-prior-settings) 1088 1156 (make-local-variable name))) 1089 (set name value)))) 1157 (if qualifier 1158 (cond ((eq qualifier 'extend) 1159 (if (not (listp prior-value)) 1160 (error "extension of non-list prior value attempted") 1161 (set name (cons value prior-value)))) 1162 ((eq qualifier 'append) 1163 (if (not (listp prior-value)) 1164 (error "appending of non-list prior value attempted") 1165 (set name (append prior-value (list value))))) 1166 (t (error "unrecognized setting qualifier `%s' encountered" 1167 qualifier))) 1168 (set name value))))) 1090 1169 ;;;_ > allout-do-resumptions () 1091 1170 (defun allout-do-resumptions () … … 1122 1201 ;;;_ x allout-view-change-hook 1123 1202 (defvar allout-view-change-hook nil 1124 "*\(Deprecated\) Hook that's run after allout outline exposure changes. 1125 1126 Switch to using `allout-exposure-change-hook' instead. Both 1127 variables are currently respected, but this one will be ignored 1128 in a subsequent allout version.") 1203 "*\(Deprecated\) A hook run after allout outline exposure changes. 1204 1205 Switch to using `allout-exposure-change-hook' instead. Both hooks are 1206 currently respected, but the other conveys the details of the exposure 1207 change via explicit parameters, and this one will eventually be disabled in 1208 a subsequent allout version.") 1129 1209 ;;;_ = allout-exposure-change-hook 1130 1210 (defvar allout-exposure-change-hook nil 1131 "*Hook that's run after allout outline exposure changes. 1132 1133 This variable will replace `allout-view-change-hook' in a subsequent allout 1134 version, though both are currently respected.") 1135 1211 "*Hook that's run after allout outline subtree exposure changes. 1212 1213 It is run at the conclusion of `allout-flag-region'. 1214 1215 Functions on the hook must take three arguments: 1216 1217 - from - integer indicating the point at the start of the change. 1218 - to - integer indicating the point of the end of the change. 1219 - flag - change mode: nil for exposure, otherwise concealment. 1220 1221 This hook might be invoked multiple times by a single command. 1222 1223 This hook is replacing `allout-view-change-hook', which is being deprecated 1224 and eventually will not be invoked.") 1225 ;;;_ = allout-structure-added-hook 1226 (defvar allout-structure-added-hook nil 1227 "*Hook that's run after addition of items to the outline. 1228 1229 Functions on the hook should take two arguments: 1230 1231 - new-start - integer indicating the point at the start of the first new item. 1232 - new-end - integer indicating the point of the end of the last new item. 1233 1234 Some edits that introduce new items may missed by this hook - 1235 specifically edits that native allout routines do not control. 1236 1237 This hook might be invoked multiple times by a single command.") 1238 ;;;_ = allout-structure-deleted-hook 1239 (defvar allout-structure-deleted-hook nil 1240 "*Hook that's run after disciplined deletion of subtrees from the outline. 1241 1242 Functions on the hook must take two arguments: 1243 1244 - depth - integer indicating the depth of the subtree that was deleted. 1245 - removed-from - integer indicating the point where the subtree was removed. 1246 1247 Some edits that remove or invalidate items may missed by this hook - 1248 specifically edits that native allout routines do not control. 1249 1250 This hook might be invoked multiple times by a single command.") 1251 ;;;_ = allout-structure-shifted-hook 1252 (defvar allout-structure-shifted-hook nil 1253 "*Hook that's run after shifting of items in the outline. 1254 1255 Functions on the hook should take two arguments: 1256 1257 - depth-change - integer indicating depth increase, negative for decrease 1258 - start - integer indicating the start point of the shifted parent item. 1259 1260 Some edits that shift items can be missed by this hook - specifically edits 1261 that native allout routines do not control. 1262 1263 This hook might be invoked multiple times by a single command.") 1136 1264 ;;;_ = allout-outside-normal-auto-fill-function 1137 1265 (defvar allout-outside-normal-auto-fill-function nil … … 1187 1315 was encrypted automatically as part of a file write or autosave.") 1188 1316 (make-variable-buffer-local 'allout-after-save-decrypt) 1317 ;;;_ = allout-encryption-plaintext-sanitization-regexps 1318 (defvar allout-encryption-plaintext-sanitization-regexps nil 1319 "List of regexps whose matches are removed from plaintext before encryption. 1320 1321 This is for the sake of removing artifacts, like escapes, that are added on 1322 and not actually part of the original plaintext. The removal is done just 1323 prior to encryption. 1324 1325 Entries must be symbols that are bound to the desired values. 1326 1327 Each value can be a regexp or a list with a regexp followed by a 1328 substitution string. If it's just a regexp, all its matches are removed 1329 before the text is encrypted. If it's a regexp and a substitution, the 1330 substition is used against the regexp matches, a la `replace-match'.") 1331 (make-variable-buffer-local 'allout-encryption-text-removal-regexps) 1332 ;;;_ = allout-encryption-ciphertext-rejection-regexps 1333 (defvar allout-encryption-ciphertext-rejection-regexps nil 1334 "Variable for regexps matching plaintext to remove before encryption. 1335 1336 This is for the sake of redoing encryption in cases where the ciphertext 1337 incidentally contains strings that would disrupt mode operation - 1338 for example, a line that happens to look like an allout-mode topic prefix. 1339 1340 Entries must be symbols that are bound to the desired regexp values. 1341 1342 The encryption will be retried up to 1343 `allout-encryption-ciphertext-rejection-limit' times, after which an error 1344 is raised.") 1345 1346 (make-variable-buffer-local 'allout-encryption-ciphertext-rejection-regexps) 1347 ;;;_ = allout-encryption-ciphertext-rejection-ceiling 1348 (defvar allout-encryption-ciphertext-rejection-ceiling 5 1349 "Limit on number of times encryption ciphertext is rejected. 1350 1351 See `allout-encryption-ciphertext-rejection-regexps' for rejection reasons.") 1352 (make-variable-buffer-local 'allout-encryption-ciphertext-rejection-ceiling) 1189 1353 ;;;_ > allout-mode-p () 1190 1354 ;; Must define this macro above any uses, or byte compilation will lack … … 1638 1802 'category 'allout-exposure-category) 1639 1803 1640 ( run-hooks 'allout-mode-deactivate-hook)1641 ( setq allout-mode nil))1804 (setq allout-mode nil) 1805 (run-hooks 'allout-mode-deactivate-hook)) 1642 1806 1643 1807 ;; Activation: … … 1646 1810 (if allout-old-style-prefixes 1647 1811 ;; Inhibit all the fancy formatting: 1648 (allout-add-resumptions '((allout-primary-bullet "*") 1649 (allout-old-style-prefixes ())))) 1812 (allout-add-resumptions '(allout-primary-bullet "*"))) 1650 1813 1651 1814 (allout-overlay-preparations) ; Doesn't hurt to redo this. … … 1655 1818 1656 1819 (set-allout-regexp) 1820 (allout-add-resumptions 1821 '(allout-encryption-ciphertext-rejection-regexps 1822 allout-line-boundary-regexp 1823 extend) 1824 '(allout-encryption-ciphertext-rejection-regexps 1825 allout-bob-regexp 1826 extend)) 1657 1827 1658 1828 ;; Produce map from current version of allout-keybindings-list: … … 1660 1830 (produce-allout-mode-map allout-keybindings-list)) 1661 1831 (substitute-key-definition 'beginning-of-line 1662 'move-beginning-of-line 1832 'allout-beginning-of-line 1833 allout-mode-map global-map) 1834 (substitute-key-definition 'move-beginning-of-line 1835 'allout-beginning-of-line 1663 1836 allout-mode-map global-map) 1664 1837 (substitute-key-definition 'end-of-line 1665 'move-end-of-line 1838 'allout-end-of-line 1839 allout-mode-map global-map) 1840 (substitute-key-definition 'move-end-of-line 1841 'allout-end-of-line 1666 1842 allout-mode-map global-map) 1667 1843 (produce-allout-mode-menubar-entries) … … 1718 1894 (setq do-layout t)) 1719 1895 1720 ( run-hooks 'allout-mode-hook)1721 ( setq allout-mode t))1896 (setq allout-mode t) 1897 (run-hooks 'allout-mode-hook)) 1722 1898 1723 1899 ;; Reactivation: … … 2045 2221 (end-of-line) 2046 2222 (if (allout-hidden-p) (forward-char 1))))) 2223 ;;;_ > allout-beginning-of-line () 2224 (defun allout-beginning-of-line () 2225 "Beginning-of-line with `allout-beginning-of-line-cycles' behavior, if set." 2226 2227 (interactive) 2228 2229 (if (or (not allout-beginning-of-line-cycles) 2230 (not (equal last-command this-command))) 2231 (move-beginning-of-line 1) 2232 (let ((beginning-of-body (save-excursion 2233 (allout-beginning-of-current-entry) 2234 (point)))) 2235 (cond ((= (current-column) 0) 2236 (allout-beginning-of-current-entry)) 2237 ((< (point) beginning-of-body) 2238 (allout-beginning-of-current-line)) 2239 ((= (point) beginning-of-body) 2240 (goto-char (allout-current-bullet-pos))) 2241 (t (allout-beginning-of-current-line) 2242 (if (< (point) beginning-of-body) 2243 ;; we were on the headline after its start: 2244 (allout-beginning-of-current-entry))))))) 2245 ;;;_ > allout-end-of-line () 2246 (defun allout-end-of-line () 2247 "End-of-line with `allout-end-of-line-cycles' behavior, if set." 2248 2249 (interactive) 2250 2251 (if (or (not allout-end-of-line-cycles) 2252 (not (equal last-command this-command))) 2253 (allout-end-of-current-line) 2254 (let ((end-of-entry (save-excursion 2255 (allout-end-of-entry) 2256 (point)))) 2257 (cond ((not (eolp)) 2258 (allout-end-of-current-line)) 2259 ((or (allout-hidden-p) (save-excursion 2260 (forward-char -1) 2261 (allout-hidden-p))) 2262 (allout-back-to-current-heading) 2263 (allout-show-current-entry) 2264 (allout-end-of-entry)) 2265 ((>= (point) end-of-entry) 2266 (allout-back-to-current-heading) 2267 (allout-end-of-current-line)) 2268 (t (allout-end-of-entry)))))) 2047 2269 ;;;_ > allout-next-heading () 2048 2270 (defsubst allout-next-heading () … … 2109 2331 ;;; traversal of the structure. 2110 2332 2111 ;;;_ > allout-chart-subtree (&optional levels orig-depth prev-depth)2112 (defun allout-chart-subtree (&optional levels orig-depth prev-depth)2333 ;;;_ > allout-chart-subtree (&optional levels visible orig-depth prev-depth) 2334 (defun allout-chart-subtree (&optional levels visible orig-depth prev-depth) 2113 2335 "Produce a location \"chart\" of subtopics of the containing topic. 2114 2336 2115 2337 Optional argument LEVELS specifies the depth \(relative to start 2116 depth) for the chart. Subsequent optional args are not for public 2117 use. 2338 depth) for the chart. 2339 2340 When optional argument VISIBLE is non-nil, the chart includes 2341 only the visible subelements of the charted subjects. 2342 2343 The remaining optional args are not for internal use by the function. 2118 2344 2119 2345 Point is left at the end of the subtree. … … 2142 2368 (progn (setq orig-depth (allout-depth)) 2143 2369 (or prev-depth (setq prev-depth (1+ orig-depth))) 2144 (allout-next-heading))) 2370 (if visible 2371 (allout-next-visible-heading 1) 2372 (allout-next-heading)))) 2145 2373 2146 2374 ;; Loop over the current levels' siblings. Besides being more … … 2164 2392 (while (and (<= curr-depth 2165 2393 (allout-recent-depth)) 2166 (allout-next-heading)))) 2167 (allout-next-heading))) 2394 (if visible 2395 (allout-next-visible-heading 1) 2396 (allout-next-heading))))) 2397 (if visible 2398 (allout-next-visible-heading 1) 2399 (allout-next-heading)))) 2168 2400 2169 2401 ((and (< prev-depth curr-depth) … … 2174 2406 (cons (allout-chart-subtree (and levels 2175 2407 (1- levels)) 2176 orig-depth 2177 curr-depth) 2408 visible 2409 orig-depth 2410 curr-depth) 2178 2411 chart)) 2179 2412 ;; ... then continue with this one. … … 2370 2603 (> (allout-recent-depth) level)) 2371 2604 (allout-next-heading)) 2372 (and (not (eobp)) (forward-char -1)) 2605 (if (eobp) 2606 (allout-end-of-entry) 2607 (forward-char -1)) 2373 2608 (if (and (not include-trailing-blank) (= ?\n (preceding-char))) 2374 2609 (forward-char -1)) … … 2676 2911 `allout-mode-map'.") 2677 2912 (make-variable-buffer-local 'allout-post-goto-bullet) 2913 ;;;_ = allout-command-counter 2914 (defvar allout-command-counter 0 2915 "Counter that monotonically increases in allout-mode buffers. 2916 2917 Set by `allout-pre-command-business', to support allout addons in 2918 coordinating with allout activity.") 2919 (make-variable-buffer-local 'allout-command-counter) 2678 2920 ;;;_ > allout-post-command-business () 2679 2921 (defun allout-post-command-business () … … 2693 2935 (allout-after-saves-handler)) 2694 2936 2695 ;; Implement -post-goto-bullet, if set:2937 ;; Implement allout-post-goto-bullet, if set: 2696 2938 (if (and allout-post-goto-bullet 2697 2939 (allout-current-bullet-pos)) … … 2702 2944 (defun allout-pre-command-business () 2703 2945 "Outline `pre-command-hook' function for outline buffers. 2704 Implements special behavior when cursor is on bullet character. 2946 2947 Among other things, implements special behavior when the cursor is on the 2948 topic bullet character. 2705 2949 2706 2950 When the cursor is on the bullet character, self-insert characters are … … 2710 2954 positioned on the bullet character of the destination topic. 2711 2955 2712 The upshot is that you can get easy, single (ie, unmodified) key2956 The upshot is that you can get easy, single \(ie, unmodified\) key 2713 2957 outline maneuvering operations by positioning the cursor on the bullet 2714 2958 char. When in this mode you can use regular cursor-positioning … … 2718 2962 (if (not (allout-mode-p)) 2719 2963 nil 2964 ;; Increment allout-command-counter 2965 (setq allout-command-counter (1+ allout-command-counter)) 2966 ;; Do hot-spot navigation. 2720 2967 (if (and (eq this-command 'self-insert-command) 2721 2968 (eq (point)(allout-current-bullet-pos))) … … 2991 3238 If OFFER-RECENT-BULLET is true, offer to use the bullet of the prior sibling. 2992 3239 3240 Runs 3241 2993 3242 Nuances: 2994 3243 … … 3041 3290 (point))) 3042 3291 dbl-space 3043 doing-beginning) 3292 doing-beginning 3293 start end) 3044 3294 3045 3295 (if (not opening-on-blank) … … 3142 3392 (forward-char 1)))) 3143 3393 )) 3394 (setq start (point)) 3144 3395 (insert (concat (allout-make-topic-prefix opening-numbered t depth) 3145 3396 " ")) 3397 (setq end (1+ (point))) 3146 3398 3147 3399 (allout-rebullet-heading (and offer-recent-bullet ref-bullet) … … 3151 3403 (allout-show-children))) 3152 3404 (end-of-line) 3405 3406 (run-hook-with-args 'allout-structure-added-hook start end) 3153 3407 ) 3154 3408 ) … … 3549 3803 (interactive "p") 3550 3804 (if (> arg 0) 3805 ;; refuse to create a containment discontinuity: 3551 3806 (save-excursion 3552 3807 (allout-back-to-current-heading) … … 3565 3820 (error (concat "Disallowed shift deeper than" 3566 3821 " containing topic's children."))))))) 3567 (allout-rebullet-topic arg)) 3822 (let ((where (point)) 3823 has-successor) 3824 (if (and (< arg 0) 3825 (allout-current-topic-collapsed-p) 3826 (save-excursion (allout-next-sibling))) 3827 (setq has-successor t)) 3828 (allout-rebullet-topic arg) 3829 (when (< arg 0) 3830 (save-excursion 3831 (if (allout-ascend) 3832 (allout-show-children))) 3833 (if has-successor 3834 (allout-show-children))) 3835 (run-hook-with-args 'allout-structure-shifted-hook arg where))) 3568 3836 ;;;_ > allout-shift-out (arg) 3569 3837 (defun allout-shift-out (arg) … … 3575 3843 depth, however." 3576 3844 (interactive "p") 3577 (if (< arg 0) 3578 (allout-shift-in (* arg -1))) 3579 (allout-rebullet-topic (* arg -1))) 3845 (allout-shift-in (* arg -1))) 3580 3846 ;;;_ : Surgery (kill-ring) functions with special provisions for outlines: 3581 3847 ;;;_ > allout-kill-line (&optional arg) … … 3611 3877 (if (not (looking-at allout-regexp)) 3612 3878 (allout-next-heading)) 3613 (allout-renumber-to-depth depth)))))) 3879 (allout-renumber-to-depth depth))) 3880 (run-hook-with-args 'allout-structure-deleted-hook depth (point))))) 3614 3881 ;;;_ > allout-kill-topic () 3615 3882 (defun allout-kill-topic () … … 3657 3924 (sit-for 0) 3658 3925 (save-excursion 3659 (allout-renumber-to-depth depth)))) 3926 (allout-renumber-to-depth depth)) 3927 (run-hook-with-args 'allout-structure-deleted-hook depth (point)))) 3660 3928 ;;;_ > allout-yank-processing () 3661 3929 (defun allout-yank-processing (&optional arg) … … 3684 3952 (if (< (allout-mark-marker t) (point)) 3685 3953 (exchange-point-and-mark)) 3686 ( let* ((inhibit-field-text-motion t)3687 (subj-beg (point))3688 (into-bol (bolp))3689 (subj-end (allout-mark-marker t))3690 (was-collapsed (get-text-property subj-beg 'allout-was-collapsed))3691 ;; 'resituate' if yanking an entire topic into topic header:3692 (resituate (and (allout-e-o-prefix-p)3693 (looking-at (concat "\\(" allout-regexp "\\)"))3694 (allout-prefix-data (match-beginning 1)3954 (allout-unprotected 3955 (let* ((subj-beg (point)) 3956 (into-bol (bolp)) 3957 (subj-end (allout-mark-marker t)) 3958 (was-collapsed (get-text-property subj-beg 'allout-was-collapsed)) 3959 ;; 'resituate' if yanking an entire topic into topic header: 3960 (resituate (and (allout-e-o-prefix-p) 3961 (looking-at (concat "\\(" allout-regexp "\\)")) 3962 (allout-prefix-data (match-beginning 1) 3695 3963 (match-end 1)))) 3696 ;; `rectify-numbering' if resituating (where several topics may3697 ;; be resituating) or yanking a topic into a topic slot (bol):3698 (rectify-numbering (or resituate3699 (and into-bol (looking-at allout-regexp)))))3700 (if resituate3964 ;; `rectify-numbering' if resituating (where several topics may 3965 ;; be resituating) or yanking a topic into a topic slot (bol): 3966 (rectify-numbering (or resituate 3967 (and into-bol (looking-at allout-regexp))))) 3968 (if resituate 3701 3969 ; The yanked stuff is a topic: 3702 (let* ((prefix-len (- (match-end 1) subj-beg))3703 (subj-depth (allout-recent-depth))3704 (prefix-bullet (allout-recent-bullet))3705 (adjust-to-depth3706 ;; Nil if adjustment unnecessary, otherwise depth to which3707 ;; adjustment should be made:3708 (save-excursion3709 (and (goto-char subj-end)3710 (eolp)3711 (goto-char subj-beg)3712 (and (looking-at allout-regexp)3713 (progn3714 (beginning-of-line)3715 (not (= (point) subj-beg)))3716 (looking-at allout-regexp)3717 (allout-prefix-data (match-beginning 0)3970 (let* ((prefix-len (- (match-end 1) subj-beg)) 3971 (subj-depth (allout-recent-depth)) 3972 (prefix-bullet (allout-recent-bullet)) 3973 (adjust-to-depth 3974 ;; Nil if adjustment unnecessary, otherwise depth to which 3975 ;; adjustment should be made: 3976 (save-excursion 3977 (and (goto-char subj-end) 3978 (eolp) 3979 (goto-char subj-beg) 3980 (and (looking-at allout-regexp) 3981 (progn 3982 (beginning-of-line) 3983 (not (= (point) subj-beg))) 3984 (looking-at allout-regexp) 3985 (allout-prefix-data (match-beginning 0) 3718 3986 (match-end 0))) 3719 (allout-recent-depth))))3720 (more t))3721 (setq rectify-numbering allout-numbered-bullet)3722 (if adjust-to-depth3987 (allout-recent-depth)))) 3988 (more t)) 3989 (setq rectify-numbering allout-numbered-bullet) 3990 (if adjust-to-depth 3723 3991 ; Do the adjustment: 3724 (progn3725 (message "... yanking") (sit-for 0)3726 (save-restriction3727 (narrow-to-region subj-beg subj-end)3992 (progn 3993 (message "... yanking") (sit-for 0) 3994 (save-restriction 3995 (narrow-to-region subj-beg subj-end) 3728 3996 ; Trim off excessive blank 3729 3997 ; line at end, if any: 3730 (goto-char (point-max))3731 (if (looking-at "^$")3732 (allout-unprotected (delete-char -1)))3998 (goto-char (point-max)) 3999 (if (looking-at "^$") 4000 (allout-unprotected (delete-char -1))) 3733 4001 ; Work backwards, with each 3734 4002 ; shallowest level, … … 3736 4004 ; last processed topic from 3737 4005 ; the narrow region: 3738 (while more3739 (allout-back-to-current-heading)4006 (while more 4007 (allout-back-to-current-heading) 3740 4008 ; go as high as we can in each bunch: 3741 (while (allout-ascend-to-depth (1- (allout-depth))))3742 (save-excursion3743 (allout-rebullet-topic-grunt (- adjust-to-depth4009 (while (allout-ascend-to-depth (1- (allout-depth)))) 4010 (save-excursion 4011 (allout-rebullet-topic-grunt (- adjust-to-depth 3744 4012 subj-depth)) 3745 (allout-depth))3746 (if (setq more (not (bobp)))3747 (progn (widen)3748 (forward-char -1)3749 (narrow-to-region subj-beg (point))))))3750 (message "")3751 ;; Preserve new bullet if it's a distinctive one, otherwise3752 ;; use old one:3753 (if (string-match (regexp-quote prefix-bullet)3754 allout-distinctive-bullets-string)4013 (allout-depth)) 4014 (if (setq more (not (bobp))) 4015 (progn (widen) 4016 (forward-char -1) 4017 (narrow-to-region subj-beg (point)))))) 4018 (message "") 4019 ;; Preserve new bullet if it's a distinctive one, otherwise 4020 ;; use old one: 4021 (if (string-match (regexp-quote prefix-bullet) 4022 allout-distinctive-bullets-string) 3755 4023 ; Delete from bullet of old to 3756 4024 ; before bullet of new: 3757 (progn3758 (beginning-of-line)3759 (delete-region (point) subj-beg)3760 (set-marker (allout-mark-marker t) subj-end)3761 (goto-char subj-beg)3762 (allout-end-of-prefix))4025 (progn 4026 (beginning-of-line) 4027 (delete-region (point) subj-beg) 4028 (set-marker (allout-mark-marker t) subj-end) 4029 (goto-char subj-beg) 4030 (allout-end-of-prefix)) 3763 4031 ; Delete base subj prefix, 3764 4032 ; leaving old one: 3765 (delete-region (point) (+ (point)3766 prefix-len3767 (- adjust-to-depth subj-depth)))4033 (delete-region (point) (+ (point) 4034 prefix-len 4035 (- adjust-to-depth subj-depth))) 3768 4036 ; and delete residual subj 3769 4037 ; prefix digits and space: 3770 (while (looking-at "[0-9]") (delete-char 1))3771 (if (looking-at " ") (delete-char 1))))3772 (exchange-point-and-mark))))3773 (if rectify-numbering3774 (progn3775 (save-excursion4038 (while (looking-at "[0-9]") (delete-char 1)) 4039 (if (looking-at " ") (delete-char 1)))) 4040 (exchange-point-and-mark)))) 4041 (if rectify-numbering 4042 (progn 4043 (save-excursion 3776 4044 ; Give some preliminary feedback: 3777 (message "... reconciling numbers") (sit-for 0)4045 (message "... reconciling numbers") (sit-for 0) 3778 4046 ; ... and renumber, in case necessary: 3779 (goto-char subj-beg)3780 (if (allout-goto-prefix)3781 (allout-rebullet-heading nil;;; solicit4047 (goto-char subj-beg) 4048 (if (allout-goto-prefix) 4049 (allout-rebullet-heading nil ;;; solicit 3782 4050 (allout-depth) ;;; depth 3783 nil ;;; number-control3784 &
