emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/writegood-mode 2ae759944a 45/47: Add additional custom reg


From: ELPA Syncer
Subject: [nongnu] elpa/writegood-mode 2ae759944a 45/47: Add additional custom regexps for weasel words and passive voice
Date: Mon, 12 Dec 2022 21:01:43 -0500 (EST)

branch: elpa/writegood-mode
commit 2ae759944a7865ceef6f6049f5e26c1f60c6270c
Author: Benjamin Beckwith <bnbeckwith@gmail.com>
Commit: Benjamin Beckwith <bnbeckwith@gmail.com>

    Add additional custom regexps for weasel words and passive voice
    
    - New `writegood-weasel-words-additional-regexp` custom variable
    - New `writegood-passive-voice-irregulars-additional-regexp` custom
      variable
    - Updated documentation
    - Bump version to 2.1
---
 README.org        | 21 ++++++++++++++++-----
 writegood-mode.el | 37 ++++++++++++++++++++++++++++---------
 2 files changed, 44 insertions(+), 14 deletions(-)

diff --git a/README.org b/README.org
index bb29213060..1f8ef6cefa 100644
--- a/README.org
+++ b/README.org
@@ -22,7 +22,7 @@
   would be necessary.
 
 * Readability tests
-  
+
   There are now two functions to perform 
[[http://en.wikipedia.org/wiki/Flesch%E2%80%93Kincaid_readability_tests][Flesch-Kincaid
 scoring]] and
   grade-level estimation. These follow the known algorithms, but may
   differ from other implementations due to the syllable estimation.
@@ -41,22 +41,33 @@ The user is free to customize three main portions of the 
mode.
    The three faces used pull from the default warning face and add
    subtle backgrounds.  There is a separate face for each check performed.
 
-   - Weasel words (writegood-weasels-face)
-   - Passive voice (writegood-passive-voice-face)
-   - Duplicate words (writegood-duplicates-face)
+   - Weasel words (~writegood-weasels-face~)
+   - Passive voice (~writegood-passive-voice-face~)
+   - Duplicate words (~writegood-duplicates-face~)
 
 ** Weasel Words
 
    There is a large list of included weasel words, but you may have
-   your own.  See the write-good-weasel-words variable to modify this
+   your own.  See the ~write-good-weasel-words~ variable to modify this
    list.
 
+   Additionally, if you require more than a list of words to mark up
+   your content, then there is a custom variable,
+   ~writegood-weasel-words-additional-regexp~ that allows a custom
+   regular expression for matching whatever you heart desires
+   (expressed as a regex).
+
 ** Passive Voice Irregulars
 
    There is also a list of irregular passive voice verbs.  These are
    the verbs that do not end in 'ed' to signify past tense. This
    variable allow the user to modify the list as needed.
 
+   Similar to weasel words, the custom variable
+   ~writegood-passive-voice-irregulars-additional-regexp~ allows the use
+   of an additional regular expression to highlight passive voice irregulars.
+
+
 * Alternatives
 
   [[https://github.com/sachac/artbollocks-mode][Artbollocks]] looks to be an 
alternative mode to this one.
diff --git a/writegood-mode.el b/writegood-mode.el
index 60b03e2af1..7b58f66456 100644
--- a/writegood-mode.el
+++ b/writegood-mode.el
@@ -2,7 +2,7 @@
 ;;
 ;; Author: Benjamin Beckwith
 ;; Created: 2010-8-12
-;; Version: 2.0
+;; Version: 2.1.0
 ;; Last-Updated: 2015-03-25
 ;; URL: http://github.com/bnbeckwith/writegood-mode
 ;; Keywords: writing weasel-words grammar
@@ -23,6 +23,7 @@
 ;;
 ;;; Change Log:
 ;;
+;; 2.1.0 Add capability to add custom regexps
 ;; 2.0.4 Remove cl dependency
 ;; 2.0.3 Add in a small decription of the Flesch-Kincaid score
 ;; 2.0.2 Fix Formatting in Org-mode files, make faces underline
@@ -74,9 +75,16 @@
   :group 'help
   :link '(url-link "http://github.com/bnbeckwith/writegood-mode";))
 
-(defconst writegood-version "2.0"
+(defconst writegood-version "2.1.0"
   "WriteGood mode version")
 
+;; General Custom settings
+(defcustom writegood-sentence-punctuation
+  '(?. ?? ?!)
+  "List of punctuation denoting sentence end"
+  :group 'writegood
+  :type '(repeat character))
+
 ;; Weaselwords
 (defface writegood-weasels-face
   '((((supports :underline (:style wave)))
@@ -99,9 +107,18 @@
   :group 'writegood
   :type '(repeat string))
 
+(defcustom writegood-weasel-words-additional-regexp
+  nil
+  "Additional regexp to identify weasel words."
+  :group 'writegood
+  :type 'regexp)
+
 (defun writegood-weasels-font-lock-keywords-regexp ()
   "Generate regex that matches weasel-words"
-  (concat "\\b" (regexp-opt writegood-weasel-words) "\\b"))
+  (concat "\\b\\(?:" (regexp-opt writegood-weasel-words)
+          (when writegood-weasel-words-additional-regexp
+            (concat "\\|" writegood-weasel-words-additional-regexp))
+          "\\)\\b"))
 
 (defun writegood-weasels-font-lock-keywords ()
   (list (list (writegood-weasels-font-lock-keywords-regexp)
@@ -144,16 +161,18 @@
   :group 'writegood
   :type '(repeat string))
 
-(defcustom writegood-sentence-punctuation
-  '(?. ?? ?!)
-  "List of punctuation denoting sentence end"
+(defcustom writegood-passive-voice-irregulars-additional-regexp
+  nil
+  "Additional regexp for passive voice irregulars"
   :group 'writegood
-  :type '(repeat character))
+  :type 'regexp)
 
 (defun writegood-passive-voice-font-lock-keywords-regexp ()
   "Generate font-lock keywords regexp for passive-voice"
-  (concat 
"\\b\\(am\\|are\\|were\\|being\\|is\\|been\\|was\\|be\\)\\b\\([[:space:]]\\|\\s<\\|\\s>\\)+\\([[:word:]]+ed\\|"
-    (regexp-opt writegood-passive-voice-irregulars)
+  (concat 
"\\b\\(am\\|are\\|were\\|being\\|is\\|been\\|was\\|be\\)\\b\\([[:space:]]\\|\\s<\\|\\s>\\)+\\1([[:word:]]+ed\\|"
+          (regexp-opt writegood-passive-voice-irregulars)
+          (when writegood-passive-voice-irregulars-additional-regexp
+            (concat "\\)\\|\\(" 
writegood-passive-voice-irregulars-additional-regexp))
     "\\)\\b"))
 
 (defun writegood-passive-voice-font-lock-keywords ()



reply via email to

[Prev in Thread] Current Thread [Next in Thread]