diff options
| author | Stefan Merten | 2012-06-03 19:20:24 +0200 |
|---|---|---|
| committer | Stefan Merten | 2012-06-03 19:20:24 +0200 |
| commit | d8a52e1551f10d0076d46fcb67d487ac60dcbb98 (patch) | |
| tree | 18ee6b92a226386bfeca576c0ee406c09bd4c73f | |
| parent | 5205d6f6a86e410758bd081949657ad5e97bb240 (diff) | |
| download | emacs-d8a52e1551f10d0076d46fcb67d487ac60dcbb98.tar.gz emacs-d8a52e1551f10d0076d46fcb67d487ac60dcbb98.zip | |
rst.el: Add comments.
(rst-transition, rst-adornment): New faces.
(rst-adornment-faces-alist): Make default safe to reevaluate.
Fixes
http://sourceforge.net/tracker/?func=detail&atid=422030&aid=3479603&group_id=38414.
Improve customization tags.
(rst-define-level-faces): Clarify meaning.
| -rw-r--r-- | lisp/ChangeLog | 10 | ||||
| -rw-r--r-- | lisp/textmodes/rst.el | 105 |
2 files changed, 89 insertions, 26 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 5a8644b81ff..ba77c554ab6 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2012-06-03 Stefan Merten <smerten@oekonux.de> | ||
| 2 | |||
| 3 | * textmodes/rst.el: Add comments. | ||
| 4 | (rst-transition, rst-adornment): New faces. | ||
| 5 | (rst-adornment-faces-alist): Make default safe to reevaluate. | ||
| 6 | Fixes | ||
| 7 | http://sourceforge.net/tracker/?func=detail&atid=422030&aid=3479603&group_id=38414. | ||
| 8 | Improve customization tags. | ||
| 9 | (rst-define-level-faces): Clarify meaning. | ||
| 10 | |||
| 1 | 2012-06-03 Chong Yidong <cyd@gnu.org> | 11 | 2012-06-03 Chong Yidong <cyd@gnu.org> |
| 2 | 12 | ||
| 3 | * progmodes/compile.el (compilation-mode-line-fail) | 13 | * progmodes/compile.el (compilation-mode-line-fail) |
diff --git a/lisp/textmodes/rst.el b/lisp/textmodes/rst.el index 6066d337a0f..0474db7d40e 100644 --- a/lisp/textmodes/rst.el +++ b/lisp/textmodes/rst.el | |||
| @@ -104,9 +104,13 @@ | |||
| 104 | ;;; Code: | 104 | ;;; Code: |
| 105 | 105 | ||
| 106 | ;; FIXME: Use `eval-when-compile' when calls to `some', `position', `signum' | 106 | ;; FIXME: Use `eval-when-compile' when calls to `some', `position', `signum' |
| 107 | ;; and `position-if' are replaced. | 107 | ;; and `position-if' are replaced. `catch' and `throw' may help with the |
| 108 | ;; list operations. | ||
| 108 | (require 'cl) | 109 | (require 'cl) |
| 109 | 110 | ||
| 111 | ;; FIXME: Check whether complicated `defconst's can be embedded in | ||
| 112 | ;; `eval-when-compile'. | ||
| 113 | |||
| 110 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 114 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 111 | ;; Versions | 115 | ;; Versions |
| 112 | 116 | ||
| @@ -123,7 +127,7 @@ and before TAIL-RE and DELIM-RE in VAR or DEFAULT for no match." | |||
| 123 | ;; Use CVSHeader to really get information from CVS and not other version | 127 | ;; Use CVSHeader to really get information from CVS and not other version |
| 124 | ;; control systems. | 128 | ;; control systems. |
| 125 | (defconst rst-cvs-header | 129 | (defconst rst-cvs-header |
| 126 | "$CVSHeader: sm/rst_el/rst.el,v 1.257.2.11 2012-06-02 12:20:41 stefan Exp $") | 130 | "$CVSHeader: sm/rst_el/rst.el,v 1.273 2012-06-03 17:01:33 stefan Exp $") |
| 127 | (defconst rst-cvs-rev | 131 | (defconst rst-cvs-rev |
| 128 | (rst-extract-version "\\$" "CVSHeader: \\S + " "[0-9]+\\(?:\\.[0-9]+\\)+" | 132 | (rst-extract-version "\\$" "CVSHeader: \\S + " "[0-9]+\\(?:\\.[0-9]+\\)+" |
| 129 | " .*" rst-cvs-header "0.0") | 133 | " .*" rst-cvs-header "0.0") |
| @@ -155,6 +159,7 @@ SVN revision is the upstream (docutils) revision.") | |||
| 155 | "%Revision: 1.256 %") | 159 | "%Revision: 1.256 %") |
| 156 | "CVS revision of this file in the official version.") | 160 | "CVS revision of this file in the official version.") |
| 157 | 161 | ||
| 162 | ;; FIXME: Version differences due to SVN checkin must not change this. | ||
| 158 | (defconst rst-version | 163 | (defconst rst-version |
| 159 | (if (equal rst-official-cvs-rev rst-cvs-rev) | 164 | (if (equal rst-official-cvs-rev rst-cvs-rev) |
| 160 | rst-official-version | 165 | rst-official-version |
| @@ -644,7 +649,8 @@ This inherits from Text mode.") | |||
| 644 | ;; Syntax table. | 649 | ;; Syntax table. |
| 645 | (defvar rst-mode-syntax-table | 650 | (defvar rst-mode-syntax-table |
| 646 | (let ((st (copy-syntax-table text-mode-syntax-table))) | 651 | (let ((st (copy-syntax-table text-mode-syntax-table))) |
| 647 | 652 | ;; FIXME: This must be rethought; at the very least ?. should not be a | |
| 653 | ;; symbol for `dabbrev' to work properly. | ||
| 648 | (modify-syntax-entry ?$ "." st) | 654 | (modify-syntax-entry ?$ "." st) |
| 649 | (modify-syntax-entry ?% "." st) | 655 | (modify-syntax-entry ?% "." st) |
| 650 | (modify-syntax-entry ?& "." st) | 656 | (modify-syntax-entry ?& "." st) |
| @@ -850,6 +856,7 @@ for modes derived from Text mode, like Mail mode." | |||
| 850 | :group 'rst | 856 | :group 'rst |
| 851 | :version "21.1") | 857 | :version "21.1") |
| 852 | 858 | ||
| 859 | ;; FIXME: The version must be represented in `rst-package-emacs-version-alist'. | ||
| 853 | (define-obsolete-variable-alias | 860 | (define-obsolete-variable-alias |
| 854 | 'rst-preferred-decorations 'rst-preferred-adornments "r6506") | 861 | 'rst-preferred-decorations 'rst-preferred-adornments "r6506") |
| 855 | (defcustom rst-preferred-adornments '((?= over-and-under 1) | 862 | (defcustom rst-preferred-adornments '((?= over-and-under 1) |
| @@ -1882,6 +1889,7 @@ Other situations are just ignored and left to users themselves." | |||
| 1882 | (end-of-line) | 1889 | (end-of-line) |
| 1883 | (insert "\n\n" newitem " "))) | 1890 | (insert "\n\n" newitem " "))) |
| 1884 | 1891 | ||
| 1892 | ;; FIXME: Isn't this a `defconst'? | ||
| 1885 | (defvar rst-initial-enums | 1893 | (defvar rst-initial-enums |
| 1886 | (let (vals) | 1894 | (let (vals) |
| 1887 | (dolist (fmt '("%s." "(%s)" "%s)")) | 1895 | (dolist (fmt '("%s." "(%s)" "%s)")) |
| @@ -1890,6 +1898,7 @@ Other situations are just ignored and left to users themselves." | |||
| 1890 | (cons "#." (nreverse vals))) | 1898 | (cons "#." (nreverse vals))) |
| 1891 | "List of initial enumerations.") | 1899 | "List of initial enumerations.") |
| 1892 | 1900 | ||
| 1901 | ;; FIXME: Isn't this a `defconst'? | ||
| 1893 | (defvar rst-initial-items | 1902 | (defvar rst-initial-items |
| 1894 | (append (mapcar 'char-to-string rst-bullets) rst-initial-enums) | 1903 | (append (mapcar 'char-to-string rst-bullets) rst-initial-enums) |
| 1895 | "List of initial items. It's collection of bullets and enumerations.") | 1904 | "List of initial items. It's collection of bullets and enumerations.") |
| @@ -2754,6 +2763,7 @@ here." | |||
| 2754 | :group 'rst | 2763 | :group 'rst |
| 2755 | :package-version '(rst . "1.1.0")) | 2764 | :package-version '(rst . "1.1.0")) |
| 2756 | 2765 | ||
| 2766 | ;; FIXME: The version must be represented in `rst-package-emacs-version-alist'. | ||
| 2757 | (define-obsolete-variable-alias | 2767 | (define-obsolete-variable-alias |
| 2758 | 'rst-shift-basic-offset 'rst-indent-width "r6713") | 2768 | 'rst-shift-basic-offset 'rst-indent-width "r6713") |
| 2759 | (defcustom rst-indent-width 2 | 2769 | (defcustom rst-indent-width 2 |
| @@ -3126,6 +3136,9 @@ Region is from RBEG to REND. With PFXARG set the empty lines too." | |||
| 3126 | 3136 | ||
| 3127 | ;; FIXME: The obsolete variables need to disappear. | 3137 | ;; FIXME: The obsolete variables need to disappear. |
| 3128 | 3138 | ||
| 3139 | ;; FIXME LEVEL-FACE: All `:version "24.1"' attributes need to be changed to | ||
| 3140 | ;; proper `:package-version "24.1"' attributes. | ||
| 3141 | |||
| 3129 | (defgroup rst-faces nil "Faces used in Rst Mode." | 3142 | (defgroup rst-faces nil "Faces used in Rst Mode." |
| 3130 | :group 'rst | 3143 | :group 'rst |
| 3131 | :group 'faces | 3144 | :group 'faces |
| @@ -3258,8 +3271,27 @@ Region is from RBEG to REND. With PFXARG set the empty lines too." | |||
| 3258 | "customize the face `rst-reference' instead." | 3271 | "customize the face `rst-reference' instead." |
| 3259 | "24.1") | 3272 | "24.1") |
| 3260 | 3273 | ||
| 3274 | (defface rst-transition '((t :inherit font-lock-keyword-face)) | ||
| 3275 | "Face used for a transition." | ||
| 3276 | :version "24.1" | ||
| 3277 | :group 'rst-faces) | ||
| 3278 | |||
| 3279 | (defface rst-adornment '((t :inherit font-lock-keyword-face)) | ||
| 3280 | "Face used for the adornment of a section header." | ||
| 3281 | :version "24.1" | ||
| 3282 | :group 'rst-faces) | ||
| 3283 | |||
| 3261 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 3284 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 3262 | 3285 | ||
| 3286 | ;; FIXME LEVEL-FACE: May be this complicated mechanism should be replaced | ||
| 3287 | ;; simply by a number of customizable faces `rst-header-%d' | ||
| 3288 | ;; which by default are set properly for dark and light | ||
| 3289 | ;; background. Initialization should come from the old | ||
| 3290 | ;; variables if they exist. A maximum level of 6 should | ||
| 3291 | ;; suffice - after that the last level should be repeated. | ||
| 3292 | ;; Only `rst-adornment-faces-alist' is needed outside this | ||
| 3293 | ;; block. Would also fix docutils-Bugs-3479594. | ||
| 3294 | |||
| 3263 | (defgroup rst-faces-defaults nil | 3295 | (defgroup rst-faces-defaults nil |
| 3264 | "Values used to generate default faces for section titles on all levels. | 3296 | "Values used to generate default faces for section titles on all levels. |
| 3265 | Tweak these if you are content with how section title faces are built in | 3297 | Tweak these if you are content with how section title faces are built in |
| @@ -3281,18 +3313,26 @@ Recompute the faces. VAL is the value to set." | |||
| 3281 | (rst-define-level-faces))) | 3313 | (rst-define-level-faces))) |
| 3282 | 3314 | ||
| 3283 | ;; Faces for displaying items on several levels. These definitions define | 3315 | ;; Faces for displaying items on several levels. These definitions define |
| 3284 | ;; different shades of gray where the lightest one (i.e. least contrasting) is | 3316 | ;; different shades of gray where the lightest one (i.e. least contrasting on a |
| 3285 | ;; used for level 1. | 3317 | ;; light background) is used for level 1. |
| 3286 | (defcustom rst-level-face-max 6 | 3318 | (defcustom rst-level-face-max 6 |
| 3287 | "Maximum depth of levels for which section title faces are defined." | 3319 | "Maximum depth of levels for which section title faces are defined." |
| 3288 | :group 'rst-faces-defaults | 3320 | :group 'rst-faces-defaults |
| 3289 | :type '(integer) | 3321 | :type '(integer) |
| 3290 | :set 'rst-set-level-default) | 3322 | :set 'rst-set-level-default) |
| 3323 | ;; FIXME: It should be possible to give "#RRGGBB" type of color values. | ||
| 3324 | ;; Together with a `rst-level-face-end-light' this could be used for | ||
| 3325 | ;; computing steps. | ||
| 3326 | ;; FIXME: This variable should be combined with `rst-level-face-format-light' | ||
| 3327 | ;; to a single string. | ||
| 3291 | (defcustom rst-level-face-base-color "grey" | 3328 | (defcustom rst-level-face-base-color "grey" |
| 3292 | "Base name of the color for creating background colors in section title faces." | 3329 | "Base name of the color for creating background colors in section title faces." |
| 3293 | :group 'rst-faces-defaults | 3330 | :group 'rst-faces-defaults |
| 3294 | :type '(string) | 3331 | :type '(string) |
| 3295 | :set 'rst-set-level-default) | 3332 | :set 'rst-set-level-default) |
| 3333 | ;; FIXME LEVEL-FACE: This needs to be done differently: The faces must specify | ||
| 3334 | ;; how they behave for dark and light background using the | ||
| 3335 | ;; relevant options explained in `defface'. | ||
| 3296 | (defcustom rst-level-face-base-light | 3336 | (defcustom rst-level-face-base-light |
| 3297 | (if (eq frame-background-mode 'dark) | 3337 | (if (eq frame-background-mode 'dark) |
| 3298 | 15 | 3338 | 15 |
| @@ -3309,6 +3349,12 @@ This value is expanded by `format' with an integer." | |||
| 3309 | :group 'rst-faces-defaults | 3349 | :group 'rst-faces-defaults |
| 3310 | :type '(string) | 3350 | :type '(string) |
| 3311 | :set 'rst-set-level-default) | 3351 | :set 'rst-set-level-default) |
| 3352 | ;; FIXME LEVEL-FACE: This needs to be done differently: The faces must specify | ||
| 3353 | ;; how they behave for dark and light background using the | ||
| 3354 | ;; relevant options explained in `defface'. | ||
| 3355 | ;; FIXME: Alternatively there could be a customizable variable | ||
| 3356 | ;; `rst-level-face-end-light' which defines the end value and steps are | ||
| 3357 | ;; computed | ||
| 3312 | (defcustom rst-level-face-step-light | 3358 | (defcustom rst-level-face-step-light |
| 3313 | (if (eq frame-background-mode 'dark) | 3359 | (if (eq frame-background-mode 'dark) |
| 3314 | 7 | 3360 | 7 |
| @@ -3328,49 +3374,53 @@ This color is used as background for section title text on level | |||
| 3328 | :set 'rst-set-level-default) | 3374 | :set 'rst-set-level-default) |
| 3329 | 3375 | ||
| 3330 | (defcustom rst-adornment-faces-alist | 3376 | (defcustom rst-adornment-faces-alist |
| 3331 | (let ((alist '((t . font-lock-keyword-face) | 3377 | ;; FIXME LEVEL-FACE: Must be redone if `rst-level-face-max' is changed |
| 3332 | (nil . font-lock-keyword-face))) | 3378 | (let ((alist (copy-list '((t . rst-transition) |
| 3379 | (nil . rst-adornment)))) | ||
| 3333 | (i 1)) | 3380 | (i 1)) |
| 3334 | (while (<= i rst-level-face-max) | 3381 | (while (<= i rst-level-face-max) |
| 3335 | (nconc alist (list (cons i (intern (format "rst-level-%d-face" i))))) | 3382 | (nconc alist (list (cons i (intern (format "rst-level-%d-face" i))))) |
| 3336 | (setq i (1+ i))) | 3383 | (setq i (1+ i))) |
| 3337 | alist) | 3384 | alist) |
| 3338 | "Faces for the various adornment types. | 3385 | "Faces for the various adornment types. |
| 3339 | Key is a number (for the section title text of that level), | 3386 | Key is a number (for the section title text of that level |
| 3340 | t (for transitions) or nil (for section title adornment). | 3387 | starting with 1), t (for transitions) or nil (for section title |
| 3341 | If you generally do not like how section title text faces are | 3388 | adornment). If you generally do not like how section title text |
| 3342 | set up tweak here. If the general idea is ok for you but you do not like the | 3389 | faces are set up tweak here. If the general idea is ok for you |
| 3343 | details check the Rst Faces Defaults group." | 3390 | but you do not like the details check the Rst Faces Defaults |
| 3391 | group." | ||
| 3344 | :group 'rst-faces | 3392 | :group 'rst-faces |
| 3345 | :type '(alist | 3393 | :type '(alist |
| 3346 | :key-type | 3394 | :key-type |
| 3347 | (choice | 3395 | (choice |
| 3348 | (integer | 3396 | (integer :tag "Section level") |
| 3349 | :tag | 3397 | (const :tag "transitions" t) |
| 3350 | "Section level (may not be bigger than `rst-level-face-max')") | 3398 | (const :tag "section title adornment" nil)) |
| 3351 | (boolean :tag "transitions (on) / section title adornment (off)")) | ||
| 3352 | :value-type (face)) | 3399 | :value-type (face)) |
| 3353 | :set-after '(rst-level-face-max)) | 3400 | :set-after '(rst-level-face-max)) |
| 3354 | 3401 | ||
| 3355 | ;; FIXME: It should be possible to give "#RRGGBB" type of color values. | ||
| 3356 | (defun rst-define-level-faces () | 3402 | (defun rst-define-level-faces () |
| 3357 | "Define the faces for the section title text faces from the values." | 3403 | "Define the faces for the section title text faces from the values." |
| 3358 | ;; All variables used here must be checked in `rst-set-level-default'. | 3404 | ;; All variables used here must be checked in `rst-set-level-default'. |
| 3359 | (let ((i 1)) | 3405 | (let ((i 1)) |
| 3360 | (while (<= i rst-level-face-max) | 3406 | (while (<= i rst-level-face-max) |
| 3361 | (let ((sym (intern (format "rst-level-%d-face" i))) | 3407 | (let ((sym (intern (format "rst-level-%d-face" i))) |
| 3362 | (doc (format "Face for showing section title text at level %d" i)) | 3408 | (doc (format "Default face for showing section title text at level %d. |
| 3409 | This symbol is *not* meant for customization but modified if a | ||
| 3410 | variable of the `rst-faces-defaults' group is customized. Use | ||
| 3411 | `rst-adornment-faces-alist' for customization instead." i)) | ||
| 3363 | (col (format (concat "%s" rst-level-face-format-light) | 3412 | (col (format (concat "%s" rst-level-face-format-light) |
| 3364 | rst-level-face-base-color | 3413 | rst-level-face-base-color |
| 3365 | (+ (* (1- i) rst-level-face-step-light) | 3414 | (+ (* (1- i) rst-level-face-step-light) |
| 3366 | rst-level-face-base-light)))) | 3415 | rst-level-face-base-light)))) |
| 3367 | (unless (facep sym) | 3416 | (make-empty-face sym) |
| 3368 | (make-empty-face sym) | 3417 | (set-face-doc-string sym doc) |
| 3369 | (set-face-doc-string sym doc) | 3418 | (set-face-background sym col) |
| 3370 | (set-face-background sym col) | 3419 | (set sym sym) |
| 3371 | (set sym sym)) | ||
| 3372 | (setq i (1+ i)))))) | 3420 | (setq i (1+ i)))))) |
| 3373 | 3421 | ||
| 3422 | ;; FIXME LEVEL-FACE: This is probably superfluous since it is done by the | ||
| 3423 | ;; customization / `rst-set-level-default'. | ||
| 3374 | (rst-define-level-faces) | 3424 | (rst-define-level-faces) |
| 3375 | 3425 | ||
| 3376 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 3426 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| @@ -3598,6 +3648,8 @@ Move N lines forward just as `forward-line'." | |||
| 3598 | (forward-line 0) | 3648 | (forward-line 0) |
| 3599 | (- moved (signum n))))) | 3649 | (- moved (signum n))))) |
| 3600 | 3650 | ||
| 3651 | ;; FIXME: If a single line is made a section header by `rst-adjust' the header | ||
| 3652 | ;; is not always fontified immediately. | ||
| 3601 | (defun rst-font-lock-extend-region-extend (pt dir) | 3653 | (defun rst-font-lock-extend-region-extend (pt dir) |
| 3602 | "Extend the region starting at point PT and extending in direction DIR. | 3654 | "Extend the region starting at point PT and extending in direction DIR. |
| 3603 | Return extended point or nil if not moved." | 3655 | Return extended point or nil if not moved." |
| @@ -4083,14 +4135,15 @@ This is a portable function." | |||
| 4083 | (t mark-active))) | 4135 | (t mark-active))) |
| 4084 | 4136 | ||
| 4085 | 4137 | ||
| 4086 | (provide 'rst) | ||
| 4087 | 4138 | ||
| 4088 | ;; LocalWords: docutils http sourceforge rst html wp svn svnroot txt reST regex | 4139 | ;; LocalWords: docutils http sourceforge rst html wp svn svnroot txt reST regex |
| 4089 | ;; LocalWords: regexes alist seq alt grp keymap abbrev overline overlines toc | 4140 | ;; LocalWords: regexes alist seq alt grp keymap abbrev overline overlines toc |
| 4090 | ;; LocalWords: XML PNT propertized referencable | 4141 | ;; LocalWords: XML PNT propertized |
| 4091 | 4142 | ||
| 4092 | ;; Local Variables: | 4143 | ;; Local Variables: |
| 4093 | ;; sentence-end-double-space: t | 4144 | ;; sentence-end-double-space: t |
| 4094 | ;; End: | 4145 | ;; End: |
| 4095 | 4146 | ||
| 4096 | ;;; rst.el ends here. | 4147 | (provide 'rst) |
| 4148 | |||
| 4149 | ;;; rst.el ends here | ||