diff options
| author | Stefan Merten | 2012-09-17 19:38:09 +0200 |
|---|---|---|
| committer | Stefan Merten | 2012-09-17 19:38:09 +0200 |
| commit | 64f6a73693f25b2f59a4474bea86cb92bd05bf8e (patch) | |
| tree | 86cf563b1b26fd20e427a83bf12411250cfaba3b /lisp | |
| parent | 6b250df6149155f30391fda3e18658410800867d (diff) | |
| download | emacs-64f6a73693f25b2f59a4474bea86cb92bd05bf8e.tar.gz emacs-64f6a73693f25b2f59a4474bea86cb92bd05bf8e.zip | |
2012-09-17 Stefan Merten <smerten@oekonux.de>
* rst.el: Add support for `testcover'.
(rst-defcustom-testcover, rst-testcover-add-compose)
(rst-testcover-add-1value): New functions.
(rst-portable-mark-active-p): Replace by `use-region-p'.
(rst-update-section, rst-classify-adornment)
(rst-find-title-line): Mark `1value' forms.
(rst-classify-adornment): Remove superfluous form.
(rst-update-section, rst-get-adornments-around)
(rst-adornment-complete-p, rst-get-next-adornment)
(rst-adjust, rst-promote-region)
(rst-display-adornments-hierarchy, rst-straighten-adornments)
(rst-find-pfx-in-region, rst-section-tree-rec)
(rst-section-tree-point, rst-toc-insert, rst-toc-insert-node)
(rst-toc-node, rst-toc, rst-forward-section)
(rst-iterate-leftmost-paragraphs)
(rst-iterate-leftmost-paragraphs-2, rst-enumerate-region)
(rst-bullet-list-region)
(rst-convert-bullets-to-enumeration, rst-font-lock-keywords)
(rst-compile-find-conf, rst-compile)
(rst-repeat-last-character): Fix style.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 23 | ||||
| -rw-r--r-- | lisp/textmodes/rst.el | 262 |
2 files changed, 166 insertions, 119 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 5c556697cb0..7ceacc5291d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,26 @@ | |||
| 1 | 2012-09-17 Stefan Merten <smerten@oekonux.de> | ||
| 2 | |||
| 3 | * rst.el: Add support for `testcover'. | ||
| 4 | (rst-defcustom-testcover, rst-testcover-add-compose) | ||
| 5 | (rst-testcover-add-1value): New functions. | ||
| 6 | (rst-portable-mark-active-p): Replace by `use-region-p'. | ||
| 7 | (rst-update-section, rst-classify-adornment) | ||
| 8 | (rst-find-title-line): Mark `1value' forms. | ||
| 9 | (rst-classify-adornment): Remove superfluous form. | ||
| 10 | (rst-update-section, rst-get-adornments-around) | ||
| 11 | (rst-adornment-complete-p, rst-get-next-adornment) | ||
| 12 | (rst-adjust, rst-promote-region) | ||
| 13 | (rst-display-adornments-hierarchy, rst-straighten-adornments) | ||
| 14 | (rst-find-pfx-in-region, rst-section-tree-rec) | ||
| 15 | (rst-section-tree-point, rst-toc-insert, rst-toc-insert-node) | ||
| 16 | (rst-toc-node, rst-toc, rst-forward-section) | ||
| 17 | (rst-iterate-leftmost-paragraphs) | ||
| 18 | (rst-iterate-leftmost-paragraphs-2, rst-enumerate-region) | ||
| 19 | (rst-bullet-list-region) | ||
| 20 | (rst-convert-bullets-to-enumeration, rst-font-lock-keywords) | ||
| 21 | (rst-compile-find-conf, rst-compile) | ||
| 22 | (rst-repeat-last-character): Fix style. | ||
| 23 | |||
| 1 | 2012-09-17 Chong Yidong <cyd@gnu.org> | 24 | 2012-09-17 Chong Yidong <cyd@gnu.org> |
| 2 | 25 | ||
| 3 | * comint.el (comint--complete-file-name-data): Don't add a space | 26 | * comint.el (comint--complete-file-name-data): Don't add a space |
diff --git a/lisp/textmodes/rst.el b/lisp/textmodes/rst.el index e2647a98770..47a821c0148 100644 --- a/lisp/textmodes/rst.el +++ b/lisp/textmodes/rst.el | |||
| @@ -103,11 +103,51 @@ | |||
| 103 | 103 | ||
| 104 | ;;; Code: | 104 | ;;; Code: |
| 105 | 105 | ||
| 106 | ;; FIXME: Check through major mode conventions again. | ||
| 107 | |||
| 106 | ;; FIXME: Add proper ";;;###autoload" comments. | 108 | ;; FIXME: Add proper ";;;###autoload" comments. |
| 107 | 109 | ||
| 108 | ;; FIXME: When 24.1 is common place remove use of `lexical-let' and put "-*- | 110 | ;; FIXME: When 24.1 is common place remove use of `lexical-let' and put "-*- |
| 109 | ;; lexical-binding: t -*-" in the first line. | 111 | ;; lexical-binding: t -*-" in the first line. |
| 110 | 112 | ||
| 113 | ;; FIXME: Use `testcover'. | ||
| 114 | |||
| 115 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| 116 | ;; Support for `testcover' | ||
| 117 | |||
| 118 | (when (boundp 'testcover-1value-functions) | ||
| 119 | ;; Below `lambda' is used in a loop with varying parameters and is thus not | ||
| 120 | ;; 1valued. | ||
| 121 | (setq testcover-1value-functions | ||
| 122 | (delq 'lambda testcover-1value-functions)) | ||
| 123 | (add-to-list 'testcover-compose-functions 'lambda)) | ||
| 124 | |||
| 125 | (defun rst-testcover-defcustom () | ||
| 126 | "Remove all customized variables from `testcover-module-constants'. | ||
| 127 | This seems to be a bug in `testcover': `defcustom' variables are | ||
| 128 | considered constants. Revert it with this function after each `defcustom'." | ||
| 129 | (when (boundp 'testcover-module-constants) | ||
| 130 | (setq testcover-module-constants | ||
| 131 | (delq nil | ||
| 132 | (mapcar | ||
| 133 | (lambda (sym) | ||
| 134 | (if (not (plist-member (symbol-plist sym) 'standard-value)) | ||
| 135 | sym)) | ||
| 136 | testcover-module-constants))))) | ||
| 137 | |||
| 138 | (defun rst-testcover-add-compose (fun) | ||
| 139 | "Add FUN to `testcover-compose-functions'." | ||
| 140 | (when (boundp 'testcover-compose-functions) | ||
| 141 | (add-to-list 'testcover-compose-functions fun))) | ||
| 142 | |||
| 143 | (defun rst-testcover-add-1value (fun) | ||
| 144 | "Add FUN to `testcover-1value-functions'." | ||
| 145 | (when (boundp 'testcover-1value-functions) | ||
| 146 | (add-to-list 'testcover-1value-functions fun))) | ||
| 147 | |||
| 148 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| 149 | ;; Common Lisp stuff | ||
| 150 | |||
| 111 | ;; Only use of macros is allowed - may be replaced by `cl-lib' some time. | 151 | ;; Only use of macros is allowed - may be replaced by `cl-lib' some time. |
| 112 | (eval-when-compile | 152 | (eval-when-compile |
| 113 | (require 'cl)) | 153 | (require 'cl)) |
| @@ -160,6 +200,7 @@ Comparison done with `equal'." | |||
| 160 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 200 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 161 | ;; Versions | 201 | ;; Versions |
| 162 | 202 | ||
| 203 | ;; testcover: ok. | ||
| 163 | (defun rst-extract-version (delim-re head-re re tail-re var &optional default) | 204 | (defun rst-extract-version (delim-re head-re re tail-re var &optional default) |
| 164 | "Extract the version from a variable according to the given regexes. | 205 | "Extract the version from a variable according to the given regexes. |
| 165 | Return the version after regex DELIM-RE and HEAD-RE matching RE | 206 | Return the version after regex DELIM-RE and HEAD-RE matching RE |
| @@ -173,7 +214,7 @@ and before TAIL-RE and DELIM-RE in VAR or DEFAULT for no match." | |||
| 173 | ;; Use CVSHeader to really get information from CVS and not other version | 214 | ;; Use CVSHeader to really get information from CVS and not other version |
| 174 | ;; control systems. | 215 | ;; control systems. |
| 175 | (defconst rst-cvs-header | 216 | (defconst rst-cvs-header |
| 176 | "$CVSHeader: sm/rst_el/rst.el,v 1.301 2012-07-30 19:29:46 stefan Exp $") | 217 | "$CVSHeader: sm/rst_el/rst.el,v 1.309.2.1 2012-09-17 17:30:49 stefan Exp $") |
| 177 | (defconst rst-cvs-rev | 218 | (defconst rst-cvs-rev |
| 178 | (rst-extract-version "\\$" "CVSHeader: \\S + " "[0-9]+\\(?:\\.[0-9]+\\)+" | 219 | (rst-extract-version "\\$" "CVSHeader: \\S + " "[0-9]+\\(?:\\.[0-9]+\\)+" |
| 179 | " .*" rst-cvs-header "0.0") | 220 | " .*" rst-cvs-header "0.0") |
| @@ -483,6 +524,8 @@ argument list for `rst-re'.") | |||
| 483 | (defvar rst-re-alist) ; Forward declare to use it in `rst-re'. | 524 | (defvar rst-re-alist) ; Forward declare to use it in `rst-re'. |
| 484 | 525 | ||
| 485 | ;; FIXME: Use `sregex` or `rx` instead of re-inventing the wheel. | 526 | ;; FIXME: Use `sregex` or `rx` instead of re-inventing the wheel. |
| 527 | (rst-testcover-add-compose 'rst-re) | ||
| 528 | ;; testcover: ok. | ||
| 486 | (defun rst-re (&rest args) | 529 | (defun rst-re (&rest args) |
| 487 | "Interpret ARGS as regular expressions and return a regex string. | 530 | "Interpret ARGS as regular expressions and return a regex string. |
| 488 | Each element of ARGS may be one of the following: | 531 | Each element of ARGS may be one of the following: |
| @@ -556,6 +599,7 @@ After interpretation of ARGS the results are concatenated as for | |||
| 556 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 599 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 557 | ;; Mode definition | 600 | ;; Mode definition |
| 558 | 601 | ||
| 602 | ;; testcover: ok. | ||
| 559 | (defun rst-define-key (keymap key def &rest deprecated) | 603 | (defun rst-define-key (keymap key def &rest deprecated) |
| 560 | "Bind like `define-key' but add deprecated key definitions. | 604 | "Bind like `define-key' but add deprecated key definitions. |
| 561 | KEYMAP, KEY, and DEF are as in `define-key'. DEPRECATED key | 605 | KEYMAP, KEY, and DEF are as in `define-key'. DEPRECATED key |
| @@ -734,6 +778,7 @@ This inherits from Text mode.") | |||
| 734 | The hook for `text-mode' is run before this one." | 778 | The hook for `text-mode' is run before this one." |
| 735 | :group 'rst | 779 | :group 'rst |
| 736 | :type '(hook)) | 780 | :type '(hook)) |
| 781 | (rst-testcover-defcustom) | ||
| 737 | 782 | ||
| 738 | ;; Pull in variable definitions silencing byte-compiler. | 783 | ;; Pull in variable definitions silencing byte-compiler. |
| 739 | (require 'newcomment) | 784 | (require 'newcomment) |
| @@ -949,6 +994,7 @@ file." | |||
| 949 | (const :tag "Underline only" simple)) | 994 | (const :tag "Underline only" simple)) |
| 950 | (integer :tag "Indentation for overline and underline type" | 995 | (integer :tag "Indentation for overline and underline type" |
| 951 | :value 0)))) | 996 | :value 0)))) |
| 997 | (rst-testcover-defcustom) | ||
| 952 | 998 | ||
| 953 | (defcustom rst-default-indent 1 | 999 | (defcustom rst-default-indent 1 |
| 954 | "Number of characters to indent the section title. | 1000 | "Number of characters to indent the section title. |
| @@ -958,7 +1004,7 @@ from a simple adornment style to a over-and-under adornment | |||
| 958 | style." | 1004 | style." |
| 959 | :group 'rst-adjust | 1005 | :group 'rst-adjust |
| 960 | :type '(integer)) | 1006 | :type '(integer)) |
| 961 | 1007 | (rst-testcover-defcustom) | |
| 962 | 1008 | ||
| 963 | (defun rst-compare-adornments (ado1 ado2) | 1009 | (defun rst-compare-adornments (ado1 ado2) |
| 964 | "Compare adornments. | 1010 | "Compare adornments. |
| @@ -979,7 +1025,8 @@ not found." | |||
| 979 | (setq cur (cdr cur))) | 1025 | (setq cur (cdr cur))) |
| 980 | cur)) | 1026 | cur)) |
| 981 | 1027 | ||
| 982 | 1028 | ;; testcover: FIXME: Test with `rst-preferred-adornments' == nil. Add test | |
| 1029 | ;; `rst-adjust-no-preference'. | ||
| 983 | (defun rst-suggest-new-adornment (allados &optional prev) | 1030 | (defun rst-suggest-new-adornment (allados &optional prev) |
| 984 | "Suggest a new, different adornment from all that have been seen. | 1031 | "Suggest a new, different adornment from all that have been seen. |
| 985 | 1032 | ||
| @@ -1032,7 +1079,7 @@ requested adornment." | |||
| 1032 | len) | 1079 | len) |
| 1033 | 1080 | ||
| 1034 | ;; Fixup whitespace at the beginning and end of the line. | 1081 | ;; Fixup whitespace at the beginning and end of the line. |
| 1035 | (if (or (null indent) (eq style 'simple)) | 1082 | (if (or (null indent) (eq style 'simple)) ;; testcover: ok. |
| 1036 | (setq indent 0)) | 1083 | (setq indent 0)) |
| 1037 | (beginning-of-line) | 1084 | (beginning-of-line) |
| 1038 | (delete-horizontal-space) | 1085 | (delete-horizontal-space) |
| @@ -1046,7 +1093,8 @@ requested adornment." | |||
| 1046 | 1093 | ||
| 1047 | ;; Remove previous line if it is an adornment. | 1094 | ;; Remove previous line if it is an adornment. |
| 1048 | (save-excursion | 1095 | (save-excursion |
| 1049 | (forward-line -1) | 1096 | (forward-line -1) ;; testcover: FIXME: Doesn't work when in first line |
| 1097 | ;; of buffer. | ||
| 1050 | (if (and (looking-at (rst-re 'ado-beg-2-1)) | 1098 | (if (and (looking-at (rst-re 'ado-beg-2-1)) |
| 1051 | ;; Avoid removing the underline of a title right above us. | 1099 | ;; Avoid removing the underline of a title right above us. |
| 1052 | (save-excursion (forward-line -1) | 1100 | (save-excursion (forward-line -1) |
| @@ -1055,7 +1103,8 @@ requested adornment." | |||
| 1055 | 1103 | ||
| 1056 | ;; Remove following line if it is an adornment. | 1104 | ;; Remove following line if it is an adornment. |
| 1057 | (save-excursion | 1105 | (save-excursion |
| 1058 | (forward-line +1) | 1106 | (forward-line +1) ;; testcover: FIXME: Doesn't work when in last line |
| 1107 | ;; of buffer. | ||
| 1059 | (if (looking-at (rst-re 'ado-beg-2-1)) | 1108 | (if (looking-at (rst-re 'ado-beg-2-1)) |
| 1060 | (rst-delete-entire-line)) | 1109 | (rst-delete-entire-line)) |
| 1061 | ;; Add a newline if we're at the end of the buffer, for the subsequence | 1110 | ;; Add a newline if we're at the end of the buffer, for the subsequence |
| @@ -1071,13 +1120,14 @@ requested adornment." | |||
| 1071 | (insert (make-string len char)))) | 1120 | (insert (make-string len char)))) |
| 1072 | 1121 | ||
| 1073 | ;; Insert underline. | 1122 | ;; Insert underline. |
| 1074 | (forward-line +1) | 1123 | (1value ;; Line has been inserted above. |
| 1124 | (forward-line +1)) | ||
| 1075 | (open-line 1) | 1125 | (open-line 1) |
| 1076 | (insert (make-string len char)) | 1126 | (insert (make-string len char)) |
| 1077 | 1127 | ||
| 1078 | (forward-line +1) | 1128 | (1value ;; Line has been inserted above. |
| 1079 | (goto-char marker) | 1129 | (forward-line +1)) |
| 1080 | )) | 1130 | (goto-char marker))) |
| 1081 | 1131 | ||
| 1082 | (defun rst-classify-adornment (adornment end) | 1132 | (defun rst-classify-adornment (adornment end) |
| 1083 | "Classify adornment for section titles and transitions. | 1133 | "Classify adornment for section titles and transitions. |
| @@ -1104,11 +1154,14 @@ Return nil if no syntactically valid adornment is found." | |||
| 1104 | (ado-re (rst-re ado-ch 'adorep3-hlp)) | 1154 | (ado-re (rst-re ado-ch 'adorep3-hlp)) |
| 1105 | (end-pnt (point)) | 1155 | (end-pnt (point)) |
| 1106 | (beg-pnt (progn | 1156 | (beg-pnt (progn |
| 1107 | (forward-line 0) | 1157 | (1value ;; No lines may be left to move. |
| 1158 | (forward-line 0)) | ||
| 1108 | (point))) | 1159 | (point))) |
| 1109 | (nxt-emp ; Next line nonexistent or empty | 1160 | (nxt-emp ; Next line nonexistent or empty |
| 1110 | (save-excursion | 1161 | (save-excursion |
| 1111 | (or (not (zerop (forward-line 1))) | 1162 | (or (not (zerop (forward-line 1))) |
| 1163 | ;; testcover: FIXME: Add test classifying at the end of | ||
| 1164 | ;; buffer. | ||
| 1112 | (looking-at (rst-re 'lin-end))))) | 1165 | (looking-at (rst-re 'lin-end))))) |
| 1113 | (prv-emp ; Previous line nonexistent or empty | 1166 | (prv-emp ; Previous line nonexistent or empty |
| 1114 | (save-excursion | 1167 | (save-excursion |
| @@ -1117,7 +1170,9 @@ Return nil if no syntactically valid adornment is found." | |||
| 1117 | (ttl-blw ; Title found below starting here. | 1170 | (ttl-blw ; Title found below starting here. |
| 1118 | (save-excursion | 1171 | (save-excursion |
| 1119 | (and | 1172 | (and |
| 1120 | (zerop (forward-line 1)) | 1173 | (zerop (forward-line 1)) ;; testcover: FIXME: Add test |
| 1174 | ;; classifying at the end of | ||
| 1175 | ;; buffer. | ||
| 1121 | (looking-at (rst-re 'ttl-beg)) | 1176 | (looking-at (rst-re 'ttl-beg)) |
| 1122 | (point)))) | 1177 | (point)))) |
| 1123 | (ttl-abv ; Title found above starting here. | 1178 | (ttl-abv ; Title found above starting here. |
| @@ -1129,7 +1184,9 @@ Return nil if no syntactically valid adornment is found." | |||
| 1129 | (und-fnd ; Matching underline found starting here. | 1184 | (und-fnd ; Matching underline found starting here. |
| 1130 | (save-excursion | 1185 | (save-excursion |
| 1131 | (and ttl-blw | 1186 | (and ttl-blw |
| 1132 | (zerop (forward-line 2)) | 1187 | (zerop (forward-line 2)) ;; testcover: FIXME: Add test |
| 1188 | ;; classifying at the end of | ||
| 1189 | ;; buffer. | ||
| 1133 | (looking-at (rst-re ado-re 'lin-end)) | 1190 | (looking-at (rst-re ado-re 'lin-end)) |
| 1134 | (point)))) | 1191 | (point)))) |
| 1135 | (ovr-fnd ; Matching overline found starting here. | 1192 | (ovr-fnd ; Matching overline found starting here. |
| @@ -1174,8 +1231,8 @@ Return nil if no syntactically valid adornment is found." | |||
| 1174 | (setq key nil))) | 1231 | (setq key nil))) |
| 1175 | (if key | 1232 | (if key |
| 1176 | (list key | 1233 | (list key |
| 1177 | (or beg-ovr beg-txt beg-und) | 1234 | (or beg-ovr beg-txt) |
| 1178 | (or end-und end-txt end-ovr) | 1235 | (or end-und end-txt) |
| 1179 | beg-ovr end-ovr beg-txt end-txt beg-und end-und))))))) | 1236 | beg-ovr end-ovr beg-txt end-txt beg-und end-und))))))) |
| 1180 | 1237 | ||
| 1181 | (defun rst-find-title-line () | 1238 | (defun rst-find-title-line () |
| @@ -1193,7 +1250,8 @@ in the first element. If there is no adornment around the title | |||
| 1193 | CHARACTER is also nil and match groups for overline and underline | 1250 | CHARACTER is also nil and match groups for overline and underline |
| 1194 | are nil." | 1251 | are nil." |
| 1195 | (save-excursion | 1252 | (save-excursion |
| 1196 | (forward-line 0) | 1253 | (1value ;; No lines may be left to move. |
| 1254 | (forward-line 0)) | ||
| 1197 | (let ((orig-pnt (point)) | 1255 | (let ((orig-pnt (point)) |
| 1198 | (orig-end (line-end-position))) | 1256 | (orig-end (line-end-position))) |
| 1199 | (cond | 1257 | (cond |
| @@ -1253,6 +1311,7 @@ t when no section adornments were found. Value depends on | |||
| 1253 | `rst-all-sections'.") | 1311 | `rst-all-sections'.") |
| 1254 | (make-variable-buffer-local 'rst-section-hierarchy) | 1312 | (make-variable-buffer-local 'rst-section-hierarchy) |
| 1255 | 1313 | ||
| 1314 | (rst-testcover-add-1value 'rst-reset-section-caches) | ||
| 1256 | (defun rst-reset-section-caches () | 1315 | (defun rst-reset-section-caches () |
| 1257 | "Reset all section cache variables. | 1316 | "Reset all section cache variables. |
| 1258 | Should be called by interactive functions which deal with sections." | 1317 | Should be called by interactive functions which deal with sections." |
| @@ -1354,9 +1413,7 @@ Return a list of the previous and next adornments." | |||
| 1354 | (if (and cur (caar cur)) | 1413 | (if (and cur (caar cur)) |
| 1355 | (setq next (if (= curline (caar cur)) (cdr cur) cur))) | 1414 | (setq next (if (= curline (caar cur)) (cdr cur) cur))) |
| 1356 | 1415 | ||
| 1357 | (mapcar 'cdar (list prev next)) | 1416 | (mapcar 'cdar (list prev next)))) |
| 1358 | )) | ||
| 1359 | |||
| 1360 | 1417 | ||
| 1361 | (defun rst-adornment-complete-p (ado) | 1418 | (defun rst-adornment-complete-p (ado) |
| 1362 | "Return true if the adornment ADO around point is complete." | 1419 | "Return true if the adornment ADO around point is complete." |
| @@ -1369,8 +1426,7 @@ Return a list of the previous and next adornments." | |||
| 1369 | (let* ((char (car ado)) | 1426 | (let* ((char (car ado)) |
| 1370 | (style (cadr ado)) | 1427 | (style (cadr ado)) |
| 1371 | (indent (caddr ado)) | 1428 | (indent (caddr ado)) |
| 1372 | (endcol (save-excursion (end-of-line) (current-column))) | 1429 | (endcol (save-excursion (end-of-line) (current-column)))) |
| 1373 | ) | ||
| 1374 | (if char | 1430 | (if char |
| 1375 | (let ((exps (rst-re "^" char (format "\\{%d\\}" (+ endcol indent)) "$"))) | 1431 | (let ((exps (rst-re "^" char (format "\\{%d\\}" (+ endcol indent)) "$"))) |
| 1376 | (and | 1432 | (and |
| @@ -1380,9 +1436,7 @@ Return a list of the previous and next adornments." | |||
| 1380 | (or (not (eq style 'over-and-under)) | 1436 | (or (not (eq style 'over-and-under)) |
| 1381 | (save-excursion (forward-line -1) | 1437 | (save-excursion (forward-line -1) |
| 1382 | (beginning-of-line) | 1438 | (beginning-of-line) |
| 1383 | (looking-at exps)))) | 1439 | (looking-at exps)))))))) |
| 1384 | )) | ||
| 1385 | )) | ||
| 1386 | 1440 | ||
| 1387 | 1441 | ||
| 1388 | (defun rst-get-next-adornment | 1442 | (defun rst-get-next-adornment |
| @@ -1414,8 +1468,7 @@ REVERSE-DIRECTION is used to reverse the cycling order." | |||
| 1414 | cur)) | 1468 | cur)) |
| 1415 | 1469 | ||
| 1416 | ;; If not found, take the first of all adornments. | 1470 | ;; If not found, take the first of all adornments. |
| 1417 | suggestion | 1471 | suggestion))) |
| 1418 | ))) | ||
| 1419 | 1472 | ||
| 1420 | 1473 | ||
| 1421 | ;; FIXME: A line "``/`` full" is not accepted as a section title. | 1474 | ;; FIXME: A line "``/`` full" is not accepted as a section title. |
| @@ -1456,7 +1509,7 @@ b. a negative numerical argument, which generally inverts the | |||
| 1456 | (reverse-direction (and pfxarg (< (prefix-numeric-value pfxarg) 0))) | 1509 | (reverse-direction (and pfxarg (< (prefix-numeric-value pfxarg) 0))) |
| 1457 | (toggle-style (and pfxarg (not reverse-direction)))) | 1510 | (toggle-style (and pfxarg (not reverse-direction)))) |
| 1458 | 1511 | ||
| 1459 | (if (rst-portable-mark-active-p) | 1512 | (if (use-region-p) |
| 1460 | ;; Adjust adornments within region. | 1513 | ;; Adjust adornments within region. |
| 1461 | (rst-promote-region (and pfxarg t)) | 1514 | (rst-promote-region (and pfxarg t)) |
| 1462 | ;; Adjust adornment around point. | 1515 | ;; Adjust adornment around point. |
| @@ -1466,15 +1519,14 @@ b. a negative numerical argument, which generally inverts the | |||
| 1466 | (run-hooks 'rst-adjust-hook) | 1519 | (run-hooks 'rst-adjust-hook) |
| 1467 | 1520 | ||
| 1468 | ;; Make sure to reset the cursor position properly after we're done. | 1521 | ;; Make sure to reset the cursor position properly after we're done. |
| 1469 | (goto-char origpt) | 1522 | (goto-char origpt))) |
| 1470 | |||
| 1471 | )) | ||
| 1472 | 1523 | ||
| 1473 | (defcustom rst-adjust-hook nil | 1524 | (defcustom rst-adjust-hook nil |
| 1474 | "Hooks to be run after running `rst-adjust'." | 1525 | "Hooks to be run after running `rst-adjust'." |
| 1475 | :group 'rst-adjust | 1526 | :group 'rst-adjust |
| 1476 | :type '(hook) | 1527 | :type '(hook) |
| 1477 | :package-version '(rst . "1.1.0")) | 1528 | :package-version '(rst . "1.1.0")) |
| 1529 | (rst-testcover-defcustom) | ||
| 1478 | 1530 | ||
| 1479 | (defcustom rst-new-adornment-down nil | 1531 | (defcustom rst-new-adornment-down nil |
| 1480 | "Controls level of new adornment for section headers." | 1532 | "Controls level of new adornment for section headers." |
| @@ -1483,6 +1535,7 @@ b. a negative numerical argument, which generally inverts the | |||
| 1483 | (const :tag "Same level as previous one" nil) | 1535 | (const :tag "Same level as previous one" nil) |
| 1484 | (const :tag "One level down relative to the previous one" t)) | 1536 | (const :tag "One level down relative to the previous one" t)) |
| 1485 | :package-version '(rst . "1.1.0")) | 1537 | :package-version '(rst . "1.1.0")) |
| 1538 | (rst-testcover-defcustom) | ||
| 1486 | 1539 | ||
| 1487 | (defun rst-adjust-adornment (pfxarg) | 1540 | (defun rst-adjust-adornment (pfxarg) |
| 1488 | "Call `rst-adjust-adornment-work' interactively. | 1541 | "Call `rst-adjust-adornment-work' interactively. |
| @@ -1741,8 +1794,7 @@ hierarchy is similar to that used by `rst-adjust-adornment-work'." | |||
| 1741 | (region-begin-line (line-number-at-pos (region-beginning))) | 1794 | (region-begin-line (line-number-at-pos (region-beginning))) |
| 1742 | (region-end-line (line-number-at-pos (region-end))) | 1795 | (region-end-line (line-number-at-pos (region-end))) |
| 1743 | 1796 | ||
| 1744 | marker-list | 1797 | marker-list) |
| 1745 | ) | ||
| 1746 | 1798 | ||
| 1747 | ;; Skip the markers that come before the region beginning. | 1799 | ;; Skip the markers that come before the region beginning. |
| 1748 | (while (and cur (< (caar cur) region-begin-line)) | 1800 | (while (and cur (< (caar cur) region-begin-line)) |
| @@ -1771,8 +1823,7 @@ hierarchy is similar to that used by `rst-adjust-adornment-work'." | |||
| 1771 | 1823 | ||
| 1772 | ;; Clear marker to avoid slowing down the editing after we're done. | 1824 | ;; Clear marker to avoid slowing down the editing after we're done. |
| 1773 | (set-marker (car p) nil)) | 1825 | (set-marker (car p) nil)) |
| 1774 | (setq deactivate-mark nil) | 1826 | (setq deactivate-mark nil)))) |
| 1775 | ))) | ||
| 1776 | 1827 | ||
| 1777 | 1828 | ||
| 1778 | 1829 | ||
| @@ -1792,9 +1843,7 @@ in ADORNMENTS." | |||
| 1792 | (apply 'rst-update-section x) | 1843 | (apply 'rst-update-section x) |
| 1793 | (goto-char (point-max)) | 1844 | (goto-char (point-max)) |
| 1794 | (insert "\n") | 1845 | (insert "\n") |
| 1795 | (incf level) | 1846 | (incf level)))))) |
| 1796 | )) | ||
| 1797 | ))) | ||
| 1798 | 1847 | ||
| 1799 | (defun rst-straighten-adornments () | 1848 | (defun rst-straighten-adornments () |
| 1800 | "Redo all the adornments in the current buffer. | 1849 | "Redo all the adornments in the current buffer. |
| @@ -1822,10 +1871,7 @@ in order to adapt it to our preferred style." | |||
| 1822 | (apply 'rst-update-section (nth (car lm) rst-preferred-adornments)) | 1871 | (apply 'rst-update-section (nth (car lm) rst-preferred-adornments)) |
| 1823 | 1872 | ||
| 1824 | ;; Reset the marker to avoid slowing down editing until it gets GC'ed. | 1873 | ;; Reset the marker to avoid slowing down editing until it gets GC'ed. |
| 1825 | (set-marker (cdr lm) nil) | 1874 | (set-marker (cdr lm) nil))))) |
| 1826 | ) | ||
| 1827 | ))) | ||
| 1828 | |||
| 1829 | 1875 | ||
| 1830 | 1876 | ||
| 1831 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 1877 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| @@ -1906,7 +1952,7 @@ and the column of the point." | |||
| 1906 | (looking-at pfx-re)))))) ; ...pfx at same level. | 1952 | (looking-at pfx-re)))))) ; ...pfx at same level. |
| 1907 | (push (cons (point) (current-column)) | 1953 | (push (cons (point) (current-column)) |
| 1908 | pfx)) | 1954 | pfx)) |
| 1909 | (forward-line 1)) ) | 1955 | (forward-line 1))) |
| 1910 | (nreverse pfx))) | 1956 | (nreverse pfx))) |
| 1911 | 1957 | ||
| 1912 | (defun rst-insert-list-pos (newitem) | 1958 | (defun rst-insert-list-pos (newitem) |
| @@ -2005,6 +2051,7 @@ starting item, for example 'e' for 'A)' style. The position is also arranged by | |||
| 2005 | :tag (char-to-string char) char)) | 2051 | :tag (char-to-string char) char)) |
| 2006 | rst-bullets))) | 2052 | rst-bullets))) |
| 2007 | :package-version '(rst . "1.1.0")) | 2053 | :package-version '(rst . "1.1.0")) |
| 2054 | (rst-testcover-defcustom) | ||
| 2008 | 2055 | ||
| 2009 | (defun rst-insert-list-continue (curitem prefer-roman) | 2056 | (defun rst-insert-list-continue (curitem prefer-roman) |
| 2010 | "Insert a list item with list start CURITEM including its indentation level. | 2057 | "Insert a list item with list start CURITEM including its indentation level. |
| @@ -2206,8 +2253,7 @@ list destructively." | |||
| 2206 | (setq node (cons nil (cdaar children)))) | 2253 | (setq node (cons nil (cdaar children)))) |
| 2207 | 2254 | ||
| 2208 | ;; Return this node with its children. | 2255 | ;; Return this node with its children. |
| 2209 | (cons node children) | 2256 | (cons node children))) |
| 2210 | )) | ||
| 2211 | 2257 | ||
| 2212 | 2258 | ||
| 2213 | (defun rst-section-tree-point (node &optional point) | 2259 | (defun rst-section-tree-point (node &optional point) |
| @@ -2241,11 +2287,8 @@ container subtree node that we're returning." | |||
| 2241 | (let ((sub (rst-section-tree-point (car last) curpoint))) | 2287 | (let ((sub (rst-section-tree-point (car last) curpoint))) |
| 2242 | (setq path (car sub) | 2288 | (setq path (car sub) |
| 2243 | outtree (cdr sub))) | 2289 | outtree (cdr sub))) |
| 2244 | (setq outtree node)) | 2290 | (setq outtree node))))) |
| 2245 | 2291 | (cons (cons (car node) path) outtree))) | |
| 2246 | ))) | ||
| 2247 | (cons (cons (car node) path) outtree) | ||
| 2248 | )) | ||
| 2249 | 2292 | ||
| 2250 | 2293 | ||
| 2251 | (defgroup rst-toc nil | 2294 | (defgroup rst-toc nil |
| @@ -2257,6 +2300,7 @@ container subtree node that we're returning." | |||
| 2257 | "Indentation for table-of-contents display. | 2300 | "Indentation for table-of-contents display. |
| 2258 | Also used for formatting insertion, when numbering is disabled." | 2301 | Also used for formatting insertion, when numbering is disabled." |
| 2259 | :group 'rst-toc) | 2302 | :group 'rst-toc) |
| 2303 | (rst-testcover-defcustom) | ||
| 2260 | 2304 | ||
| 2261 | (defcustom rst-toc-insert-style 'fixed | 2305 | (defcustom rst-toc-insert-style 'fixed |
| 2262 | "Insertion style for table-of-contents. | 2306 | "Insertion style for table-of-contents. |
| @@ -2267,10 +2311,12 @@ indentation style: | |||
| 2267 | - aligned: numbering, titles aligned under each other | 2311 | - aligned: numbering, titles aligned under each other |
| 2268 | - listed: numbering, with dashes like list items (EXPERIMENTAL)" | 2312 | - listed: numbering, with dashes like list items (EXPERIMENTAL)" |
| 2269 | :group 'rst-toc) | 2313 | :group 'rst-toc) |
| 2314 | (rst-testcover-defcustom) | ||
| 2270 | 2315 | ||
| 2271 | (defcustom rst-toc-insert-number-separator " " | 2316 | (defcustom rst-toc-insert-number-separator " " |
| 2272 | "Separator that goes between the TOC number and the title." | 2317 | "Separator that goes between the TOC number and the title." |
| 2273 | :group 'rst-toc) | 2318 | :group 'rst-toc) |
| 2319 | (rst-testcover-defcustom) | ||
| 2274 | 2320 | ||
| 2275 | ;; This is used to avoid having to change the user's mode. | 2321 | ;; This is used to avoid having to change the user's mode. |
| 2276 | (defvar rst-toc-insert-click-keymap | 2322 | (defvar rst-toc-insert-click-keymap |
| @@ -2282,7 +2328,7 @@ indentation style: | |||
| 2282 | (defcustom rst-toc-insert-max-level nil | 2328 | (defcustom rst-toc-insert-max-level nil |
| 2283 | "If non-nil, maximum depth of the inserted TOC." | 2329 | "If non-nil, maximum depth of the inserted TOC." |
| 2284 | :group 'rst-toc) | 2330 | :group 'rst-toc) |
| 2285 | 2331 | (rst-testcover-defcustom) | |
| 2286 | 2332 | ||
| 2287 | (defun rst-toc-insert (&optional pfxarg) | 2333 | (defun rst-toc-insert (&optional pfxarg) |
| 2288 | "Insert a simple text rendering of the table of contents. | 2334 | "Insert a simple text rendering of the table of contents. |
| @@ -2316,8 +2362,7 @@ The TOC is inserted indented at the current column." | |||
| 2316 | (delete-region init-point (+ init-point (length initial-indent))) | 2362 | (delete-region init-point (+ init-point (length initial-indent))) |
| 2317 | 2363 | ||
| 2318 | ;; Delete the last newline added. | 2364 | ;; Delete the last newline added. |
| 2319 | (delete-char -1) | 2365 | (delete-char -1)))) |
| 2320 | ))) | ||
| 2321 | 2366 | ||
| 2322 | (defun rst-toc-insert-node (node level indent pfx) | 2367 | (defun rst-toc-insert-node (node level indent pfx) |
| 2323 | "Insert tree node NODE in table-of-contents. | 2368 | "Insert tree node NODE in table-of-contents. |
| @@ -2343,9 +2388,7 @@ level to align." | |||
| 2343 | ;; is generated automatically. | 2388 | ;; is generated automatically. |
| 2344 | (put-text-property b (point) 'mouse-face 'highlight) | 2389 | (put-text-property b (point) 'mouse-face 'highlight) |
| 2345 | (put-text-property b (point) 'rst-toc-target (cadar node)) | 2390 | (put-text-property b (point) 'rst-toc-target (cadar node)) |
| 2346 | (put-text-property b (point) 'keymap rst-toc-insert-click-keymap) | 2391 | (put-text-property b (point) 'keymap rst-toc-insert-click-keymap)) |
| 2347 | |||
| 2348 | ) | ||
| 2349 | (insert "\n") | 2392 | (insert "\n") |
| 2350 | 2393 | ||
| 2351 | ;; Prepare indent for children. | 2394 | ;; Prepare indent for children. |
| @@ -2362,9 +2405,7 @@ level to align." | |||
| 2362 | 2405 | ||
| 2363 | ((eq rst-toc-insert-style 'listed) | 2406 | ((eq rst-toc-insert-style 'listed) |
| 2364 | (concat (substring indent 0 -3) | 2407 | (concat (substring indent 0 -3) |
| 2365 | (concat (make-string (+ (length pfx) 2) ? ) " - "))) | 2408 | (concat (make-string (+ (length pfx) 2) ? ) " - ")))))) |
| 2366 | )) | ||
| 2367 | ) | ||
| 2368 | 2409 | ||
| 2369 | (if (or (eq rst-toc-insert-max-level nil) | 2410 | (if (or (eq rst-toc-insert-max-level nil) |
| 2370 | (< level rst-toc-insert-max-level)) | 2411 | (< level rst-toc-insert-max-level)) |
| @@ -2382,8 +2423,7 @@ level to align." | |||
| 2382 | (if (cdr node) | 2423 | (if (cdr node) |
| 2383 | (setq fmt (format "%%-%dd" | 2424 | (setq fmt (format "%%-%dd" |
| 2384 | (1+ (floor (log10 (length | 2425 | (1+ (floor (log10 (length |
| 2385 | (cdr node)))))))) | 2426 | (cdr node)))))))))) |
| 2386 | )) | ||
| 2387 | 2427 | ||
| 2388 | (dolist (child (cdr node)) | 2428 | (dolist (child (cdr node)) |
| 2389 | (rst-toc-insert-node child | 2429 | (rst-toc-insert-node child |
| @@ -2391,9 +2431,7 @@ level to align." | |||
| 2391 | indent | 2431 | indent |
| 2392 | (if do-child-numbering | 2432 | (if do-child-numbering |
| 2393 | (concat pfx (format fmt count)) pfx)) | 2433 | (concat pfx (format fmt count)) pfx)) |
| 2394 | (incf count))) | 2434 | (incf count)))))) |
| 2395 | |||
| 2396 | ))) | ||
| 2397 | 2435 | ||
| 2398 | 2436 | ||
| 2399 | (defun rst-toc-update () | 2437 | (defun rst-toc-update () |
| @@ -2468,8 +2506,7 @@ file-write hook to always make it up-to-date automatically." | |||
| 2468 | ;; Add link on lines. | 2506 | ;; Add link on lines. |
| 2469 | (put-text-property b (point) 'rst-toc-target (cadar node)) | 2507 | (put-text-property b (point) 'rst-toc-target (cadar node)) |
| 2470 | 2508 | ||
| 2471 | (insert "\n") | 2509 | (insert "\n"))) |
| 2472 | )) | ||
| 2473 | 2510 | ||
| 2474 | (dolist (child (cdr node)) | 2511 | (dolist (child (cdr node)) |
| 2475 | (rst-toc-node child (1+ level)))) | 2512 | (rst-toc-node child (1+ level)))) |
| @@ -2517,8 +2554,7 @@ brings the cursor in that section." | |||
| 2517 | line | 2554 | line |
| 2518 | 2555 | ||
| 2519 | ;; Create a temporary buffer. | 2556 | ;; Create a temporary buffer. |
| 2520 | (buf (get-buffer-create rst-toc-buffer-name)) | 2557 | (buf (get-buffer-create rst-toc-buffer-name))) |
| 2521 | ) | ||
| 2522 | 2558 | ||
| 2523 | (with-current-buffer buf | 2559 | (with-current-buffer buf |
| 2524 | (let ((inhibit-read-only t)) | 2560 | (let ((inhibit-read-only t)) |
| @@ -2531,8 +2567,7 @@ brings the cursor in that section." | |||
| 2531 | 2567 | ||
| 2532 | ;; Count the lines to our found node. | 2568 | ;; Count the lines to our found node. |
| 2533 | (let ((linefound (rst-toc-count-lines sectree our-node))) | 2569 | (let ((linefound (rst-toc-count-lines sectree our-node))) |
| 2534 | (setq line (if (cdr linefound) (car linefound) 0))) | 2570 | (setq line (if (cdr linefound) (car linefound) 0))))) |
| 2535 | )) | ||
| 2536 | (display-buffer buf) | 2571 | (display-buffer buf) |
| 2537 | (pop-to-buffer buf) | 2572 | (pop-to-buffer buf) |
| 2538 | 2573 | ||
| @@ -2541,8 +2576,7 @@ brings the cursor in that section." | |||
| 2541 | 2576 | ||
| 2542 | ;; Move the cursor near the right section in the TOC. | 2577 | ;; Move the cursor near the right section in the TOC. |
| 2543 | (goto-char (point-min)) | 2578 | (goto-char (point-min)) |
| 2544 | (forward-line (1- line)) | 2579 | (forward-line (1- line)))) |
| 2545 | )) | ||
| 2546 | 2580 | ||
| 2547 | 2581 | ||
| 2548 | (defun rst-toc-mode-find-section () | 2582 | (defun rst-toc-mode-find-section () |
| @@ -2644,8 +2678,7 @@ backwards in the file (default is to use 1)." | |||
| 2644 | (curline (line-number-at-pos)) | 2678 | (curline (line-number-at-pos)) |
| 2645 | 2679 | ||
| 2646 | (cur allados) | 2680 | (cur allados) |
| 2647 | (idx 0) | 2681 | (idx 0)) |
| 2648 | ) | ||
| 2649 | 2682 | ||
| 2650 | ;; Find the index of the "next" adornment w.r.t. to the current line. | 2683 | ;; Find the index of the "next" adornment w.r.t. to the current line. |
| 2651 | (while (and cur (< (caar cur) curline)) | 2684 | (while (and cur (< (caar cur) curline)) |
| @@ -2666,8 +2699,7 @@ backwards in the file (default is to use 1)." | |||
| 2666 | (progn | 2699 | (progn |
| 2667 | (goto-char (point-min)) | 2700 | (goto-char (point-min)) |
| 2668 | (forward-line (1- (car cur)))) | 2701 | (forward-line (1- (car cur)))) |
| 2669 | (if (> offset 0) (goto-char (point-max)) (goto-char (point-min)))) | 2702 | (if (> offset 0) (goto-char (point-max)) (goto-char (point-min)))))) |
| 2670 | )) | ||
| 2671 | 2703 | ||
| 2672 | (defun rst-backward-section () | 2704 | (defun rst-backward-section () |
| 2673 | "Like `rst-forward-section', except move back one title." | 2705 | "Like `rst-forward-section', except move back one title." |
| @@ -2686,7 +2718,7 @@ for negative COUNT." | |||
| 2686 | (error "Cannot mark zero sections")) | 2718 | (error "Cannot mark zero sections")) |
| 2687 | (cond ((and allow-extend | 2719 | (cond ((and allow-extend |
| 2688 | (or (and (eq last-command this-command) (mark t)) | 2720 | (or (and (eq last-command this-command) (mark t)) |
| 2689 | (rst-portable-mark-active-p))) | 2721 | (use-region-p))) |
| 2690 | (set-mark | 2722 | (set-mark |
| 2691 | (save-excursion | 2723 | (save-excursion |
| 2692 | (goto-char (mark)) | 2724 | (goto-char (mark)) |
| @@ -2742,17 +2774,14 @@ of each paragraph only." | |||
| 2742 | (valid (and (= curcol leftcol) | 2774 | (valid (and (= curcol leftcol) |
| 2743 | (not (looking-at (rst-re 'lin-end)))) | 2775 | (not (looking-at (rst-re 'lin-end)))) |
| 2744 | (and (= curcol leftcol) | 2776 | (and (= curcol leftcol) |
| 2745 | (not (looking-at (rst-re 'lin-end))))) | 2777 | (not (looking-at (rst-re 'lin-end)))))) |
| 2746 | ) | ||
| 2747 | ((>= (point) endm)) | 2778 | ((>= (point) endm)) |
| 2748 | 2779 | ||
| 2749 | (if (if ,first-only | 2780 | (if (if ,first-only |
| 2750 | (and valid (not previous)) | 2781 | (and valid (not previous)) |
| 2751 | valid) | 2782 | valid) |
| 2752 | ,body-consequent | 2783 | ,body-consequent |
| 2753 | ,body-alternative) | 2784 | ,body-alternative))))) |
| 2754 | |||
| 2755 | )))) | ||
| 2756 | 2785 | ||
| 2757 | ;; FIXME: This needs to be refactored. Probably this is simply a function | 2786 | ;; FIXME: This needs to be refactored. Probably this is simply a function |
| 2758 | ;; applying BODY rather than a macro. | 2787 | ;; applying BODY rather than a macro. |
| @@ -2785,13 +2814,10 @@ first of a paragraph." | |||
| 2785 | (,isleftmost (and (not ,isempty) | 2814 | (,isleftmost (and (not ,isempty) |
| 2786 | (= (current-column) ,leftmost)) | 2815 | (= (current-column) ,leftmost)) |
| 2787 | (and (not ,isempty) | 2816 | (and (not ,isempty) |
| 2788 | (= (current-column) ,leftmost))) | 2817 | (= (current-column) ,leftmost)))) |
| 2789 | ) | ||
| 2790 | ((>= (point) endm)) | 2818 | ((>= (point) endm)) |
| 2791 | 2819 | ||
| 2792 | (progn ,@body) | 2820 | (progn ,@body)))))) |
| 2793 | |||
| 2794 | ))))) | ||
| 2795 | 2821 | ||
| 2796 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 2822 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 2797 | ;; Indentation | 2823 | ;; Indentation |
| @@ -2817,26 +2843,31 @@ here." | |||
| 2817 | "Indentation when there is no more indentation point given." | 2843 | "Indentation when there is no more indentation point given." |
| 2818 | :group 'rst-indent | 2844 | :group 'rst-indent |
| 2819 | :type '(integer)) | 2845 | :type '(integer)) |
| 2846 | (rst-testcover-defcustom) | ||
| 2820 | 2847 | ||
| 2821 | (defcustom rst-indent-field 3 | 2848 | (defcustom rst-indent-field 3 |
| 2822 | "Indentation for first line after a field or 0 to always indent for content." | 2849 | "Indentation for first line after a field or 0 to always indent for content." |
| 2823 | :group 'rst-indent | 2850 | :group 'rst-indent |
| 2824 | :type '(integer)) | 2851 | :type '(integer)) |
| 2852 | (rst-testcover-defcustom) | ||
| 2825 | 2853 | ||
| 2826 | (defcustom rst-indent-literal-normal 3 | 2854 | (defcustom rst-indent-literal-normal 3 |
| 2827 | "Default indentation for literal block after a markup on an own line." | 2855 | "Default indentation for literal block after a markup on an own line." |
| 2828 | :group 'rst-indent | 2856 | :group 'rst-indent |
| 2829 | :type '(integer)) | 2857 | :type '(integer)) |
| 2858 | (rst-testcover-defcustom) | ||
| 2830 | 2859 | ||
| 2831 | (defcustom rst-indent-literal-minimized 2 | 2860 | (defcustom rst-indent-literal-minimized 2 |
| 2832 | "Default indentation for literal block after a minimized markup." | 2861 | "Default indentation for literal block after a minimized markup." |
| 2833 | :group 'rst-indent | 2862 | :group 'rst-indent |
| 2834 | :type '(integer)) | 2863 | :type '(integer)) |
| 2864 | (rst-testcover-defcustom) | ||
| 2835 | 2865 | ||
| 2836 | (defcustom rst-indent-comment 3 | 2866 | (defcustom rst-indent-comment 3 |
| 2837 | "Default indentation for first line of a comment." | 2867 | "Default indentation for first line of a comment." |
| 2838 | :group 'rst-indent | 2868 | :group 'rst-indent |
| 2839 | :type '(integer)) | 2869 | :type '(integer)) |
| 2870 | (rst-testcover-defcustom) | ||
| 2840 | 2871 | ||
| 2841 | ;; FIXME: Must consider other tabs: | 2872 | ;; FIXME: Must consider other tabs: |
| 2842 | ;; * Line blocks | 2873 | ;; * Line blocks |
| @@ -3116,8 +3147,7 @@ do all lines instead of just paragraphs." | |||
| 3116 | (let ((ins-string (format "%d. " (incf count)))) | 3147 | (let ((ins-string (format "%d. " (incf count)))) |
| 3117 | (setq last-insert-len (length ins-string)) | 3148 | (setq last-insert-len (length ins-string)) |
| 3118 | (insert ins-string)) | 3149 | (insert ins-string)) |
| 3119 | (insert (make-string last-insert-len ?\ )) | 3150 | (insert (make-string last-insert-len ?\ ))))) |
| 3120 | ))) | ||
| 3121 | 3151 | ||
| 3122 | (defun rst-bullet-list-region (beg end all) | 3152 | (defun rst-bullet-list-region (beg end all) |
| 3123 | "Add bullets to all the leftmost paragraphs in the given region. | 3153 | "Add bullets to all the leftmost paragraphs in the given region. |
| @@ -3127,8 +3157,7 @@ do all lines instead of just paragraphs." | |||
| 3127 | (rst-iterate-leftmost-paragraphs | 3157 | (rst-iterate-leftmost-paragraphs |
| 3128 | beg end (not all) | 3158 | beg end (not all) |
| 3129 | (insert (car rst-preferred-bullets) " ") | 3159 | (insert (car rst-preferred-bullets) " ") |
| 3130 | (insert " ") | 3160 | (insert " "))) |
| 3131 | )) | ||
| 3132 | 3161 | ||
| 3133 | ;; FIXME: Does not deal with a varying number of digits appropriately. | 3162 | ;; FIXME: Does not deal with a varying number of digits appropriately. |
| 3134 | ;; FIXME: Does not deal with multiple levels independently. | 3163 | ;; FIXME: Does not deal with multiple levels independently. |
| @@ -3143,18 +3172,13 @@ Renumber as necessary. Region is from BEG to END." | |||
| 3143 | (cons (copy-marker (car x)) | 3172 | (cons (copy-marker (car x)) |
| 3144 | (cdr x))) | 3173 | (cdr x))) |
| 3145 | (rst-find-pfx-in-region beg end (rst-re 'itmany-sta-1)))) | 3174 | (rst-find-pfx-in-region beg end (rst-re 'itmany-sta-1)))) |
| 3146 | (count 1) | 3175 | (count 1)) |
| 3147 | ) | ||
| 3148 | (save-excursion | 3176 | (save-excursion |
| 3149 | (dolist (x items) | 3177 | (dolist (x items) |
| 3150 | (goto-char (car x)) | 3178 | (goto-char (car x)) |
| 3151 | (looking-at (rst-re 'itmany-beg-1)) | 3179 | (looking-at (rst-re 'itmany-beg-1)) |
| 3152 | (replace-match (format "%d." count) nil nil nil 1) | 3180 | (replace-match (format "%d." count) nil nil nil 1) |
| 3153 | (incf count) | 3181 | (incf count))))) |
| 3154 | )) | ||
| 3155 | )) | ||
| 3156 | |||
| 3157 | |||
| 3158 | 3182 | ||
| 3159 | ;;------------------------------------------------------------------------------ | 3183 | ;;------------------------------------------------------------------------------ |
| 3160 | 3184 | ||
| @@ -3202,6 +3226,7 @@ Region is from RBEG to REND. With PFXARG set the empty lines too." | |||
| 3202 | :version "24.1" | 3226 | :version "24.1" |
| 3203 | :group 'rst-faces | 3227 | :group 'rst-faces |
| 3204 | :type '(face)) | 3228 | :type '(face)) |
| 3229 | (rst-testcover-defcustom) | ||
| 3205 | (make-obsolete-variable 'rst-block-face | 3230 | (make-obsolete-variable 'rst-block-face |
| 3206 | "customize the face `rst-block' instead." | 3231 | "customize the face `rst-block' instead." |
| 3207 | "24.1") | 3232 | "24.1") |
| @@ -3216,6 +3241,7 @@ Region is from RBEG to REND. With PFXARG set the empty lines too." | |||
| 3216 | :version "24.1" | 3241 | :version "24.1" |
| 3217 | :group 'rst-faces | 3242 | :group 'rst-faces |
| 3218 | :type '(face)) | 3243 | :type '(face)) |
| 3244 | (rst-testcover-defcustom) | ||
| 3219 | (make-obsolete-variable 'rst-external-face | 3245 | (make-obsolete-variable 'rst-external-face |
| 3220 | "customize the face `rst-external' instead." | 3246 | "customize the face `rst-external' instead." |
| 3221 | "24.1") | 3247 | "24.1") |
| @@ -3230,6 +3256,7 @@ Region is from RBEG to REND. With PFXARG set the empty lines too." | |||
| 3230 | :version "24.1" | 3256 | :version "24.1" |
| 3231 | :group 'rst-faces | 3257 | :group 'rst-faces |
| 3232 | :type '(face)) | 3258 | :type '(face)) |
| 3259 | (rst-testcover-defcustom) | ||
| 3233 | (make-obsolete-variable 'rst-definition-face | 3260 | (make-obsolete-variable 'rst-definition-face |
| 3234 | "customize the face `rst-definition' instead." | 3261 | "customize the face `rst-definition' instead." |
| 3235 | "24.1") | 3262 | "24.1") |
| @@ -3246,6 +3273,7 @@ Region is from RBEG to REND. With PFXARG set the empty lines too." | |||
| 3246 | "Directives and roles." | 3273 | "Directives and roles." |
| 3247 | :group 'rst-faces | 3274 | :group 'rst-faces |
| 3248 | :type '(face)) | 3275 | :type '(face)) |
| 3276 | (rst-testcover-defcustom) | ||
| 3249 | (make-obsolete-variable 'rst-directive-face | 3277 | (make-obsolete-variable 'rst-directive-face |
| 3250 | "customize the face `rst-directive' instead." | 3278 | "customize the face `rst-directive' instead." |
| 3251 | "24.1") | 3279 | "24.1") |
| @@ -3260,6 +3288,7 @@ Region is from RBEG to REND. With PFXARG set the empty lines too." | |||
| 3260 | :version "24.1" | 3288 | :version "24.1" |
| 3261 | :group 'rst-faces | 3289 | :group 'rst-faces |
| 3262 | :type '(face)) | 3290 | :type '(face)) |
| 3291 | (rst-testcover-defcustom) | ||
| 3263 | (make-obsolete-variable 'rst-comment-face | 3292 | (make-obsolete-variable 'rst-comment-face |
| 3264 | "customize the face `rst-comment' instead." | 3293 | "customize the face `rst-comment' instead." |
| 3265 | "24.1") | 3294 | "24.1") |
| @@ -3274,6 +3303,7 @@ Region is from RBEG to REND. With PFXARG set the empty lines too." | |||
| 3274 | :version "24.1" | 3303 | :version "24.1" |
| 3275 | :group 'rst-faces | 3304 | :group 'rst-faces |
| 3276 | :type '(face)) | 3305 | :type '(face)) |
| 3306 | (rst-testcover-defcustom) | ||
| 3277 | (make-obsolete-variable 'rst-emphasis1-face | 3307 | (make-obsolete-variable 'rst-emphasis1-face |
| 3278 | "customize the face `rst-emphasis1' instead." | 3308 | "customize the face `rst-emphasis1' instead." |
| 3279 | "24.1") | 3309 | "24.1") |
| @@ -3287,6 +3317,7 @@ Region is from RBEG to REND. With PFXARG set the empty lines too." | |||
| 3287 | "Double emphasis." | 3317 | "Double emphasis." |
| 3288 | :group 'rst-faces | 3318 | :group 'rst-faces |
| 3289 | :type '(face)) | 3319 | :type '(face)) |
| 3320 | (rst-testcover-defcustom) | ||
| 3290 | (make-obsolete-variable 'rst-emphasis2-face | 3321 | (make-obsolete-variable 'rst-emphasis2-face |
| 3291 | "customize the face `rst-emphasis2' instead." | 3322 | "customize the face `rst-emphasis2' instead." |
| 3292 | "24.1") | 3323 | "24.1") |
| @@ -3301,6 +3332,7 @@ Region is from RBEG to REND. With PFXARG set the empty lines too." | |||
| 3301 | :version "24.1" | 3332 | :version "24.1" |
| 3302 | :group 'rst-faces | 3333 | :group 'rst-faces |
| 3303 | :type '(face)) | 3334 | :type '(face)) |
| 3335 | (rst-testcover-defcustom) | ||
| 3304 | (make-obsolete-variable 'rst-literal-face | 3336 | (make-obsolete-variable 'rst-literal-face |
| 3305 | "customize the face `rst-literal' instead." | 3337 | "customize the face `rst-literal' instead." |
| 3306 | "24.1") | 3338 | "24.1") |
| @@ -3315,6 +3347,7 @@ Region is from RBEG to REND. With PFXARG set the empty lines too." | |||
| 3315 | :version "24.1" | 3347 | :version "24.1" |
| 3316 | :group 'rst-faces | 3348 | :group 'rst-faces |
| 3317 | :type '(face)) | 3349 | :type '(face)) |
| 3350 | (rst-testcover-defcustom) | ||
| 3318 | (make-obsolete-variable 'rst-reference-face | 3351 | (make-obsolete-variable 'rst-reference-face |
| 3319 | "customize the face `rst-reference' instead." | 3352 | "customize the face `rst-reference' instead." |
| 3320 | "24.1") | 3353 | "24.1") |
| @@ -3368,6 +3401,7 @@ Recompute the faces. VAL is the value to set." | |||
| 3368 | :group 'rst-faces-defaults | 3401 | :group 'rst-faces-defaults |
| 3369 | :type '(integer) | 3402 | :type '(integer) |
| 3370 | :set 'rst-set-level-default) | 3403 | :set 'rst-set-level-default) |
| 3404 | (rst-testcover-defcustom) | ||
| 3371 | ;; FIXME: It should be possible to give "#RRGGBB" type of color values. | 3405 | ;; FIXME: It should be possible to give "#RRGGBB" type of color values. |
| 3372 | ;; Together with a `rst-level-face-end-light' this could be used for | 3406 | ;; Together with a `rst-level-face-end-light' this could be used for |
| 3373 | ;; computing steps. | 3407 | ;; computing steps. |
| @@ -3378,6 +3412,7 @@ Recompute the faces. VAL is the value to set." | |||
| 3378 | :group 'rst-faces-defaults | 3412 | :group 'rst-faces-defaults |
| 3379 | :type '(string) | 3413 | :type '(string) |
| 3380 | :set 'rst-set-level-default) | 3414 | :set 'rst-set-level-default) |
| 3415 | (rst-testcover-defcustom) | ||
| 3381 | ;; FIXME LEVEL-FACE: This needs to be done differently: The faces must specify | 3416 | ;; FIXME LEVEL-FACE: This needs to be done differently: The faces must specify |
| 3382 | ;; how they behave for dark and light background using the | 3417 | ;; how they behave for dark and light background using the |
| 3383 | ;; relevant options explained in `defface'. | 3418 | ;; relevant options explained in `defface'. |
| @@ -3391,12 +3426,14 @@ The default depends on whether the value of `frame-background-mode' is | |||
| 3391 | :group 'rst-faces-defaults | 3426 | :group 'rst-faces-defaults |
| 3392 | :type '(integer) | 3427 | :type '(integer) |
| 3393 | :set 'rst-set-level-default) | 3428 | :set 'rst-set-level-default) |
| 3429 | (rst-testcover-defcustom) | ||
| 3394 | (defcustom rst-level-face-format-light "%2d" | 3430 | (defcustom rst-level-face-format-light "%2d" |
| 3395 | "The format for the lightness factor appended to the base name of the color. | 3431 | "The format for the lightness factor appended to the base name of the color. |
| 3396 | This value is expanded by `format' with an integer." | 3432 | This value is expanded by `format' with an integer." |
| 3397 | :group 'rst-faces-defaults | 3433 | :group 'rst-faces-defaults |
| 3398 | :type '(string) | 3434 | :type '(string) |
| 3399 | :set 'rst-set-level-default) | 3435 | :set 'rst-set-level-default) |
| 3436 | (rst-testcover-defcustom) | ||
| 3400 | ;; FIXME LEVEL-FACE: This needs to be done differently: The faces must specify | 3437 | ;; FIXME LEVEL-FACE: This needs to be done differently: The faces must specify |
| 3401 | ;; how they behave for dark and light background using the | 3438 | ;; how they behave for dark and light background using the |
| 3402 | ;; relevant options explained in `defface'. | 3439 | ;; relevant options explained in `defface'. |
| @@ -3420,6 +3457,7 @@ This color is used as background for section title text on level | |||
| 3420 | :group 'rst-faces-defaults | 3457 | :group 'rst-faces-defaults |
| 3421 | :type '(integer) | 3458 | :type '(integer) |
| 3422 | :set 'rst-set-level-default) | 3459 | :set 'rst-set-level-default) |
| 3460 | (rst-testcover-defcustom) | ||
| 3423 | 3461 | ||
| 3424 | (defcustom rst-adornment-faces-alist | 3462 | (defcustom rst-adornment-faces-alist |
| 3425 | ;; FIXME LEVEL-FACE: Must be redone if `rst-level-face-max' is changed | 3463 | ;; FIXME LEVEL-FACE: Must be redone if `rst-level-face-max' is changed |
| @@ -3447,6 +3485,7 @@ group." | |||
| 3447 | (const :tag "section title adornment" nil)) | 3485 | (const :tag "section title adornment" nil)) |
| 3448 | :value-type (face)) | 3486 | :value-type (face)) |
| 3449 | :set-after '(rst-level-face-max)) | 3487 | :set-after '(rst-level-face-max)) |
| 3488 | (rst-testcover-defcustom) | ||
| 3450 | 3489 | ||
| 3451 | (defun rst-define-level-faces () | 3490 | (defun rst-define-level-faces () |
| 3452 | "Define the faces for the section title text faces from the values." | 3491 | "Define the faces for the section title text faces from the values." |
| @@ -3663,8 +3702,7 @@ variable of the `rst-faces-defaults' group is customized. Use | |||
| 3663 | ;; Indentation is not required for doctest blocks. | 3702 | ;; Indentation is not required for doctest blocks. |
| 3664 | (,(rst-re 'lin-beg '(:grp (:alt ">>>" ell-tag)) '(:grp ".+")) | 3703 | (,(rst-re 'lin-beg '(:grp (:alt ">>>" ell-tag)) '(:grp ".+")) |
| 3665 | (1 rst-block-face) | 3704 | (1 rst-block-face) |
| 3666 | (2 rst-literal-face)) | 3705 | (2 rst-literal-face))) |
| 3667 | ) | ||
| 3668 | "Keywords to highlight in rst mode.") | 3706 | "Keywords to highlight in rst mode.") |
| 3669 | 3707 | ||
| 3670 | (defvar font-lock-beg) | 3708 | (defvar font-lock-beg) |
| @@ -3974,6 +4012,7 @@ string)) to be used for converting the document." | |||
| 3974 | (string :tag "Options")))) | 4012 | (string :tag "Options")))) |
| 3975 | :group 'rst | 4013 | :group 'rst |
| 3976 | :package-version "1.2.0") | 4014 | :package-version "1.2.0") |
| 4015 | (rst-testcover-defcustom) | ||
| 3977 | 4016 | ||
| 3978 | ;; FIXME: Must be `defcustom`. | 4017 | ;; FIXME: Must be `defcustom`. |
| 3979 | (defvar rst-compile-primary-toolset 'html | 4018 | (defvar rst-compile-primary-toolset 'html |
| @@ -3999,11 +4038,8 @@ string)) to be used for converting the document." | |||
| 3999 | (setq prevdir dir) | 4038 | (setq prevdir dir) |
| 4000 | (setq dir (expand-file-name (file-name-directory | 4039 | (setq dir (expand-file-name (file-name-directory |
| 4001 | (directory-file-name | 4040 | (directory-file-name |
| 4002 | (file-name-directory dir))))) | 4041 | (file-name-directory dir)))))) |
| 4003 | ) | 4042 | (or (and dir (concat dir file-name)) nil)))) |
| 4004 | (or (and dir (concat dir file-name)) nil) | ||
| 4005 | ))) | ||
| 4006 | |||
| 4007 | 4043 | ||
| 4008 | (require 'compile) | 4044 | (require 'compile) |
| 4009 | 4045 | ||
| @@ -4041,8 +4077,7 @@ select the alternative tool-set." | |||
| 4041 | ;; Invoke the compile command. | 4077 | ;; Invoke the compile command. |
| 4042 | (if (or compilation-read-command use-alt) | 4078 | (if (or compilation-read-command use-alt) |
| 4043 | (call-interactively 'compile) | 4079 | (call-interactively 'compile) |
| 4044 | (compile compile-command)) | 4080 | (compile compile-command)))) |
| 4045 | )) | ||
| 4046 | 4081 | ||
| 4047 | (defun rst-compile-alt-toolset () | 4082 | (defun rst-compile-alt-toolset () |
| 4048 | "Compile command with the alternative tool-set." | 4083 | "Compile command with the alternative tool-set." |
| @@ -4166,8 +4201,7 @@ column is used (fill-column vs. end of previous/next line)." | |||
| 4166 | (cond ((equal last-command 'rst-repeat-last-character) | 4201 | (cond ((equal last-command 'rst-repeat-last-character) |
| 4167 | (if (= curcol fill-column) prevcol fill-column)) | 4202 | (if (= curcol fill-column) prevcol fill-column)) |
| 4168 | (t (save-excursion | 4203 | (t (save-excursion |
| 4169 | (if (zerop prevcol) fill-column prevcol))) | 4204 | (if (zerop prevcol) fill-column prevcol)))))) |
| 4170 | )) ) | ||
| 4171 | (end-of-line) | 4205 | (end-of-line) |
| 4172 | (if (> (current-column) rightmost-column) | 4206 | (if (> (current-column) rightmost-column) |
| 4173 | ;; Shave characters off the end. | 4207 | ;; Shave characters off the end. |
| @@ -4176,17 +4210,7 @@ column is used (fill-column vs. end of previous/next line)." | |||
| 4176 | (point)) | 4210 | (point)) |
| 4177 | ;; Fill with last characters. | 4211 | ;; Fill with last characters. |
| 4178 | (insert-char (preceding-char) | 4212 | (insert-char (preceding-char) |
| 4179 | (- rightmost-column (current-column)))) | 4213 | (- rightmost-column (current-column)))))) |
| 4180 | )) | ||
| 4181 | |||
| 4182 | |||
| 4183 | (defun rst-portable-mark-active-p () | ||
| 4184 | "Return non-nil if the mark is active. | ||
| 4185 | This is a portable function." | ||
| 4186 | (cond | ||
| 4187 | ((fboundp 'region-active-p) (region-active-p)) | ||
| 4188 | ((boundp 'transient-mark-mode) (and transient-mark-mode mark-active)) | ||
| 4189 | (t mark-active))) | ||
| 4190 | 4214 | ||
| 4191 | 4215 | ||
| 4192 | 4216 | ||