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

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

[nongnu] elpa/drupal-mode 003953437c 067/308: Ensured blank line when `d


From: ELPA Syncer
Subject: [nongnu] elpa/drupal-mode 003953437c 067/308: Ensured blank line when `drupal-insert-hook'.
Date: Tue, 25 Jan 2022 10:59:29 -0500 (EST)

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

    Ensured blank line when `drupal-insert-hook'.
    
    And also when `drupal-insert-function' is used.
---
 drupal-mode.el | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drupal-mode.el b/drupal-mode.el
index bfdaf3ac88..0a458dba5a 100644
--- a/drupal-mode.el
+++ b/drupal-mode.el
@@ -347,6 +347,7 @@ Used by `drupal-insert-hook' to provide completions on 
hooks.")
                                  (funcall drupal-symbol-collection)
                                drupal-symbol-collection)
                              nil nil "hook_"))
+  (drupal-ensure-newline)
   "/**\n"
   " * Implements " v1 "().\n"
   " */\n"
@@ -357,6 +358,7 @@ Used by `drupal-insert-hook' to provide completions on 
hooks.")
 (define-skeleton drupal-insert-function
   "Insert Drupal function skeleton."
   nil
+  (drupal-ensure-newline)
   "/**\n"
   " * " @ "\n"
   " */\n"
@@ -364,6 +366,19 @@ Used by `drupal-insert-hook' to provide completions on 
hooks.")
   "  " @ _ "\n"
   "}\n")
 
+(defun drupal-ensure-newline (&optional num)
+  "Ensure (NUM) blank lines before point.
+Ensures there is NUM blank lines before point - if not it will insert them.
+Defaults to one blank line if optional argument NUM is not specified."
+  (unless num
+    (setq num 1))
+  (let ((result 0)
+        (num (+ 2 num)))
+    (newline (- num (dotimes (var num result)
+                      (when (looking-back (concat "
+\\{" (number-to-string var) "\\}") (line-beginning-position (- var)))
+                        (setq result (+ 1 result))))))))
+
 
 
 ;; Detect Drupal and Drupal version



reply via email to

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