Mercurial > emacs
comparison lisp/allout.el @ 83548:c71725faff1a
Merged from emacs@sv.gnu.org. Last-minute emacsclient rewrites be damned!
Patches applied:
* emacs@sv.gnu.org/emacs--devo--0--patch-490
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-491
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-492
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-493
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-494
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-495
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-496
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-497
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-498
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-499
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-500
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-501
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-502
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-503
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-504
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-505
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-506
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-507
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-508
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-509
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-510
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-511
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-512
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-513
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-514
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-515
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-516
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-517
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-518
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-519
Update from CVS: etc/TUTORIAL.cn: Updated.
* emacs@sv.gnu.org/emacs--devo--0--patch-520
Merge from erc--emacs--22
* emacs@sv.gnu.org/emacs--devo--0--patch-521
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-522
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-523
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-524
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-525
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-526
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-527
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-528
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-529
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-530
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-531
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-532
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-533
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-534
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-535
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-161
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-162
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-163
Merge from emacs--devo--0
* emacs@sv.gnu.org/gnus--rel--5.10--patch-164
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-165
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-166
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-167
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-168
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-169
Merge from emacs--devo--0
* emacs@sv.gnu.org/gnus--rel--5.10--patch-170
Update from CVS
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-588
author | Karoly Lorentey <lorentey@elte.hu> |
---|---|
date | Sun, 03 Dec 2006 15:03:30 +0000 |
parents | 2d56e13fd23d cce8c092567f |
children | 17e0dd217877 |
comparison
equal
deleted
inserted
replaced
83547:0912b745fc75 | 83548:c71725faff1a |
---|---|
64 ;; The latest development version and helpful notes are available at | 64 ;; The latest development version and helpful notes are available at |
65 ;; http://myriadicity.net/Sundry/EmacsAllout . | 65 ;; http://myriadicity.net/Sundry/EmacsAllout . |
66 ;; | 66 ;; |
67 ;; The outline menubar additions provide quick reference to many of | 67 ;; The outline menubar additions provide quick reference to many of |
68 ;; the features, and see the docstring of the variable `allout-init' | 68 ;; the features, and see the docstring of the variable `allout-init' |
69 ;; for instructions on priming your emacs session for automatic | 69 ;; for instructions on priming your Emacs session for automatic |
70 ;; activation of allout-mode. | 70 ;; activation of allout-mode. |
71 ;; | 71 ;; |
72 ;; See the docstring of the variables `allout-layout' and | 72 ;; See the docstring of the variables `allout-layout' and |
73 ;; `allout-auto-activation' for details on automatic activation of | 73 ;; `allout-auto-activation' for details on automatic activation of |
74 ;; `allout-mode' as a minor mode. (It has changed since allout | 74 ;; `allout-mode' as a minor mode. (It has changed since allout |
889 (defvar allout-plain-bullets-string-len (length allout-plain-bullets-string) | 889 (defvar allout-plain-bullets-string-len (length allout-plain-bullets-string) |
890 "Length of `allout-plain-bullets-string', updated by `set-allout-regexp'.") | 890 "Length of `allout-plain-bullets-string', updated by `set-allout-regexp'.") |
891 (make-variable-buffer-local 'allout-plain-bullets-string-len) | 891 (make-variable-buffer-local 'allout-plain-bullets-string-len) |
892 | 892 |
893 ;;;_ = allout-doublecheck-at-and-shallower | 893 ;;;_ = allout-doublecheck-at-and-shallower |
894 (defconst allout-doublecheck-at-and-shallower 3 | 894 (defconst allout-doublecheck-at-and-shallower 2 |
895 "Verify apparent topics of this depth and shallower as being non-aberrant. | 895 "Validate apparent topics of this depth and shallower as being non-aberrant. |
896 | 896 |
897 Verified with `allout-aberrant-container-p'. This check's usefulness is | 897 Verified with `allout-aberrant-container-p'. This check's usefulness is |
898 limited to shallow prospects, because the determination of aberrance | 898 limited to shallow depths, because the determination of aberrance |
899 depends on the mistaken item being followed by a legitimate item of | 899 is according to the mistaken item being followed by a legitimate item of |
900 excessively greater depth.") | 900 excessively greater depth.") |
901 ;;;_ X allout-reset-header-lead (header-lead) | 901 ;;;_ X allout-reset-header-lead (header-lead) |
902 (defun allout-reset-header-lead (header-lead) | 902 (defun allout-reset-header-lead (header-lead) |
903 "*Reset the leading string used to identify topic headers." | 903 "*Reset the leading string used to identify topic headers." |
904 (interactive "sNew lead string: ") | 904 (interactive "sNew lead string: ") |
1378 itself is \*not* recorded in the file anywhere, and the encrypted contents | 1378 itself is \*not* recorded in the file anywhere, and the encrypted contents |
1379 are random binary characters to avoid exposing greater susceptibility to | 1379 are random binary characters to avoid exposing greater susceptibility to |
1380 search attacks. | 1380 search attacks. |
1381 | 1381 |
1382 The verifier string is retained as an Emacs file variable, as well as in | 1382 The verifier string is retained as an Emacs file variable, as well as in |
1383 the emacs buffer state, if file variable adjustments are enabled. See | 1383 the Emacs buffer state, if file variable adjustments are enabled. See |
1384 `allout-enable-file-variable-adjustment' for details about that.") | 1384 `allout-enable-file-variable-adjustment' for details about that.") |
1385 (make-variable-buffer-local 'allout-passphrase-verifier-string) | 1385 (make-variable-buffer-local 'allout-passphrase-verifier-string) |
1386 ;;;###autoload | 1386 ;;;###autoload |
1387 (put 'allout-passphrase-verifier-string 'safe-local-variable 'stringp) | 1387 (put 'allout-passphrase-verifier-string 'safe-local-variable 'stringp) |
1388 ;;;_ = allout-passphrase-hint-string | 1388 ;;;_ = allout-passphrase-hint-string |
1390 "Variable used to retain reminder string for file's encryption passphrase. | 1390 "Variable used to retain reminder string for file's encryption passphrase. |
1391 | 1391 |
1392 See the description of `allout-passphrase-hint-handling' for details about how | 1392 See the description of `allout-passphrase-hint-handling' for details about how |
1393 the reminder is deployed. | 1393 the reminder is deployed. |
1394 | 1394 |
1395 The hint is retained as an Emacs file variable, as well as in the emacs buffer | 1395 The hint is retained as an Emacs file variable, as well as in the Emacs buffer |
1396 state, if file variable adjustments are enabled. See | 1396 state, if file variable adjustments are enabled. See |
1397 `allout-enable-file-variable-adjustment' for details about that.") | 1397 `allout-enable-file-variable-adjustment' for details about that.") |
1398 (make-variable-buffer-local 'allout-passphrase-hint-string) | 1398 (make-variable-buffer-local 'allout-passphrase-hint-string) |
1399 (setq-default allout-passphrase-hint-string "") | 1399 (setq-default allout-passphrase-hint-string "") |
1400 ;;;###autoload | 1400 ;;;###autoload |
1504 (if (not was-modified) | 1504 (if (not was-modified) |
1505 (set-buffer-modified-p nil))) | 1505 (set-buffer-modified-p nil))) |
1506 (goto-char (cadr allout-after-save-decrypt)) | 1506 (goto-char (cadr allout-after-save-decrypt)) |
1507 (setq allout-after-save-decrypt nil)) | 1507 (setq allout-after-save-decrypt nil)) |
1508 ) | 1508 ) |
1509 ;;;_ = allout-inhibit-aberrance-doublecheck nil | |
1510 ;; In some exceptional moments, disparate topic depths need to be allowed | |
1511 ;; momentarily, eg when one topic is being yanked into another and they're | |
1512 ;; about to be reconciled. let-binding allout-inhibit-aberrance-doublecheck | |
1513 ;; prevents the aberrance doublecheck to allow, eg, the reconciliation | |
1514 ;; processing to happen in the presence of such discrepancies. It should | |
1515 ;; almost never be needed, however. | |
1516 (defvar allout-inhibit-aberrance-doublecheck nil | |
1517 "Internal state, for momentarily inhibits aberrance doublecheck. | |
1518 | |
1519 This should only be momentarily let-bound non-nil, not set | |
1520 non-nil in a lasting way.") | |
1509 | 1521 |
1510 ;;;_ #2 Mode activation | 1522 ;;;_ #2 Mode activation |
1511 ;;;_ = allout-explicitly-deactivated | 1523 ;;;_ = allout-explicitly-deactivated |
1512 (defvar allout-explicitly-deactivated nil | 1524 (defvar allout-explicitly-deactivated nil |
1513 "If t, `allout-mode's last deactivation was deliberate. | 1525 "If t, `allout-mode's last deactivation was deliberate. |
2192 | 2204 |
2193 ;;;_ #4 Navigation | 2205 ;;;_ #4 Navigation |
2194 | 2206 |
2195 ;;;_ - Position Assessment | 2207 ;;;_ - Position Assessment |
2196 ;;;_ : Location Predicates | 2208 ;;;_ : Location Predicates |
2197 ;;;_ > allout-on-current-heading-p () | 2209 ;;;_ > allout-do-doublecheck () |
2198 (defun allout-on-current-heading-p () | 2210 (defsubst allout-do-doublecheck () |
2199 "Return non-nil if point is on current visible topics' header line. | 2211 "True if current item conditions qualify for checking on topic aberrance." |
2200 | 2212 (and |
2201 Actually, returns prefix beginning point." | 2213 ;; presume integrity of outline and yanked content during yank - necessary, |
2202 (save-excursion | 2214 ;; to allow for level disparity of yank location and yanked text: |
2203 (allout-beginning-of-current-line) | 2215 (not allout-inhibit-aberrance-doublecheck) |
2204 (and (looking-at allout-regexp) | 2216 ;; allout-doublecheck-at-and-shallower is ceiling for doublecheck: |
2205 (allout-prefix-data) | 2217 (<= allout-recent-depth allout-doublecheck-at-and-shallower))) |
2206 (or (> allout-recent-depth allout-doublecheck-at-and-shallower) | 2218 ;;;_ > allout-aberrant-container-p () |
2207 (not (allout-aberrant-container-p)))))) | |
2208 ;;;_ > allout-on-heading-p () | |
2209 (defalias 'allout-on-heading-p 'allout-on-current-heading-p) | |
2210 ;;;_ > allout-e-o-prefix-p () | |
2211 (defun allout-e-o-prefix-p () | |
2212 "True if point is located where current topic prefix ends, heading begins." | |
2213 (and (save-excursion (let ((inhibit-field-text-motion t)) | |
2214 (beginning-of-line)) | |
2215 (looking-at allout-regexp)) | |
2216 (= (point)(save-excursion (allout-end-of-prefix)(point))))) | |
2217 ;;;_ > allout-aberrant-container-p () | |
2218 (defun allout-aberrant-container-p () | 2219 (defun allout-aberrant-container-p () |
2219 "True if topic, or next sibling with children, contains them discontinuously. | 2220 "True if topic, or next sibling with children, contains them discontinuously. |
2220 | 2221 |
2221 Discontinuous means an immediate offspring that is nested more | 2222 Discontinuous means an immediate offspring that is nested more |
2222 than one level deeper than the topic. | 2223 than one level deeper than the topic. |
2245 (re-search-forward allout-line-boundary-regexp nil 0)) | 2246 (re-search-forward allout-line-boundary-regexp nil 0)) |
2246 (allout-prefix-data) | 2247 (allout-prefix-data) |
2247 (goto-char allout-recent-prefix-beginning) | 2248 (goto-char allout-recent-prefix-beginning) |
2248 (cond | 2249 (cond |
2249 ;; sibling - continue: | 2250 ;; sibling - continue: |
2250 ((eq allout-recent-depth depth)) | 2251 ((eq allout-recent-depth depth)) |
2251 ;; first offspring is excessive - aberrant: | 2252 ;; first offspring is excessive - aberrant: |
2252 ((> allout-recent-depth (1+ depth)) | 2253 ((> allout-recent-depth (1+ depth)) |
2253 (setq done t aberrant t)) | 2254 (setq done t aberrant t)) |
2254 ;; next non-sibling is lower-depth - not aberrant: | 2255 ;; next non-sibling is lower-depth - not aberrant: |
2255 (t (setq done t))))) | 2256 (t (setq done t))))) |
2257 aberrant | 2258 aberrant |
2258 (goto-char start-point) | 2259 (goto-char start-point) |
2259 ;; recalibrate allout-recent-* | 2260 ;; recalibrate allout-recent-* |
2260 (allout-depth) | 2261 (allout-depth) |
2261 nil))) | 2262 nil))) |
2263 ;;;_ > allout-on-current-heading-p () | |
2264 (defun allout-on-current-heading-p () | |
2265 "Return non-nil if point is on current visible topics' header line. | |
2266 | |
2267 Actually, returns prefix beginning point." | |
2268 (save-excursion | |
2269 (allout-beginning-of-current-line) | |
2270 (and (looking-at allout-regexp) | |
2271 (allout-prefix-data) | |
2272 (or (not (allout-do-doublecheck)) | |
2273 (not (allout-aberrant-container-p)))))) | |
2274 ;;;_ > allout-on-heading-p () | |
2275 (defalias 'allout-on-heading-p 'allout-on-current-heading-p) | |
2276 ;;;_ > allout-e-o-prefix-p () | |
2277 (defun allout-e-o-prefix-p () | |
2278 "True if point is located where current topic prefix ends, heading begins." | |
2279 (and (save-excursion (let ((inhibit-field-text-motion t)) | |
2280 (beginning-of-line)) | |
2281 (looking-at allout-regexp)) | |
2282 (= (point)(save-excursion (allout-end-of-prefix)(point))))) | |
2262 ;;;_ : Location attributes | 2283 ;;;_ : Location attributes |
2263 ;;;_ > allout-depth () | 2284 ;;;_ > allout-depth () |
2264 (defun allout-depth () | 2285 (defun allout-depth () |
2265 "Return depth of topic most immediately containing point. | 2286 "Return depth of topic most immediately containing point. |
2266 | 2287 |
2388 (not (equal last-command this-command))) | 2409 (not (equal last-command this-command))) |
2389 (move-beginning-of-line 1) | 2410 (move-beginning-of-line 1) |
2390 (allout-depth) | 2411 (allout-depth) |
2391 (let ((beginning-of-body | 2412 (let ((beginning-of-body |
2392 (save-excursion | 2413 (save-excursion |
2393 (while (and (<= allout-recent-depth | 2414 (while (and (allout-do-doublecheck) |
2394 allout-doublecheck-at-and-shallower) | |
2395 (allout-aberrant-container-p) | 2415 (allout-aberrant-container-p) |
2396 (allout-previous-visible-heading 1))) | 2416 (allout-previous-visible-heading 1))) |
2397 (allout-beginning-of-current-entry) | 2417 (allout-beginning-of-current-entry) |
2398 (point)))) | 2418 (point)))) |
2399 (cond ((= (current-column) 0) | 2419 (cond ((= (current-column) 0) |
2441 (if (looking-at allout-regexp) | 2461 (if (looking-at allout-regexp) |
2442 (forward-char 1)) | 2462 (forward-char 1)) |
2443 | 2463 |
2444 (when (re-search-forward allout-line-boundary-regexp nil 0) | 2464 (when (re-search-forward allout-line-boundary-regexp nil 0) |
2445 (allout-prefix-data) | 2465 (allout-prefix-data) |
2446 (and (<= allout-recent-depth allout-doublecheck-at-and-shallower) | 2466 (and (allout-do-doublecheck) |
2447 ;; this will set allout-recent-* on the first non-aberrant topic, | 2467 ;; this will set allout-recent-* on the first non-aberrant topic, |
2448 ;; whether it's the current one or one that disqualifies it: | 2468 ;; whether it's the current one or one that disqualifies it: |
2449 (allout-aberrant-container-p)) | 2469 (allout-aberrant-container-p)) |
2450 (goto-char allout-recent-prefix-beginning))) | 2470 (goto-char allout-recent-prefix-beginning))) |
2451 ;;;_ > allout-this-or-next-heading | 2471 ;;;_ > allout-this-or-next-heading |
2462 | 2482 |
2463 We skip anomolous low-level topics, a la `allout-aberrant-container-p'." | 2483 We skip anomolous low-level topics, a la `allout-aberrant-container-p'." |
2464 | 2484 |
2465 (if (bobp) | 2485 (if (bobp) |
2466 nil | 2486 nil |
2467 ;; allout-goto-prefix-doublechecked calls us, so we can't use it here. | |
2468 (let ((start-point (point))) | 2487 (let ((start-point (point))) |
2488 ;; allout-goto-prefix-doublechecked calls us, so we can't use it here. | |
2469 (allout-goto-prefix) | 2489 (allout-goto-prefix) |
2470 (when (or (re-search-backward allout-line-boundary-regexp nil 0) | 2490 (when (or (re-search-backward allout-line-boundary-regexp nil 0) |
2471 (looking-at allout-bob-regexp)) | 2491 (looking-at allout-bob-regexp)) |
2472 (goto-char (allout-prefix-data)) | 2492 (goto-char (allout-prefix-data)) |
2473 (if (and (<= allout-recent-depth allout-doublecheck-at-and-shallower) | 2493 (if (and (allout-do-doublecheck) |
2474 (allout-aberrant-container-p)) | 2494 (allout-aberrant-container-p)) |
2475 (or (allout-previous-heading) | 2495 (or (allout-previous-heading) |
2476 (and (goto-char start-point) | 2496 (and (goto-char start-point) |
2477 ;; recalibrate allout-recent-*: | 2497 ;; recalibrate allout-recent-*: |
2478 (allout-depth) | 2498 (allout-depth) |
2703 | 2723 |
2704 Like `allout-goto-prefix', but shallow topics \(according to | 2724 Like `allout-goto-prefix', but shallow topics \(according to |
2705 `allout-doublecheck-at-and-shallower') are checked and | 2725 `allout-doublecheck-at-and-shallower') are checked and |
2706 disqualified for child containment discontinuity, according to | 2726 disqualified for child containment discontinuity, according to |
2707 `allout-aberrant-container-p'." | 2727 `allout-aberrant-container-p'." |
2708 (allout-goto-prefix) | 2728 (if (allout-goto-prefix) |
2709 (if (and (<= allout-recent-depth allout-doublecheck-at-and-shallower) | 2729 (if (and (allout-do-doublecheck) |
2710 (allout-aberrant-container-p)) | 2730 (allout-aberrant-container-p)) |
2711 (allout-previous-heading) | 2731 (allout-previous-heading) |
2712 (point))) | 2732 (point)))) |
2713 | 2733 |
2714 ;;;_ > allout-end-of-prefix () | 2734 ;;;_ > allout-end-of-prefix () |
2715 (defun allout-end-of-prefix (&optional ignore-decorations) | 2735 (defun allout-end-of-prefix (&optional ignore-decorations) |
2716 "Position cursor at beginning of header text. | 2736 "Position cursor at beginning of header text. |
2717 | 2737 |
2743 Return value of resulting point, unless we started outside | 2763 Return value of resulting point, unless we started outside |
2744 of (before any) topics, in which case we return nil." | 2764 of (before any) topics, in which case we return nil." |
2745 | 2765 |
2746 (allout-beginning-of-current-line) | 2766 (allout-beginning-of-current-line) |
2747 (let ((bol-point (point))) | 2767 (let ((bol-point (point))) |
2748 (allout-goto-prefix-doublechecked) | 2768 (if (allout-goto-prefix-doublechecked) |
2749 (if (<= (point) bol-point) | 2769 (if (<= (point) bol-point) |
2750 (if (interactive-p) | 2770 (if (interactive-p) |
2751 (allout-end-of-prefix) | 2771 (allout-end-of-prefix) |
2752 (point)) | 2772 (point)) |
2753 (goto-char (point-min)) | 2773 (goto-char (point-min)) |
2754 nil))) | 2774 nil)))) |
2755 ;;;_ > allout-back-to-heading () | 2775 ;;;_ > allout-back-to-heading () |
2756 (defalias 'allout-back-to-heading 'allout-back-to-current-heading) | 2776 (defalias 'allout-back-to-heading 'allout-back-to-current-heading) |
2757 ;;;_ > allout-pre-next-prefix () | 2777 ;;;_ > allout-pre-next-prefix () |
2758 (defun allout-pre-next-prefix () | 2778 (defun allout-pre-next-prefix () |
2759 "Skip forward to just before the next heading line. | 2779 "Skip forward to just before the next heading line. |
2869 ;;;_ > allout-ascend () | 2889 ;;;_ > allout-ascend () |
2870 (defun allout-ascend () | 2890 (defun allout-ascend () |
2871 "Ascend one level, returning t if successful, nil if not." | 2891 "Ascend one level, returning t if successful, nil if not." |
2872 (prog1 | 2892 (prog1 |
2873 (if (allout-beginning-of-level) | 2893 (if (allout-beginning-of-level) |
2874 (allout-previous-heading)) | 2894 (let ((bolevel (point)) |
2895 (bolevel-depth allout-recent-depth)) | |
2896 (allout-previous-heading) | |
2897 (if (< allout-recent-depth bolevel-depth) | |
2898 allout-recent-depth | |
2899 ;; some topic after file's first is at lower depth than first: | |
2900 (goto-char bolevel) | |
2901 (allout-depth) | |
2902 nil))) | |
2875 (if (interactive-p) (allout-end-of-prefix)))) | 2903 (if (interactive-p) (allout-end-of-prefix)))) |
2876 ;;;_ > allout-descend-to-depth (depth) | 2904 ;;;_ > allout-descend-to-depth (depth) |
2877 (defun allout-descend-to-depth (depth) | 2905 (defun allout-descend-to-depth (depth) |
2878 "Descend to depth DEPTH within current topic. | 2906 "Descend to depth DEPTH within current topic. |
2879 | 2907 |
2916 | 2944 |
2917 (if (if backward (bobp) (eobp)) | 2945 (if (if backward (bobp) (eobp)) |
2918 nil | 2946 nil |
2919 (let ((target-depth (or depth (allout-depth))) | 2947 (let ((target-depth (or depth (allout-depth))) |
2920 (start-point (point)) | 2948 (start-point (point)) |
2949 (start-prefix-beginning allout-recent-prefix-beginning) | |
2921 (count 0) | 2950 (count 0) |
2922 leaping | 2951 leaping |
2923 last-depth) | 2952 last-depth) |
2924 (while (and | 2953 (while (and |
2925 ;; done too few single steps to resort to the leap routine: | 2954 ;; done too few single steps to resort to the leap routine: |
2939 (goto-char start-point) | 2968 (goto-char start-point) |
2940 (if depth (allout-depth) target-depth) | 2969 (if depth (allout-depth) target-depth) |
2941 nil))) | 2970 nil))) |
2942 ((and (not (eobp)) | 2971 ((and (not (eobp)) |
2943 (and (> (or last-depth (allout-depth)) 0) | 2972 (and (> (or last-depth (allout-depth)) 0) |
2944 (= allout-recent-depth target-depth))) | 2973 (= allout-recent-depth target-depth)) |
2974 (not (= start-prefix-beginning | |
2975 allout-recent-prefix-beginning))) | |
2945 allout-recent-prefix-beginning) | 2976 allout-recent-prefix-beginning) |
2946 (t | 2977 (t |
2947 (goto-char start-point) | 2978 (goto-char start-point) |
2948 (if depth (allout-depth) target-depth) | 2979 (if depth (allout-depth) target-depth) |
2949 nil))))) | 2980 nil))))) |
3065 ;; Deal with apparent header line: | 3096 ;; Deal with apparent header line: |
3066 (if (not (looking-at allout-regexp)) | 3097 (if (not (looking-at allout-regexp)) |
3067 ;; not a header line, keep looking: | 3098 ;; not a header line, keep looking: |
3068 t | 3099 t |
3069 (allout-prefix-data) | 3100 (allout-prefix-data) |
3070 (if (and (<= allout-recent-depth | 3101 (if (and (allout-do-doublecheck) |
3071 allout-doublecheck-at-and-shallower) | |
3072 (allout-aberrant-container-p)) | 3102 (allout-aberrant-container-p)) |
3073 ;; skip this aberrant prospective header line: | 3103 ;; skip this aberrant prospective header line: |
3074 t | 3104 t |
3075 ;; this prospective headerline qualifies - register: | 3105 ;; this prospective headerline qualifies - register: |
3076 (setq got allout-recent-prefix-beginning) | 3106 (setq got allout-recent-prefix-beginning) |
3477 the other offspring are exposed, or after the last child if the offspring | 3507 the other offspring are exposed, or after the last child if the offspring |
3478 are hidden. \(The intervening offspring will be exposed in the latter | 3508 are hidden. \(The intervening offspring will be exposed in the latter |
3479 case.) | 3509 case.) |
3480 | 3510 |
3481 If OFFER-RECENT-BULLET is true, offer to use the bullet of the prior sibling. | 3511 If OFFER-RECENT-BULLET is true, offer to use the bullet of the prior sibling. |
3482 | |
3483 Runs | |
3484 | 3512 |
3485 Nuances: | 3513 Nuances: |
3486 | 3514 |
3487 - Creation of new topics is with respect to the visible topic | 3515 - Creation of new topics is with respect to the visible topic |
3488 containing the cursor, regardless of intervening concealed ones. | 3516 containing the cursor, regardless of intervening concealed ones. |
3826 (let* ((current-depth (allout-depth)) | 3854 (let* ((current-depth (allout-depth)) |
3827 (new-depth (or new-depth current-depth)) | 3855 (new-depth (or new-depth current-depth)) |
3828 (mb allout-recent-prefix-beginning) | 3856 (mb allout-recent-prefix-beginning) |
3829 (me allout-recent-prefix-end) | 3857 (me allout-recent-prefix-end) |
3830 (current-bullet (buffer-substring-no-properties (- me 1) me)) | 3858 (current-bullet (buffer-substring-no-properties (- me 1) me)) |
3859 (has-annotation (get-text-property mb 'allout-was-hidden)) | |
3831 (new-prefix (allout-make-topic-prefix current-bullet | 3860 (new-prefix (allout-make-topic-prefix current-bullet |
3832 nil | 3861 nil |
3833 new-depth | 3862 new-depth |
3834 solicit | 3863 solicit |
3835 number-control | 3864 number-control |
3851 (if (and allout-numbered-bullet | 3880 (if (and allout-numbered-bullet |
3852 (string= allout-numbered-bullet current-bullet) | 3881 (string= allout-numbered-bullet current-bullet) |
3853 (looking-at "[0-9]+")) | 3882 (looking-at "[0-9]+")) |
3854 (allout-unprotected | 3883 (allout-unprotected |
3855 (delete-region (match-beginning 0)(match-end 0)))) | 3884 (delete-region (match-beginning 0)(match-end 0)))) |
3885 | |
3886 ;; convey 'allout-was-hidden annotation, if original had it: | |
3887 (if has-annotation | |
3888 (put-text-property 0 (length new-prefix) 'allout-was-hidden t | |
3889 new-prefix)) | |
3856 | 3890 |
3857 ; Put in new prefix: | 3891 ; Put in new prefix: |
3858 (allout-unprotected (insert new-prefix)) | 3892 (allout-unprotected (insert new-prefix)) |
3859 | 3893 |
3860 ;; Reindent the body if elected, margin changed, and not encrypted body: | 3894 ;; Reindent the body if elected, margin changed, and not encrypted body: |
4115 0)))) | 4149 0)))) |
4116 (if (and (> predecessor-depth 0) | 4150 (if (and (> predecessor-depth 0) |
4117 (> (1+ current-depth) | 4151 (> (1+ current-depth) |
4118 (1+ predecessor-depth))) | 4152 (1+ predecessor-depth))) |
4119 (error (concat "Disallowed shift deeper than" | 4153 (error (concat "Disallowed shift deeper than" |
4120 " containing topic's children.")))))) | 4154 " containing topic's children.")) |
4155 (allout-back-to-current-heading) | |
4156 (if (< allout-recent-depth (1+ current-depth)) | |
4157 (allout-show-children)))))) | |
4121 (let ((where (point))) | 4158 (let ((where (point))) |
4122 (allout-rebullet-topic 1 (and (> arg 1) 'sans-offspring)) | 4159 (allout-rebullet-topic 1 (and (> arg 1) 'sans-offspring)) |
4123 (run-hook-with-args 'allout-structure-shifted-hook arg where)))) | 4160 (run-hook-with-args 'allout-structure-shifted-hook arg where)))) |
4124 ;;;_ > allout-shift-out (arg) | 4161 ;;;_ > allout-shift-out (arg) |
4125 (defun allout-shift-out (arg) | 4162 (defun allout-shift-out (arg) |
4181 (setq end (point)) | 4218 (setq end (point)) |
4182 (allout-hidden-p))) | 4219 (allout-hidden-p))) |
4183 (depth (allout-depth))) | 4220 (depth (allout-depth))) |
4184 | 4221 |
4185 (allout-annotate-hidden beg end) | 4222 (allout-annotate-hidden beg end) |
4186 | |
4187 (if (and (not beg-hidden) (not end-hidden)) | 4223 (if (and (not beg-hidden) (not end-hidden)) |
4188 (allout-unprotected (kill-line arg)) | 4224 (allout-unprotected (kill-line arg)) |
4189 (kill-line arg)) | 4225 (kill-line arg)) |
4226 (allout-deannotate-hidden beg end) | |
4227 | |
4190 (if allout-numbered-bullet | 4228 (if allout-numbered-bullet |
4191 (save-excursion ; Renumber subsequent topics if needed: | 4229 (save-excursion ; Renumber subsequent topics if needed: |
4192 (if (not (looking-at allout-regexp)) | 4230 (if (not (looking-at allout-regexp)) |
4193 (allout-next-heading)) | 4231 (allout-next-heading)) |
4194 (allout-renumber-to-depth depth))) | 4232 (allout-renumber-to-depth depth))) |
4216 allout-yank-processing for exposure recovery." | 4254 allout-yank-processing for exposure recovery." |
4217 | 4255 |
4218 (interactive) | 4256 (interactive) |
4219 (let* ((inhibit-field-text-motion t) | 4257 (let* ((inhibit-field-text-motion t) |
4220 (beg (prog1 (allout-back-to-current-heading) (beginning-of-line))) | 4258 (beg (prog1 (allout-back-to-current-heading) (beginning-of-line))) |
4259 end | |
4221 (depth allout-recent-depth)) | 4260 (depth allout-recent-depth)) |
4222 (allout-end-of-current-subtree) | 4261 (allout-end-of-current-subtree) |
4223 (if (and (/= (current-column) 0) (not (eobp))) | 4262 (if (and (/= (current-column) 0) (not (eobp))) |
4224 (forward-char 1)) | 4263 (forward-char 1)) |
4225 (if (not (eobp)) | 4264 (if (not (eobp)) |
4229 (= depth allout-recent-depth))) | 4268 (= depth allout-recent-depth))) |
4230 (and (> (- beg (point-min)) 3) | 4269 (and (> (- beg (point-min)) 3) |
4231 (string= (buffer-substring (- beg 2) beg) "\n\n")))) | 4270 (string= (buffer-substring (- beg 2) beg) "\n\n")))) |
4232 (forward-char 1))) | 4271 (forward-char 1))) |
4233 | 4272 |
4234 (allout-annotate-hidden beg (point)) | 4273 (allout-annotate-hidden beg (setq end (point))) |
4235 | 4274 (unwind-protect |
4236 (allout-unprotected (kill-region beg (point))) | 4275 (allout-unprotected (kill-region beg end)) |
4276 (if buffer-read-only | |
4277 ;; eg, during copy-as-kill. | |
4278 (allout-deannotate-hidden beg end))) | |
4279 | |
4237 (save-excursion | 4280 (save-excursion |
4238 (allout-renumber-to-depth depth)) | 4281 (allout-renumber-to-depth depth)) |
4239 (run-hook-with-args 'allout-structure-deleted-hook depth (point)))) | 4282 (run-hook-with-args 'allout-structure-deleted-hook depth (point)))) |
4240 ;;;_ > allout-copy-topic-as-kill () | 4283 ;;;_ > allout-copy-topic-as-kill () |
4241 (defun allout-copy-topic-as-kill () | 4284 (defun allout-copy-topic-as-kill () |
4249 (defun allout-annotate-hidden (begin end) | 4292 (defun allout-annotate-hidden (begin end) |
4250 "Qualify text with properties to indicate exposure status." | 4293 "Qualify text with properties to indicate exposure status." |
4251 | 4294 |
4252 (let ((was-modified (buffer-modified-p)) | 4295 (let ((was-modified (buffer-modified-p)) |
4253 (buffer-read-only nil)) | 4296 (buffer-read-only nil)) |
4254 (allout-unprotected | 4297 (allout-deannotate-hidden begin end) |
4255 (remove-text-properties begin end '(allout-was-hidden t))) | |
4256 (save-excursion | 4298 (save-excursion |
4257 (goto-char begin) | 4299 (goto-char begin) |
4258 (let (done next prev overlay) | 4300 (let (done next prev overlay) |
4259 (while (not done) | 4301 (while (not done) |
4260 ;; at or advance to start of next hidden region: | 4302 ;; at or advance to start of next hidden region: |
4277 prev next) | 4319 prev next) |
4278 ;; advance to end of this hidden area: | 4320 ;; advance to end of this hidden area: |
4279 (when next | 4321 (when next |
4280 (goto-char next) | 4322 (goto-char next) |
4281 (allout-unprotected | 4323 (allout-unprotected |
4282 (put-text-property (overlay-start overlay) next | 4324 (let ((buffer-undo-list t)) |
4283 'allout-was-hidden t)))))))) | 4325 (put-text-property (overlay-start overlay) next |
4326 'allout-was-hidden t))))))))) | |
4284 (set-buffer-modified-p was-modified))) | 4327 (set-buffer-modified-p was-modified))) |
4328 ;;;_ > allout-deannotate-hidden (begin end) | |
4329 (defun allout-deannotate-hidden (begin end) | |
4330 "Remove allout hidden-text annotation between BEGIN and END." | |
4331 | |
4332 (allout-unprotected | |
4333 (let ((inhibit-read-only t) | |
4334 (buffer-undo-list t)) | |
4335 ;(remove-text-properties begin end '(allout-was-hidden t)) | |
4336 ))) | |
4285 ;;;_ > allout-hide-by-annotation (begin end) | 4337 ;;;_ > allout-hide-by-annotation (begin end) |
4286 (defun allout-hide-by-annotation (begin end) | 4338 (defun allout-hide-by-annotation (begin end) |
4287 "Translate text properties indicating exposure status into actual exposure." | 4339 "Translate text properties indicating exposure status into actual exposure." |
4288 (save-excursion | 4340 (save-excursion |
4289 (goto-char begin) | 4341 (goto-char begin) |
4307 (setq next (next-single-char-property-change (point) | 4359 (setq next (next-single-char-property-change (point) |
4308 'allout-was-hidden | 4360 'allout-was-hidden |
4309 nil end)) | 4361 nil end)) |
4310 (overlay-put (make-overlay prev next) | 4362 (overlay-put (make-overlay prev next) |
4311 'category 'allout-exposure-category) | 4363 'category 'allout-exposure-category) |
4312 (allout-unprotected | 4364 (allout-deannotate-hidden prev next) |
4313 (remove-text-properties prev next '(allout-was-hidden t))) | |
4314 (setq prev next) | 4365 (setq prev next) |
4315 (if next (goto-char next))))) | 4366 (if next (goto-char next))))) |
4316 (set-buffer-modified-p was-modified)))) | 4367 (set-buffer-modified-p was-modified)))) |
4317 ;;;_ > allout-remove-exposure-annotation (begin end) | |
4318 (defun allout-remove-exposure-annotation (begin end) | |
4319 "Remove text properties indicating exposure status." | |
4320 (remove-text-properties begin end '(allout-was-hidden t))) | |
4321 | |
4322 ;;;_ > allout-yank-processing () | 4368 ;;;_ > allout-yank-processing () |
4323 (defun allout-yank-processing (&optional arg) | 4369 (defun allout-yank-processing (&optional arg) |
4324 | 4370 |
4325 "Incidental allout-specific business to be done just after text yanks. | 4371 "Incidental allout-specific business to be done just after text yanks. |
4326 | 4372 |
4343 (interactive "*P") | 4389 (interactive "*P") |
4344 ; Get to beginning, leaving | 4390 ; Get to beginning, leaving |
4345 ; region around subject: | 4391 ; region around subject: |
4346 (if (< (allout-mark-marker t) (point)) | 4392 (if (< (allout-mark-marker t) (point)) |
4347 (exchange-point-and-mark)) | 4393 (exchange-point-and-mark)) |
4348 (allout-unprotected | 4394 (let* ((subj-beg (point)) |
4349 (let* ((subj-beg (point)) | 4395 (into-bol (bolp)) |
4350 (into-bol (bolp)) | 4396 (subj-end (allout-mark-marker t)) |
4351 (subj-end (allout-mark-marker t)) | 4397 ;; 'resituate' if yanking an entire topic into topic header: |
4352 ;; 'resituate' if yanking an entire topic into topic header: | 4398 (resituate (and (let ((allout-inhibit-aberrance-doublecheck t)) |
4353 (resituate (and (allout-e-o-prefix-p) | 4399 (allout-e-o-prefix-p)) |
4354 (looking-at allout-regexp) | 4400 (looking-at allout-regexp) |
4355 (allout-prefix-data))) | 4401 (allout-prefix-data))) |
4356 ;; `rectify-numbering' if resituating (where several topics may | 4402 ;; `rectify-numbering' if resituating (where several topics may |
4357 ;; be resituating) or yanking a topic into a topic slot (bol): | 4403 ;; be resituating) or yanking a topic into a topic slot (bol): |
4358 (rectify-numbering (or resituate | 4404 (rectify-numbering (or resituate |
4359 (and into-bol (looking-at allout-regexp))))) | 4405 (and into-bol (looking-at allout-regexp))))) |
4360 (if resituate | 4406 (if resituate |
4361 ; The yanked stuff is a topic: | 4407 ;; Yanking a topic into the start of a topic - reconcile to fit: |
4362 (let* ((prefix-len (- (match-end 1) subj-beg)) | 4408 (let* ((inhibit-field-text-motion t) |
4363 (subj-depth allout-recent-depth) | 4409 (prefix-len (if (not (match-end 1)) |
4364 (prefix-bullet (allout-recent-bullet)) | 4410 1 |
4365 (adjust-to-depth | 4411 (- (match-end 1) subj-beg))) |
4366 ;; Nil if adjustment unnecessary, otherwise depth to which | 4412 (subj-depth allout-recent-depth) |
4367 ;; adjustment should be made: | 4413 (prefix-bullet (allout-recent-bullet)) |
4368 (save-excursion | 4414 (adjust-to-depth |
4369 (and (goto-char subj-end) | 4415 ;; Nil if adjustment unnecessary, otherwise depth to which |
4370 (eolp) | 4416 ;; adjustment should be made: |
4371 (goto-char subj-beg) | 4417 (save-excursion |
4372 (and (looking-at allout-regexp) | 4418 (and (goto-char subj-end) |
4373 (progn | 4419 (eolp) |
4374 (beginning-of-line) | 4420 (goto-char subj-beg) |
4375 (not (= (point) subj-beg))) | 4421 (and (looking-at allout-regexp) |
4376 (looking-at allout-regexp) | 4422 (progn |
4377 (allout-prefix-data)) | 4423 (beginning-of-line) |
4378 allout-recent-depth))) | 4424 (not (= (point) subj-beg))) |
4379 (more t)) | 4425 (looking-at allout-regexp) |
4380 (setq rectify-numbering allout-numbered-bullet) | 4426 (allout-prefix-data)) |
4381 (if adjust-to-depth | 4427 allout-recent-depth))) |
4428 (more t)) | |
4429 (setq rectify-numbering allout-numbered-bullet) | |
4430 (if adjust-to-depth | |
4382 ; Do the adjustment: | 4431 ; Do the adjustment: |
4383 (progn | 4432 (progn |
4384 (save-restriction | 4433 (save-restriction |
4385 (narrow-to-region subj-beg subj-end) | 4434 (narrow-to-region subj-beg subj-end) |
4386 ; Trim off excessive blank | 4435 ; Trim off excessive blank |
4387 ; line at end, if any: | 4436 ; line at end, if any: |
4388 (goto-char (point-max)) | 4437 (goto-char (point-max)) |
4389 (if (looking-at "^$") | 4438 (if (looking-at "^$") |
4390 (allout-unprotected (delete-char -1))) | 4439 (allout-unprotected (delete-char -1))) |
4391 ; Work backwards, with each | 4440 ; Work backwards, with each |
4392 ; shallowest level, | 4441 ; shallowest level, |
4393 ; successively excluding the | 4442 ; successively excluding the |
4394 ; last processed topic from | 4443 ; last processed topic from |
4395 ; the narrow region: | 4444 ; the narrow region: |
4396 (while more | 4445 (while more |
4397 (allout-back-to-current-heading) | 4446 (allout-back-to-current-heading) |
4398 ; go as high as we can in each bunch: | 4447 ; go as high as we can in each bunch: |
4399 (while (allout-ascend)) | 4448 (while (allout-ascend)) |
4400 (save-excursion | 4449 (save-excursion |
4450 (allout-unprotected | |
4401 (allout-rebullet-topic-grunt (- adjust-to-depth | 4451 (allout-rebullet-topic-grunt (- adjust-to-depth |
4402 subj-depth)) | 4452 subj-depth))) |
4403 (allout-depth)) | 4453 (allout-depth)) |
4404 (if (setq more (not (bobp))) | 4454 (if (setq more (not (bobp))) |
4405 (progn (widen) | 4455 (progn (widen) |
4406 (forward-char -1) | 4456 (forward-char -1) |
4407 (narrow-to-region subj-beg (point)))))) | 4457 (narrow-to-region subj-beg (point)))))) |
4408 ;; Preserve new bullet if it's a distinctive one, otherwise | 4458 ;; Preserve new bullet if it's a distinctive one, otherwise |
4409 ;; use old one: | 4459 ;; use old one: |
4410 (if (string-match (regexp-quote prefix-bullet) | 4460 (if (string-match (regexp-quote prefix-bullet) |
4411 allout-distinctive-bullets-string) | 4461 allout-distinctive-bullets-string) |
4412 ; Delete from bullet of old to | 4462 ; Delete from bullet of old to |
4413 ; before bullet of new: | 4463 ; before bullet of new: |
4414 (progn | 4464 (progn |
4415 (beginning-of-line) | 4465 (beginning-of-line) |
4416 (delete-region (point) subj-beg) | 4466 (allout-unprotected |
4417 (set-marker (allout-mark-marker t) subj-end) | 4467 (delete-region (point) subj-beg)) |
4418 (goto-char subj-beg) | 4468 (set-marker (allout-mark-marker t) subj-end) |
4419 (allout-end-of-prefix)) | 4469 (goto-char subj-beg) |
4470 (allout-end-of-prefix)) | |
4420 ; Delete base subj prefix, | 4471 ; Delete base subj prefix, |
4421 ; leaving old one: | 4472 ; leaving old one: |
4422 (delete-region (point) (+ (point) | 4473 (allout-unprotected |
4423 prefix-len | 4474 (progn |
4424 (- adjust-to-depth subj-depth))) | 4475 (delete-region (point) (+ (point) |
4476 prefix-len | |
4477 (- adjust-to-depth | |
4478 subj-depth))) | |
4425 ; and delete residual subj | 4479 ; and delete residual subj |
4426 ; prefix digits and space: | 4480 ; prefix digits and space: |
4427 (while (looking-at "[0-9]") (delete-char 1)) | 4481 (while (looking-at "[0-9]") (delete-char 1)) |
4428 (if (looking-at " ") (delete-char 1)))) | 4482 (if (looking-at " ") (delete-char 1)))))) |
4429 (exchange-point-and-mark)))) | 4483 (exchange-point-and-mark)))) |
4430 (if rectify-numbering | 4484 (if rectify-numbering |
4431 (progn | 4485 (progn |
4432 (save-excursion | 4486 (save-excursion |
4433 ; Give some preliminary feedback: | 4487 ; Give some preliminary feedback: |
4434 (message "... reconciling numbers") | 4488 (message "... reconciling numbers") |
4435 ; ... and renumber, in case necessary: | 4489 ; ... and renumber, in case necessary: |
4436 (goto-char subj-beg) | 4490 (goto-char subj-beg) |
4437 (if (allout-goto-prefix-doublechecked) | 4491 (if (allout-goto-prefix-doublechecked) |
4492 (allout-unprotected | |
4438 (allout-rebullet-heading nil ;;; solicit | 4493 (allout-rebullet-heading nil ;;; solicit |
4439 (allout-depth) ;;; depth | 4494 (allout-depth) ;;; depth |
4440 nil ;;; number-control | 4495 nil ;;; number-control |
4441 nil ;;; index | 4496 nil ;;; index |
4442 t)) | 4497 t))) |
4443 (message "")))) | 4498 (message "")))) |
4444 (if (or into-bol resituate) | 4499 (if (or into-bol resituate) |
4445 (allout-hide-by-annotation (point) (allout-mark-marker t)) | 4500 (allout-hide-by-annotation (point) (allout-mark-marker t)) |
4446 (allout-remove-exposure-annotation (allout-mark-marker t) (point))) | 4501 (allout-deannotate-hidden (allout-mark-marker t) (point))) |
4447 (if (not resituate) | 4502 (if (not resituate) |
4448 (exchange-point-and-mark)) | 4503 (exchange-point-and-mark)) |
4449 (run-hook-with-args 'allout-structure-added-hook subj-beg subj-end)))) | 4504 (run-hook-with-args 'allout-structure-added-hook subj-beg subj-end))) |
4450 ;;;_ > allout-yank (&optional arg) | 4505 ;;;_ > allout-yank (&optional arg) |
4451 (defun allout-yank (&optional arg) | 4506 (defun allout-yank (&optional arg) |
4452 "`allout-mode' yank, with depth and numbering adjustment of yanked topics. | 4507 "`allout-mode' yank, with depth and numbering adjustment of yanked topics. |
4453 | 4508 |
4454 Non-topic yanks work no differently than normal yanks. | 4509 Non-topic yanks work no differently than normal yanks. |
5669 | 5724 |
5670 If allout customization var `allout-passphrase-verifier-handling' is | 5725 If allout customization var `allout-passphrase-verifier-handling' is |
5671 non-nil, an entry for `allout-passphrase-verifier-string' and its value is | 5726 non-nil, an entry for `allout-passphrase-verifier-string' and its value is |
5672 added to an Emacs 'local variables' section at the end of the file, which | 5727 added to an Emacs 'local variables' section at the end of the file, which |
5673 is created if necessary. That setting is for retention of the passphrase | 5728 is created if necessary. That setting is for retention of the passphrase |
5674 verifier across emacs sessions. | 5729 verifier across Emacs sessions. |
5675 | 5730 |
5676 Similarly, `allout-passphrase-hint-string' stores a user-provided reminder | 5731 Similarly, `allout-passphrase-hint-string' stores a user-provided reminder |
5677 about their passphrase, and `allout-passphrase-hint-handling' specifies | 5732 about their passphrase, and `allout-passphrase-hint-handling' specifies |
5678 when the hint is presented, or if passphrase hints are disabled. If | 5733 when the hint is presented, or if passphrase hints are disabled. If |
5679 enabled \(see the `allout-passphrase-hint-handling' docstring for details), | 5734 enabled \(see the `allout-passphrase-hint-handling' docstring for details), |
5709 (if (= allout-recent-depth 1) | 5764 (if (= allout-recent-depth 1) |
5710 (error (concat "Cannot encrypt or decrypt level 1 topics -" | 5765 (error (concat "Cannot encrypt or decrypt level 1 topics -" |
5711 " shift it in to make it encryptable"))) | 5766 " shift it in to make it encryptable"))) |
5712 | 5767 |
5713 (let* ((allout-buffer (current-buffer)) | 5768 (let* ((allout-buffer (current-buffer)) |
5714 ;; Asses location: | 5769 ;; Assess location: |
5715 (bullet-pos allout-recent-prefix-beginning) | 5770 (bullet-pos allout-recent-prefix-beginning) |
5716 (after-bullet-pos (point)) | 5771 (after-bullet-pos (point)) |
5717 (was-encrypted | 5772 (was-encrypted |
5718 (progn (if (= (point-max) after-bullet-pos) | 5773 (progn (if (= (point-max) after-bullet-pos) |
5719 (error "no body to encrypt")) | 5774 (error "no body to encrypt")) |
5743 (and (member fetch-pass '(4 (4))) | 5798 (and (member fetch-pass '(4 (4))) |
5744 '(keypair nil)) | 5799 '(keypair nil)) |
5745 '(symmetric nil))) | 5800 '(symmetric nil))) |
5746 (for-key-type (car key-info)) | 5801 (for-key-type (car key-info)) |
5747 (for-key-identity (cadr key-info)) | 5802 (for-key-identity (cadr key-info)) |
5748 (fetch-pass (and fetch-pass (member fetch-pass '(16 (16)))))) | 5803 (fetch-pass (and fetch-pass (member fetch-pass '(16 (16))))) |
5804 (was-coding-system buffer-file-coding-system)) | |
5805 | |
5806 (when (not was-encrypted) | |
5807 ;; ensure that non-ascii chars pending encryption are noticed before | |
5808 ;; they're encrypted, so the coding system is set to accomodate | |
5809 ;; them. | |
5810 (setq buffer-file-coding-system | |
5811 (select-safe-coding-system subtree-beg subtree-end)) | |
5812 ;; if the coding system for the text being encrypted is different | |
5813 ;; than that prevailing, then there a real risk that the coding | |
5814 ;; system can't be noticed by emacs when the file is visited. to | |
5815 ;; mitigate that, offer to preserve the coding system using a file | |
5816 ;; local variable. | |
5817 (if (and (not (equal buffer-file-coding-system | |
5818 was-coding-system)) | |
5819 (yes-or-no-p | |
5820 (format (concat "Register coding system %s as file local" | |
5821 " var? Necessary when only encrypted text" | |
5822 " is in that coding system. ") | |
5823 buffer-file-coding-system))) | |
5824 (allout-adjust-file-variable "buffer-file-coding-system" | |
5825 buffer-file-coding-system))) | |
5749 | 5826 |
5750 (setq result-text | 5827 (setq result-text |
5751 (allout-encrypt-string subject-text was-encrypted | 5828 (allout-encrypt-string subject-text was-encrypted |
5752 (current-buffer) | 5829 (current-buffer) |
5753 for-key-type for-key-identity fetch-pass)) | 5830 for-key-type for-key-identity fetch-pass)) |
5832 key-type | 5909 key-type |
5833 (if (equal key-type 'keypair) | 5910 (if (equal key-type 'keypair) |
5834 target-prompt-id | 5911 target-prompt-id |
5835 (or (buffer-file-name allout-buffer) | 5912 (or (buffer-file-name allout-buffer) |
5836 target-prompt-id)))) | 5913 target-prompt-id)))) |
5914 (encoding (with-current-buffer allout-buffer | |
5915 buffer-file-coding-system)) | |
5916 (multibyte (with-current-buffer allout-buffer | |
5917 enable-multibyte-characters)) | |
5837 (strip-plaintext-regexps | 5918 (strip-plaintext-regexps |
5838 (if (not decrypt) | 5919 (if (not decrypt) |
5839 (allout-get-configvar-values | 5920 (allout-get-configvar-values |
5840 'allout-encryption-plaintext-sanitization-regexps))) | 5921 'allout-encryption-plaintext-sanitization-regexps))) |
5841 (reject-ciphertext-regexps | 5922 (reject-ciphertext-regexps |
5867 retried fetch-pass))) | 5948 retried fetch-pass))) |
5868 | 5949 |
5869 (with-temp-buffer | 5950 (with-temp-buffer |
5870 | 5951 |
5871 (insert text) | 5952 (insert text) |
5953 | |
5954 ;; convey the text characteristics of the original buffer: | |
5955 (set-buffer-multibyte multibyte) | |
5956 (when encoding | |
5957 (set-buffer-file-coding-system encoding) | |
5958 (if (not decrypt) | |
5959 (encode-coding-region (point-min) (point-max) encoding))) | |
5872 | 5960 |
5873 (when (and strip-plaintext-regexps (not decrypt)) | 5961 (when (and strip-plaintext-regexps (not decrypt)) |
5874 (dolist (re strip-plaintext-regexps) | 5962 (dolist (re strip-plaintext-regexps) |
5875 (let ((re (if (listp re) (car re) re)) | 5963 (let ((re (if (listp re) (car re) re)) |
5876 (replacement (if (listp re) (cadr re) ""))) | 5964 (replacement (if (listp re) (cadr re) ""))) |
6354 | 6442 |
6355 (allout-mode t) | 6443 (allout-mode t) |
6356 | 6444 |
6357 (save-excursion | 6445 (save-excursion |
6358 (goto-char (point-min)) | 6446 (goto-char (point-min)) |
6359 (if (looking-at allout-regexp) | 6447 (if (allout-goto-prefix) |
6360 t | 6448 t |
6361 (allout-open-topic 2) | 6449 (allout-open-topic 2) |
6362 (insert (concat "Dummy outline topic header - see" | 6450 (insert (concat "Dummy outline topic header - see" |
6363 "`allout-mode' docstring: `^Hm'.")) | 6451 "`allout-mode' docstring: `^Hm'.")) |
6364 (allout-adjust-file-variable | 6452 (allout-adjust-file-variable |
6391 ) | 6479 ) |
6392 ) | 6480 ) |
6393 ) | 6481 ) |
6394 ;;;_ > allout-adjust-file-variable (varname value) | 6482 ;;;_ > allout-adjust-file-variable (varname value) |
6395 (defun allout-adjust-file-variable (varname value) | 6483 (defun allout-adjust-file-variable (varname value) |
6396 "Adjust the setting of an emacs file variable named VARNAME to VALUE. | 6484 "Adjust the setting of an Emacs file variable named VARNAME to VALUE. |
6397 | 6485 |
6398 This activity is inhibited if either `enable-local-variables' | 6486 This activity is inhibited if either `enable-local-variables' |
6399 `allout-enable-file-variable-adjustment' are nil. | 6487 `allout-enable-file-variable-adjustment' are nil. |
6400 | 6488 |
6401 When enabled, an entry for the variable is created if not already present, | 6489 When enabled, an entry for the variable is created if not already present, |
6402 or changed if established with a different value. The section for the file | 6490 or changed if established with a different value. The section for the file |
6403 variables, itself, is created if not already present. When created, the | 6491 variables, itself, is created if not already present. When created, the |
6404 section lines \(including the section line) exist as second-level topics in | 6492 section lines \(including the section line) exist as second-level topics in |
6405 a top-level topic at the end of the file. | 6493 a top-level topic at the end of the file. |
6406 | 6494 |
6407 enable-local-variables must be true for any of this to happen." | 6495 `enable-local-variables' must be true for any of this to happen." |
6408 (if (not (and enable-local-variables | 6496 (if (not (and enable-local-variables |
6409 allout-enable-file-variable-adjustment)) | 6497 allout-enable-file-variable-adjustment)) |
6410 nil | 6498 nil |
6411 (save-excursion | 6499 (save-excursion |
6412 (let ((inhibit-field-text-motion t) | 6500 (let ((inhibit-field-text-motion t) |