[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/fountain-mode f12e7f0 13/17: Improve completion for sce
From: |
Paul Rankin |
Subject: |
[elpa] externals/fountain-mode f12e7f0 13/17: Improve completion for scene headings |
Date: |
Sun, 19 May 2019 09:55:59 -0400 (EDT) |
branch: externals/fountain-mode
commit f12e7f0b3d75293cdae137e9d1860b31e5bbbb9f
Author: Paul W. Rankin <address@hidden>
Commit: Paul W. Rankin <address@hidden>
Improve completion for scene headings
- add variable fountain-scene-heading-suffix-list
- add variable fountain-scene-heading-suffix-sep
- allow completion to complete location or suffix
---
fountain-mode.el | 91 +++++++++++++++++++++++++++++++++++++++-----------------
1 file changed, 64 insertions(+), 27 deletions(-)
diff --git a/fountain-mode.el b/fountain-mode.el
index c493f82..f398ec7 100644
--- a/fountain-mode.el
+++ b/fountain-mode.el
@@ -576,6 +576,22 @@ e.g.
Requires `fountain-match-scene-heading' for preceding blank line.")
+(defcustom fountain-scene-heading-suffix-sep
+ " - "
+ "String separating scene heading location from suffix."
+ :type 'string
+ :safe 'string
+ :set #'fountain--set-and-refresh-all-font-lock)
+
+(defcustom fountain-scene-heading-suffix-list
+ '("DAY" "NIGHT" "LATER" "MOMENTS LATER" "CONTINUOUS")
+ "List of scene heading suffixes (case insensitive).
+
+These are separated from scene heading locations with
+`fountain-scene-heading-suffix-sep'."
+ :type '(repeat (string :tag "Suffix"))
+ :set #'fountain--set-and-refresh-all-font-lock)
+
(defvar fountain-trans-regexp
nil
"Regular expression for matching transitions.
@@ -893,33 +909,35 @@ scene heading regular expression."
;; Group 2: match scene heading without scene number
"\\(?2:\\<"
;; Group 4: match location
- "\\(?4:.+?\\)[\s\t]*"
- ;; Group 5: match time of day
- "\\(?:--?[\s\t]*\\(?5:.+?\\)\\)?"
+ "\\(?4:.+?\\)"
+ ;; Group 5: match suffix separator
+ "\\(?:\\(?5:" fountain-scene-heading-suffix-sep "\\)"
+ ;; Group 6: match suffix
+ "\\(?6:.+\\)?\\)?"
"\\)\\|"
;;; Match normal scene heading
;; Group 2: match scene heading without scene number
"^\\(?2:"
;; Group 3: match INT/EXT
- "\\(?3:"
- (regexp-opt fountain-scene-heading-prefix-list)
- "\\)[.\s\t][\s\t]*"
+ "\\(?3:" (regexp-opt fountain-scene-heading-prefix-list) ".?\s+\\)"
;; Group 4: match location
- "\\(?4:.+?\\)[\s\t]*"
- ;; Group 5: match time of day
- "\\(?:--?[\s\t]*\\(?5:.+?\\)\\)?"
+ "\\(?4:.+?\\)?"
+ ;; Group 5: match suffix separator
+ "\\(?:\\(?5:" fountain-scene-heading-suffix-sep "\\)"
+ ;; Group 6: match suffix
+ "\\(?6:.+\\)?\\)?"
"\\)\\)"
;;; Match scene number
"\\(?:"
- ;; Group 6: match space between scene heading and scene number
- "\\(?6:[\s\t]+\\)"
- ;; Group 7: match first # delimiter
- "\\(?7:#\\)"
- ;; Group 8: match scene number
- "\\(?8:[0-9a-z\\.-]+\\)"
- ;; Group 9: match last # delimiter
- "\\(?9:#\\)\\)?"
- "[\s\t]*$")))
+ ;; Group 7: match space between scene heading and scene number
+ "\\(?7:\s+\\)"
+ ;; Group 8: match first # delimiter
+ "\\(?8:#\\)"
+ ;; Group 9: match scene number
+ "\\(?9:[0-9a-z\\.-]+\\)"
+ ;; Group 10: match last # delimiter
+ "\\(?10:#\\)\\)?"
+ "\s*$")))
(defun fountain-init-trans-regexp ()
"Initialize transition regular expression.
@@ -1249,7 +1267,7 @@ occurrences. ")
(fountain-forward-scene 0)
(while (< (point) end)
(when (fountain-match-scene-heading)
- (let ((scene-heading (match-string-no-properties 2)))
+ (let ((scene-heading (match-string-no-properties 4)))
(unless (member scene-heading fountain-completion-scene-headings)
(push scene-heading fountain-completion-scene-headings))))
(fountain-forward-scene 1)))
@@ -1326,14 +1344,33 @@ previous line is blank, return result of
`fountain-completion-get-characters'.
Added to `completion-at-point-functions'."
- (list (line-beginning-position)
- (point)
- (completion-table-case-fold
- (cond
- ((fountain-match-scene-heading)
- fountain-completion-scene-headings)
- ((fountain-blank-before-p)
- (fountain-completion-get-characters))))))
+ (cond ((and (fountain-match-scene-heading)
+ (match-string 5))
+ ;; Return scene heading suffix completion
+ (list (match-end 5)
+ (point)
+ (completion-table-case-fold
+ fountain-scene-heading-suffix-list)))
+ ((and (fountain-match-scene-heading)
+ (match-string 3))
+ ;; Return scene location completion
+ (list (match-end 3)
+ (point)
+ (completion-table-case-fold
+ fountain-completion-scene-headings)))
+ ((and (fountain-match-scene-heading)
+ (match-string 1))
+ ;; Return scene location completion (forced)
+ (list (match-end 1)
+ (point)
+ (completion-table-case-fold
+ fountain-completion-scene-headings)))
+ ((fountain-blank-before-p)
+ ;; Return character completion
+ (list (line-beginning-position)
+ (point)
+ (completion-table-case-fold
+ (fountain-completion-get-characters))))))
(defun fountain-completion-update ()
"Update completion candidates for current buffer.
- [elpa] externals/fountain-mode updated (7d92f6b -> eef014a), Paul Rankin, 2019/05/19
- [elpa] externals/fountain-mode eef014a 17/17: Update README/Commentary/code comments, Paul Rankin, 2019/05/19
- [elpa] externals/fountain-mode 349436a 16/17: Update fountain-dwim to toggle outline/completion-at-point, Paul Rankin, 2019/05/19
- [elpa] externals/fountain-mode 51d3e39 14/17: Fix scene heading regexp grouping for scene numbers, Paul Rankin, 2019/05/19
- [elpa] externals/fountain-mode f12e7f0 13/17: Improve completion for scene headings,
Paul Rankin <=
- [elpa] externals/fountain-mode c1a01e3 12/17: Remove old page-count vars/options, Paul Rankin, 2019/05/19
- [elpa] externals/fountain-mode 735561a 15/17: Change scene heading completion to location/suffix completion, Paul Rankin, 2019/05/19
- [elpa] externals/fountain-mode cb78fc0 11/17: Bind TAB to fountain-dwim, C-c C-o to fountain-include-find-file, Paul Rankin, 2019/05/19
- [elpa] externals/fountain-mode a6a11f8 07/17: Remove fountain page count commands from menu, Paul Rankin, 2019/05/19
- [elpa] externals/fountain-mode 5fd879c 09/17: Neaten up fountain menu, Paul Rankin, 2019/05/19
- [elpa] externals/fountain-mode 6cdcb2d 10/17: Bump version number, Paul Rankin, 2019/05/19
- [elpa] externals/fountain-mode e8a7ecd 08/17: Remove fountain-tab-command from menu, Paul Rankin, 2019/05/19
- [elpa] externals/fountain-mode eb1ae47 06/17: Cleaned up obsolete variable warnings, Paul Rankin, 2019/05/19
- [elpa] externals/fountain-mode d6c367e 05/17: Clean-ups, fixing fountain-scene-numbers group, Paul Rankin, 2019/05/19
- [elpa] externals/fountain-mode 459bd14 04/17: Remove --edit-line funcs, Paul Rankin, 2019/05/19