Mercurial > emacs
comparison lisp/allout.el @ 73003:ec72ab6f5541
* allout.el (allout-unprotected): Let inhibit-read-only only when
buffer-read-only isn't set.
(allout-annotate-hidden): Enable topic annotation during copies even
when the buffer is read-only, eg for topic copies. Ensure that the loop
advances, even when the span extends beyond the deletion region.
(allout-toggle-subtree-encryption): Use allout-structure-added-hook
rather than allout-exposure-changed-hook, as a stronger assertion.
(allout-keybindings-list): Add bindings for
allout-copy-line-as-kill and allout-copy-topic-as-kill.
(allout-copy-line-as-kill, allout-copy-topic-as-kill): copy
wrappers for allout-kill-line and allout-kill-topic.
(allout-listify-exposed): Position correctly to accumulate lines.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Tue, 19 Sep 2006 21:55:44 +0000 |
parents | 17942cb3949e |
children | 16a7031b0447 b5c13d1564a9 |
comparison
equal
deleted
inserted
replaced
73002:b3a72607819d | 73003:ec72ab6f5541 |
---|---|
696 ("<" allout-shift-out) | 696 ("<" allout-shift-out) |
697 ("\C-m" allout-rebullet-topic) | 697 ("\C-m" allout-rebullet-topic) |
698 ("*" allout-rebullet-current-heading) | 698 ("*" allout-rebullet-current-heading) |
699 ("#" allout-number-siblings) | 699 ("#" allout-number-siblings) |
700 ("\C-k" allout-kill-line t) | 700 ("\C-k" allout-kill-line t) |
701 ("\M-k" allout-copy-line-as-kill t) | |
701 ("\C-y" allout-yank t) | 702 ("\C-y" allout-yank t) |
702 ("\M-y" allout-yank-pop t) | 703 ("\M-y" allout-yank-pop t) |
703 ("\C-k" allout-kill-topic) | 704 ("\C-k" allout-kill-topic) |
705 ("\M-k" allout-copy-topic-as-kill) | |
704 ; Miscellaneous commands: | 706 ; Miscellaneous commands: |
705 ;([?\C-\ ] allout-mark-topic) | 707 ;([?\C-\ ] allout-mark-topic) |
706 ("@" allout-resolve-xref) | 708 ("@" allout-resolve-xref) |
707 ("=c" allout-copy-exposed-to-buffer) | 709 ("=c" allout-copy-exposed-to-buffer) |
708 ("=i" allout-indented-exposed-to-buffer) | 710 ("=i" allout-indented-exposed-to-buffer) |
1277 (set name (car value-cell)))))) | 1279 (set name (car value-cell)))))) |
1278 ;;;_ : Mode-specific incidentals | 1280 ;;;_ : Mode-specific incidentals |
1279 ;;;_ > allout-unprotected (expr) | 1281 ;;;_ > allout-unprotected (expr) |
1280 (defmacro allout-unprotected (expr) | 1282 (defmacro allout-unprotected (expr) |
1281 "Enable internal outline operations to alter invisible text." | 1283 "Enable internal outline operations to alter invisible text." |
1282 `(let ((inhibit-read-only t) | 1284 `(let ((inhibit-read-only (if (not buffer-read-only) t)) |
1283 (inhibit-field-text-motion t)) | 1285 (inhibit-field-text-motion t)) |
1284 ,expr)) | 1286 ,expr)) |
1285 ;;;_ = allout-mode-hook | 1287 ;;;_ = allout-mode-hook |
1286 (defvar allout-mode-hook nil | 1288 (defvar allout-mode-hook nil |
1287 "*Hook that's run when allout mode starts.") | 1289 "*Hook that's run when allout mode starts.") |
1691 count, revoke numbering. | 1693 count, revoke numbering. |
1692 | 1694 |
1693 Topic-oriented Killing and Yanking: | 1695 Topic-oriented Killing and Yanking: |
1694 ---------------------------------- | 1696 ---------------------------------- |
1695 \\[allout-kill-topic] allout-kill-topic Kill current topic, including offspring. | 1697 \\[allout-kill-topic] allout-kill-topic Kill current topic, including offspring. |
1696 \\[allout-kill-line] allout-kill-line Like kill-line, but reconciles numbering, etc. | 1698 \\[allout-copy-topic-as-kill] allout-copy-topic-as-kill Copy current topic, including offspring. |
1699 \\[allout-kill-line] allout-kill-line kill-line, attending to outline structure. | |
1700 \\[allout-copy-line-as-kill] allout-copy-line-as-kill Copy line but don't delete it. | |
1697 \\[allout-yank] allout-yank Yank, adjusting depth of yanked topic to | 1701 \\[allout-yank] allout-yank Yank, adjusting depth of yanked topic to |
1698 depth of heading if yanking into bare topic | 1702 depth of heading if yanking into bare topic |
1699 heading (ie, prefix sans text). | 1703 heading (ie, prefix sans text). |
1700 \\[allout-yank-pop] allout-yank-pop Is to allout-yank as yank-pop is to yank | 1704 \\[allout-yank-pop] allout-yank-pop Is to allout-yank as yank-pop is to yank |
1701 | 1705 |
2085 (goto-char start)))) | 2089 (goto-char start)))) |
2086 ;;;_ > allout-before-change-handler (beg end) | 2090 ;;;_ > allout-before-change-handler (beg end) |
2087 (defun allout-before-change-handler (beg end) | 2091 (defun allout-before-change-handler (beg end) |
2088 "Protect against changes to invisible text. | 2092 "Protect against changes to invisible text. |
2089 | 2093 |
2090 See allout-overlay-interior-modification-handler for details. | 2094 See allout-overlay-interior-modification-handler for details." |
2091 | |
2092 This before-change handler is used only where modification-hooks | |
2093 overlay property is not supported." | |
2094 | 2095 |
2095 (if (and (allout-mode-p) undo-in-progress (allout-hidden-p)) | 2096 (if (and (allout-mode-p) undo-in-progress (allout-hidden-p)) |
2096 (allout-show-to-offshoot)) | 2097 (allout-show-to-offshoot)) |
2097 | 2098 |
2098 ;; allout-overlay-interior-modification-handler on an overlay handles | 2099 ;; allout-overlay-interior-modification-handler on an overlay handles |
4185 (save-excursion ; Renumber subsequent topics if needed: | 4186 (save-excursion ; Renumber subsequent topics if needed: |
4186 (if (not (looking-at allout-regexp)) | 4187 (if (not (looking-at allout-regexp)) |
4187 (allout-next-heading)) | 4188 (allout-next-heading)) |
4188 (allout-renumber-to-depth depth))) | 4189 (allout-renumber-to-depth depth))) |
4189 (run-hook-with-args 'allout-structure-deleted-hook depth (point))))) | 4190 (run-hook-with-args 'allout-structure-deleted-hook depth (point))))) |
4191 ;;;_ > allout-copy-line-as-kill () | |
4192 (defun allout-copy-line-as-kill () | |
4193 "Like allout-kill-topic, but save to kill ring instead of deleting." | |
4194 (interactive) | |
4195 (let ((buffer-read-only t)) | |
4196 (condition-case nil | |
4197 (allout-kill-line) | |
4198 (buffer-read-only nil)))) | |
4190 ;;;_ > allout-kill-topic () | 4199 ;;;_ > allout-kill-topic () |
4191 (defun allout-kill-topic () | 4200 (defun allout-kill-topic () |
4192 "Kill topic together with subtopics. | 4201 "Kill topic together with subtopics. |
4193 | 4202 |
4194 Trailing whitespace is killed with a topic if that whitespace: | 4203 Trailing whitespace is killed with a topic if that whitespace: |
4221 | 4230 |
4222 (allout-unprotected (kill-region beg (point))) | 4231 (allout-unprotected (kill-region beg (point))) |
4223 (save-excursion | 4232 (save-excursion |
4224 (allout-renumber-to-depth depth)) | 4233 (allout-renumber-to-depth depth)) |
4225 (run-hook-with-args 'allout-structure-deleted-hook depth (point)))) | 4234 (run-hook-with-args 'allout-structure-deleted-hook depth (point)))) |
4235 ;;;_ > allout-copy-topic-as-kill () | |
4236 (defun allout-copy-topic-as-kill () | |
4237 "Like allout-kill-topic, but save to kill ring instead of deleting." | |
4238 (interactive) | |
4239 (let ((buffer-read-only t)) | |
4240 (condition-case nil | |
4241 (allout-kill-topic) | |
4242 (buffer-read-only (message "Topic copied..."))))) | |
4226 ;;;_ > allout-annotate-hidden (begin end) | 4243 ;;;_ > allout-annotate-hidden (begin end) |
4227 (defun allout-annotate-hidden (begin end) | 4244 (defun allout-annotate-hidden (begin end) |
4228 "Qualify text with properties to indicate exposure status." | 4245 "Qualify text with properties to indicate exposure status." |
4229 | 4246 |
4230 (let ((was-modified (buffer-modified-p))) | 4247 (let ((was-modified (buffer-modified-p)) |
4248 (buffer-read-only nil)) | |
4231 (allout-unprotected | 4249 (allout-unprotected |
4232 (remove-text-properties begin end '(allout-was-hidden t))) | 4250 (remove-text-properties begin end '(allout-was-hidden t))) |
4233 (save-excursion | 4251 (save-excursion |
4234 (goto-char begin) | 4252 (goto-char begin) |
4235 (let (done next prev overlay) | 4253 (let (done next prev overlay) |
4236 (while (not done) | 4254 (while (not done) |
4237 ;; at or advance to start of next hidden region: | 4255 ;; at or advance to start of next hidden region: |
4238 (if (not (allout-hidden-p)) | 4256 (if (not (allout-hidden-p)) |
4239 (setq next | 4257 (setq next |
4240 (next-single-char-property-change (point) | 4258 (max (1+ (point)) |
4241 'invisible nil end))) | 4259 (next-single-char-property-change (point) |
4260 'invisible | |
4261 nil end)))) | |
4242 (if (or (not next) (eq prev next)) | 4262 (if (or (not next) (eq prev next)) |
4243 ;; still not at start of hidden area - must not be any left. | 4263 ;; still not at start of hidden area - must not be any left. |
4244 (setq done t) | 4264 (setq done t) |
4245 (goto-char next) | 4265 (goto-char next) |
4246 (setq prev next) | 4266 (setq prev next) |
5167 (progn | 5187 (progn |
5168 (end-of-line) | 5188 (end-of-line) |
5169 (allout-back-to-visible-text))) | 5189 (allout-back-to-visible-text))) |
5170 strings)) | 5190 strings)) |
5171 (when (< (point) next) ; Resume from after hid text, if any. | 5191 (when (< (point) next) ; Resume from after hid text, if any. |
5172 (line-move 1)) | 5192 (line-move 1) |
5193 (beginning-of-line)) | |
5173 (setq beg (point))) | 5194 (setq beg (point))) |
5174 ;; Accumulate list for this topic: | 5195 ;; Accumulate list for this topic: |
5175 (setq strings (nreverse strings)) | 5196 (setq strings (nreverse strings)) |
5176 (setq result | 5197 (setq result |
5177 (cons | 5198 (cons |
5743 (progn (goto-char after-bullet-pos) | 5764 (progn (goto-char after-bullet-pos) |
5744 (delete-char 1)) | 5765 (delete-char 1)) |
5745 ;; Add the is-encrypted bullet qualifier: | 5766 ;; Add the is-encrypted bullet qualifier: |
5746 (goto-char after-bullet-pos) | 5767 (goto-char after-bullet-pos) |
5747 (insert "*")))) | 5768 (insert "*")))) |
5748 (run-hook-with-args 'allout-exposure-changed-hook | 5769 (run-hook-with-args 'allout-structure-added-hook |
5749 bullet-pos subtree-end nil)))) | 5770 bullet-pos subtree-end)))) |
5750 ;;;_ > allout-encrypt-string (text decrypt allout-buffer key-type for-key | 5771 ;;;_ > allout-encrypt-string (text decrypt allout-buffer key-type for-key |
5751 ;;; fetch-pass &optional retried verifying | 5772 ;;; fetch-pass &optional retried verifying |
5752 ;;; passphrase) | 5773 ;;; passphrase) |
5753 (defun allout-encrypt-string (text decrypt allout-buffer key-type for-key | 5774 (defun allout-encrypt-string (text decrypt allout-buffer key-type for-key |
5754 fetch-pass &optional retried rejected | 5775 fetch-pass &optional retried rejected |