Skip to content

Commit dc82e54

Browse files
committed
Handle .info.yml files
1 parent 76c2888 commit dc82e54

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

drupal-mode.el

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ Include path to the executable if it is not in your $PATH."
159159
:group 'drupal)
160160

161161
;;;###autoload
162-
(defcustom drupal-info-modes (list 'conf-windows-mode)
162+
(defcustom drupal-info-modes (list 'conf-windows-mode 'yaml-mode)
163163
"Major modes to consider info files in Drupal mode."
164164
:type '(repeat symbol)
165165
:group 'drupal)
@@ -806,13 +806,12 @@ older implementation of `locate-dominating-file'."
806806
(let ((prev-user user))
807807
(setq user (nth 2 (file-attributes dir)))
808808
(or (null prev-user) (equal user prev-user))))
809-
(if (and (setq files (condition-case nil
810-
(directory-files dir 'full "\\(.+\\)\\.info\\'" 'nosort)
811-
(error nil)))
812-
(file-exists-p (concat (file-name-sans-extension (car files)) ".module")))
809+
(if (setq files (condition-case nil
810+
(directory-files dir 'full "\\(.+\\)\\.info\\(\\.yml\\)\\'" 'nosort)
811+
(error nil)))
813812
(if info-file-location
814813
(throw 'found (car files))
815-
(throw 'found (file-name-nondirectory (file-name-sans-extension (car files)))))
814+
(throw 'found (file-name-nondirectory (file-name-sans-extension(file-name-sans-extension (car files))))))
816815
(if (equal dir
817816
(setq dir (file-name-directory
818817
(directory-file-name dir))))
@@ -831,7 +830,7 @@ Used in `drupal-insert-hook' and `drupal-insert-function'."
831830
drupal-module
832831
;; Otherwise fall back to a very naive
833832
;; way of guessing the module name.
834-
(file-name-nondirectory (file-name-sans-extension (or buffer-file-name (buffer-name))))))))
833+
(file-name-nondirectory (file-name-sans-extension (file-name-sans-extension (or buffer-file-name (buffer-name)))))))))
835834
(if (called-interactively-p 'any)
836835
(insert name)
837836
name)))

drupal/autoinsert.el

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
;;; Code:
2828

2929
(define-auto-insert '("\\.info\\'" . "Drupal info file") 'drupal/autoinsert-insert-info-skeleton)
30+
(define-auto-insert '("\\.info\\.yml\\'" . "Drupal info YML file") 'drupal/autoinsert-insert-info-yml-skeleton)
3031
(define-auto-insert '("\\.module\\'" . "Drupal module file") 'drupal/autoinsert-insert-module-skeleton)
3132
(define-auto-insert '("\\.install\\'" . "Drupal install file") 'drupal/autoinsert-insert-install-skeleton)
3233
(define-auto-insert '("\\.test\\'" . "Drupal test file") 'drupal/autoinsert-insert-test-skeleton)
@@ -51,6 +52,16 @@
5152
(when v2 "; required = ") & @ (when v2 "TRUE\n")
5253
(when v2 "; hidden = ") & @ (when v2 "TRUE\n"))
5354

55+
(define-skeleton drupal/autoinsert-insert-info-yml-skeleton
56+
"Drupal 8 info.yml file skeleton."
57+
nil
58+
'(setq v1 (file-name-nondirectory (file-name-sans-extension (file-name-sans-extension (or buffer-file-name (buffer-name))))))
59+
'(setq v2 (if (string= (drupal-major-version) "8") "^8 || ^9" (concat "^" (drupal-major-version))))
60+
"name: " @ - (upcase-initials (replace-regexp-in-string "[-_\\.]+" " " v1)) \n
61+
"description: " @ (replace-regexp-in-string "[-_\\.]+" " " v1) \n
62+
"type: module" @ \n
63+
"core_version_requirement: " @ v2 "\n")
64+
5465
(define-skeleton drupal/autoinsert-insert-module-skeleton
5566
"Drupal module file skeleton."
5667
nil

0 commit comments

Comments
 (0)