From 8ad70d4213247e44ee7b99088149a601a7bb5e73 Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Thu, 23 Nov 2023 19:47:49 +0100 Subject: [PATCH] update terraform Signed-off-by: Andreas Gerler --- .../terraform-mode-pkg.el | 2 - .../terraform-mode-autoloads.el | 4 ++ .../terraform-mode-pkg.el | 14 +++++++ .../terraform-mode.el | 38 ++++++++++++++----- 4 files changed, 46 insertions(+), 12 deletions(-) delete mode 100644 elpa/terraform-mode-20230502.2213/terraform-mode-pkg.el rename elpa/{terraform-mode-20230502.2213 => terraform-mode-20230607.1923}/terraform-mode-autoloads.el (91%) create mode 100644 elpa/terraform-mode-20230607.1923/terraform-mode-pkg.el rename elpa/{terraform-mode-20230502.2213 => terraform-mode-20230607.1923}/terraform-mode.el (91%) diff --git a/elpa/terraform-mode-20230502.2213/terraform-mode-pkg.el b/elpa/terraform-mode-20230502.2213/terraform-mode-pkg.el deleted file mode 100644 index cc3d516c..00000000 --- a/elpa/terraform-mode-20230502.2213/terraform-mode-pkg.el +++ /dev/null @@ -1,2 +0,0 @@ -;;; Generated package description from terraform-mode.el -*- no-byte-compile: t -*- -(define-package "terraform-mode" "20230502.2213" "Major mode for terraform configuration file" '((emacs "24.3") (hcl-mode "0.3") (dash "2.17.0")) :commit "56f19abae95afb7e13e48ec3e6aeba3820d31307" :authors '(("Syohei YOSHIDA" . "syohex@gmail.com")) :maintainers '(("Syohei YOSHIDA" . "syohex@gmail.com")) :maintainer '("Syohei YOSHIDA" . "syohex@gmail.com") :url "https://github.com/syohex/emacs-terraform-mode") diff --git a/elpa/terraform-mode-20230502.2213/terraform-mode-autoloads.el b/elpa/terraform-mode-20230607.1923/terraform-mode-autoloads.el similarity index 91% rename from elpa/terraform-mode-20230502.2213/terraform-mode-autoloads.el rename to elpa/terraform-mode-20230607.1923/terraform-mode-autoloads.el index 419183f1..e749752d 100644 --- a/elpa/terraform-mode-20230502.2213/terraform-mode-autoloads.el +++ b/elpa/terraform-mode-20230607.1923/terraform-mode-autoloads.el @@ -19,6 +19,10 @@ Major mode for editing terraform configuration file (register-definition-prefixes "terraform-mode" '("terraform-")) +;;;*** + +;;;### (autoloads nil nil ("terraform-mode-pkg.el") (0 0 0 0)) + ;;;*** ;; Local Variables: diff --git a/elpa/terraform-mode-20230607.1923/terraform-mode-pkg.el b/elpa/terraform-mode-20230607.1923/terraform-mode-pkg.el new file mode 100644 index 00000000..30b94e09 --- /dev/null +++ b/elpa/terraform-mode-20230607.1923/terraform-mode-pkg.el @@ -0,0 +1,14 @@ +(define-package "terraform-mode" "20230607.1923" "Major mode for terraform configuration file" + '((emacs "24.3") + (hcl-mode "0.3") + (dash "2.17.0")) + :commit "25a22a66f81e35c75f2fdaaab89aad7f9940fe06" :authors + '(("Syohei YOSHIDA" . "syohex@gmail.com")) + :maintainers + '(("Syohei YOSHIDA" . "syohex@gmail.com")) + :maintainer + '("Syohei YOSHIDA" . "syohex@gmail.com") + :url "https://github.com/syohex/emacs-terraform-mode") +;; Local Variables: +;; no-byte-compile: t +;; End: diff --git a/elpa/terraform-mode-20230502.2213/terraform-mode.el b/elpa/terraform-mode-20230607.1923/terraform-mode.el similarity index 91% rename from elpa/terraform-mode-20230502.2213/terraform-mode.el rename to elpa/terraform-mode-20230607.1923/terraform-mode.el index 24ef8b8b..4c0182a2 100644 --- a/elpa/terraform-mode-20230502.2213/terraform-mode.el +++ b/elpa/terraform-mode-20230607.1923/terraform-mode.el @@ -4,8 +4,6 @@ ;; Author: Syohei YOSHIDA ;; URL: https://github.com/syohex/emacs-terraform-mode -;; Package-Version: 20230502.2213 -;; Package-Commit: 56f19abae95afb7e13e48ec3e6aeba3820d31307 ;; Version: 0.06 ;; Package-Requires: ((emacs "24.3") (hcl-mode "0.03") (dash "2.17.0")) @@ -254,31 +252,49 @@ (when (re-search-forward (concat "/\\(.*?\\)/" provider "\\]") nil t) (match-string 1))))) -(defun terraform--resource-url (resource) - "Return the url containing the documentation for RESOURCE." +(defun terraform--resource-url (resource doc-dir) + "Return the url containing the documentation for RESOURCE using DOC-DIR." (let* ((provider (terraform--extract-provider resource)) (provider-ns (terraform--get-resource-provider-namespace provider)) (resource-name (terraform--extract-resource resource))) (if provider-ns - (format "https://registry.terraform.io/providers/%s/%s/latest/docs/resources/%s" + (format "https://registry.terraform.io/providers/%s/%s/latest/docs/%s/%s" provider-ns provider + doc-dir resource-name) (user-error "Can not determine the provider namespace for %s" provider)))) (defun terraform--resource-url-at-point () (save-excursion (goto-char (line-beginning-position)) - (unless (looking-at-p "^resource") - (re-search-backward "^resource" nil t)) - (forward-symbol 2) - (terraform--resource-url (thing-at-point 'symbol)))) + (unless (looking-at-p "^resource\\|^data") + (re-search-backward "^resource\\|^data" nil t)) + (let ((doc-dir (if (equal (word-at-point) "data") "data-sources" "resources"))) + (forward-symbol 2) + (terraform--resource-url (thing-at-point 'symbol) doc-dir)))) (defun terraform-open-doc () "Open a browser at the URL documenting the resource at point." (interactive) (browse-url (terraform--resource-url-at-point))) +(defun terraform-kill-doc-url () + "Kill the URL documenting the resource at point (i.e. copy it to the clipboard)." + (interactive) + (let* ((url (substring-no-properties (terraform--resource-url-at-point)))) + (kill-new url) + (message "Copied URL: %s" url))) + +(defun terraform-insert-doc-in-comment () + "Insert a comment containing an URL documenting the resource at point." + (interactive) + (let ((doc-url (terraform--resource-url-at-point))) + (save-excursion + (unless (looking-at-p "^resource\\|^data") + (re-search-backward "^resource\\|^data" nil t)) + (insert (format "# %s\n" doc-url))))) + (defun terraform--outline-level () "Return the depth to which a statement is nested in the outline. @@ -316,7 +332,9 @@ If the point is not at the heading, call (defvar terraform-mode-map (let ((map (make-sparse-keymap))) - (define-key map (kbd "C-c C-h") #'terraform-open-doc) + (define-key map (kbd "C-c C-d C-w") #'terraform-open-doc) + (define-key map (kbd "C-c C-d C-c") #'terraform-kill-doc-url) + (define-key map (kbd "C-c C-d C-r") #'terraform-insert-doc-in-comment) (define-key map (kbd "C-c C-f") #'outline-toggle-children) map)) -- 2.47.3