From 15867bb63d1d4109780652c5b3580870857b27b9 Mon Sep 17 00:00:00 2001 From: Johan Claesson Date: Tue, 5 Sep 2017 22:06:38 +0200 Subject: Emacs: Guess type of tag definition in Emacs 24 This concerns tag finding commands in Emacs 24. If the word at point is preceded by a hash suggest as default a jump to a record definition. If it is a question mark suggest a macro. Otherwise assume it is a function. If it is not a qualified call assume it is a local function. --- lib/tools/emacs/erlang.el | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/tools/emacs/erlang.el b/lib/tools/emacs/erlang.el index 012de479d3..f3c3a6bae1 100644 --- a/lib/tools/emacs/erlang.el +++ b/lib/tools/emacs/erlang.el @@ -2083,12 +2083,6 @@ This function is aware of imported functions." (when funcname (erlang-man-find-function (current-buffer) funcname)))))) -(defun erlang-default-function-or-module () - (let ((id (erlang-get-identifier-at-point))) - (if (eq (erlang-id-kind id) 'qualified-function) - (format "%s:%s" (erlang-id-module id) (erlang-id-name id)) - (erlang-id-name id)))) - ;; Should the defadvice be at the top level, the package `advice' would ;; be required. Now it is only required when this functionality @@ -3792,6 +3786,21 @@ of arguments could be found, otherwise nil." (nth 3 (erlang-id-to-list id))) +(defun erlang-default-function-or-module () + (erlang-with-id (kind module name) (erlang-get-identifier-at-point) + (let ((x (cond ((eq kind 'module) + (format "%s:" name)) + ((eq kind 'record) + (format "-record(%s" name)) + ((eq kind 'macro) + (format "-define(%s" name)) + (t + name)))) + (if module + (format "%s:%s" module x) + x)))) + + ;; TODO: Escape single quotes inside the string without ;; replace-regexp-in-string. (defun erlang-add-quotes-if-needed (str) -- cgit v1.2.3 From ba25346f6e5aec1399cb8b97209e8cc127b8e8eb Mon Sep 17 00:00:00 2001 From: Johan Claesson Date: Sat, 26 Aug 2017 12:02:34 +0200 Subject: Emacs: Update erlang-xref-find-definitions-module for Emacs 26 The number of arguments to visit-tags-table-buffer have increased in Emacs 26. --- lib/tools/emacs/erlang.el | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/tools/emacs/erlang.el b/lib/tools/emacs/erlang.el index f3c3a6bae1..63ad21b138 100644 --- a/lib/tools/emacs/erlang.el +++ b/lib/tools/emacs/erlang.el @@ -5008,9 +5008,10 @@ considered first when it is time to jump to the definition.") (and (fboundp 'xref-make) (fboundp 'xref-make-file-location) (let* ((first-time t) + (cbuf (current-buffer)) xrefs matching-files) (save-excursion - (while (visit-tags-table-buffer (not first-time)) + (while (erlang-visit-tags-table-buffer (not first-time) cbuf) (setq first-time nil) (let ((files (tags-table-files))) (while files @@ -5026,6 +5027,10 @@ considered first when it is time to jump to the definition.") (setq files (cdr files)))))) (nreverse xrefs)))) +(defun erlang-visit-tags-table-buffer (cont cbuf) + (if (< emacs-major-version 26) + (visit-tags-table-buffer cont) + (visit-tags-table-buffer cont cbuf))) (defun erlang-xref-find-definitions-module-tag (module tag -- cgit v1.2.3