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

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

[nongnu] elpa/drupal-mode 7d29d72a62 155/308: Added function to wrap str


From: ELPA Syncer
Subject: [nongnu] elpa/drupal-mode 7d29d72a62 155/308: Added function to wrap string in t().
Date: Tue, 25 Jan 2022 10:59:41 -0500 (EST)

branch: elpa/drupal-mode
commit 7d29d72a620727415215261fe5c3fd0a6831ff3b
Author: Arne Jørgensen <arne@arnested.dk>
Commit: Arne Jørgensen <arne@arnested.dk>

    Added function to wrap string in t().
    
    Bound to `C-c C-v C-t`.
    
    Fixes #15.
---
 drupal-mode.el | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drupal-mode.el b/drupal-mode.el
index c08a2108ce..b783da3424 100644
--- a/drupal-mode.el
+++ b/drupal-mode.el
@@ -195,6 +195,7 @@ Include path to the executable if it is not in your $PATH."
     (define-key map [(control c) (control v) (control h)] #'drupal-insert-hook)
     (define-key map [(control c) (control v) (control f)] 
#'drupal-insert-function)
     (define-key map [(control c) (control v) (control m)] #'drupal-module-name)
+    (define-key map [(control c) (control v) (control t)] 
#'drupal-wrap-string-in-t-function)
     (define-key map [(control a)] #'drupal-mode-beginning-of-line)
     map)
   "Keymap for `drupal-mode'")
@@ -421,6 +422,18 @@ buffer."
         (find-file-other-window dd)
         (auto-revert-tail-mode 1)))))
 
+(defun drupal-wrap-string-in-t-function ()
+  "If point is inside a string wrap the string in the t() function."
+  (interactive)
+  (when (eq (get-text-property (point) 'face) 'font-lock-string-face)
+    (save-excursion
+      (atomic-change-group
+        (search-backward-regexp "\\(\"\\|'\\)")
+        (insert "t(")
+        (forward-char)
+        (search-forward-regexp "\\(\"\\|'\\)")
+        (insert ")")))))
+
 
 
 (defvar drupal-form-id-history nil



reply via email to

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