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

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

[elpa] master 5dd3035 19/28: Refactor trim functions.


From: Jackson Ray Hamilton
Subject: [elpa] master 5dd3035 19/28: Refactor trim functions.
Date: Tue, 05 May 2015 11:10:23 +0000

branch: master
commit 5dd3035f60d39daf33dd1ff262881911676c659e
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>

    Refactor trim functions.
---
 context-coloring.el |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/context-coloring.el b/context-coloring.el
index 010e0af..06c22e9 100644
--- a/context-coloring.el
+++ b/context-coloring.el
@@ -68,16 +68,22 @@
   "Join a list of STRINGS with the string DELIMITER."
   (mapconcat 'identity strings delimiter))
 
-(defun context-coloring-trim (string)
-  "Remove leading and trailing whitespace from STRING."
-  ;; Trim right.
-  (when (string-match "[ \t\n\r]+\\'" string)
-    (setq string (replace-match "" t t string)))
-  ;; Trim left.
+(defsubst context-coloring-trim-right (string)
+  "Remove leading whitespace from STRING."
+  (if (string-match "[ \t\n\r]+\\'" string)
+      (replace-match "" t t string)
+    string))
+
+(defsubst context-coloring-trim-left (string)
+  "Remove trailing whitespace from STRING."
   (if (string-match "\\`[ \t\n\r]+" string)
       (replace-match "" t t string)
     string))
 
+(defsubst context-coloring-trim (string)
+  "Remove leading and trailing whitespace from STRING."
+  (context-coloring-trim-left (context-coloring-trim-right string)))
+
 
 ;;; Faces
 



reply via email to

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