[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/drupal-mode f150913830 050/308: Added skeletons for functi
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/drupal-mode f150913830 050/308: Added skeletons for functions and hooks. |
Date: |
Tue, 25 Jan 2022 10:59:22 -0500 (EST) |
branch: elpa/drupal-mode
commit f150913830517e972e6bd98b98469e15af6d00cd
Author: Arne Jørgensen <arne@arnested.dk>
Commit: Arne Jørgensen <arne@arnested.dk>
Added skeletons for functions and hooks.
Fixes #8.
---
drupal-mode.el | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/drupal-mode.el b/drupal-mode.el
index 662f09b1a5..389472c9b1 100644
--- a/drupal-mode.el
+++ b/drupal-mode.el
@@ -148,6 +148,8 @@ Include path to the executable if it is not in your $PATH."
(let ((map (make-sparse-keymap)))
(define-key map "\C-cdf" 'drupal-search-documentation)
(define-key map "\C-cdc" 'drupal-drush-cache-clear)
+ (define-key map "\C-cdih" 'drupal-insert-hook)
+ (define-key map "\C-cdif" 'drupal-insert-function)
map)
"Keymap for `drupal-mode'")
@@ -309,6 +311,29 @@ should save your files with unix style end of line."
+(define-skeleton drupal-insert-hook
+ "Insert Drupal hook function skeleton."
+ nil
+ '(setq v1 (skeleton-read "Hook: " "hook_"))
+ "/**\n"
+ " * Implements " v1 "().\n"
+ " */\n"
+ "function " (replace-regexp-in-string "hook" (drupal-module-name) v1) "(" @
- ") {\n"
+ " " @ _ "\n"
+ "}\n")
+
+(define-skeleton drupal-insert-function
+ "Insert Drupal function skeleton."
+ nil
+ "/**\n"
+ " * " @ "\n"
+ " */\n"
+ "function " (drupal-module-name) "_" @ - "(" @ ") {\n"
+ " " @ _ "\n"
+ "}\n")
+
+
+
;; Detect Drupal and Drupal version
(defun drupal-detect-drupal-version ()
"Detect if the buffer is part of a Drupal project.
@@ -391,6 +416,19 @@ older implementation of `locate-dominating-file'."
(setq dir nil))))
nil)))
+(defun drupal-module-name ()
+ "Return Drupal module name suitable for function names.
+This will return the best guess at the name of the Drupal module
+and encoded suitable for use as function name prefixes.
+
+Used in `drupal-insert-hook' and `drupal-insert-function'."
+ (replace-regexp-in-string "-" "_"
+ (if drupal-module
+ drupal-module
+ ;; Otherwise fall back to a very naive
+ ;; way of guessing the module name.
+ (file-name-nondirectory
(file-name-sans-extension (buffer-file-name))))))
+
(defun drupal-major-version (&optional version)
"Return major version number of version string.
If major version number is 4 - return both major and minor."
- [nongnu] elpa/drupal-mode cda13dfb21 063/308: Added better bootstrapping of Drupal mode., (continued)
- [nongnu] elpa/drupal-mode cda13dfb21 063/308: Added better bootstrapping of Drupal mode., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 55a523b65f 046/308: No need to restart check since flymake-phpcs 1.0.4, ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode f02cb3d8eb 044/308: Drupal version also outside full projects., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode d9a34a4a5f 065/308: Enabled `gtags-mode` if GTAGS is in use., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode f491ac72b9 081/308: Redefined key bindings., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 8e19894d55 051/308: `drupal-insert-hook' got completing-read support., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode af2b2c5a76 118/308: Changed `replace-regexp-in-string` to `subst-char-in-string`., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 243db30a93 004/308: Compiled elisp should not be committed., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 21a3c7544d 049/308: Drupal menu adjusted., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode d3b4c6f1e7 112/308: Added variable for GNU GLOBAL`global' command., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode f150913830 050/308: Added skeletons for functions and hooks.,
ELPA Syncer <=
- [nongnu] elpa/drupal-mode 6a7322f581 052/308: Optimized for byte-compile by using #' shorthand., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode d0031d4c1f 056/308: Added/adjusted COPYING information., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode b4496a561f 047/308: Revert parts of 55a523b65fe53ca06f429cffd91ead6ff76667d2, ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode b34cc6fb8f 042/308: Ensured flymake-phpcs is run in php-mode buffers., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 88d744068c 073/308: Fixed regexp., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode d23d66e624 083/308: Support `php-extras-eldoc-documentation-function'., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode d73965852e 085/308: Fixed flaw in `drupal-major-version'., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 5c53b742fb 087/308: Improved buffer-file-name fallbacks., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode e65bf476cd 090/308: Fixed module version for Drupal core modules., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 0ef0569693 088/308: Fixed keyboard shortcuts in documentation., ELPA Syncer, 2022/01/25