[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/lua-mode 6436a45 398/468: Index "require" as imenu items
From: |
Philip Kaludercic |
Subject: |
[nongnu] elpa/lua-mode 6436a45 398/468: Index "require" as imenu items |
Date: |
Thu, 5 Aug 2021 04:59:16 -0400 (EDT) |
branch: elpa/lua-mode
commit 6436a45df5987b55a1208bc74a71830bd545fc88
Author: immerrr <immerrr+lua@gmail.com>
Commit: immerrr <immerrr+lua@gmail.com>
Index "require" as imenu items
---
lua-mode.el | 3 ++-
test/test-generic.el | 30 ++++++++++++++++++++++++++++++
2 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/lua-mode.el b/lua-mode.el
index 640e490..33f68c2 100644
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -662,7 +662,8 @@ Groups 6-9 can be used in any of argument regexps."
"Default expressions to highlight in Lua mode.")
(defvar lua-imenu-generic-expression
- `((nil ,(lua-rx (or bol ";") ws (opt (seq (symbol "local") ws))
lua-funcheader) 1))
+ `(("Requires" ,(lua-rx (or bol ";") ws (opt (seq (symbol "local") ws))
(group-n 1 lua-name) ws "=" ws (symbol "require")) 1)
+ (nil ,(lua-rx (or bol ";") ws (opt (seq (symbol "local") ws))
lua-funcheader) 1))
"Imenu generic expression for lua-mode. See `imenu-generic-expression'.")
(defvar lua-sexp-alist '(("then" . "end")
diff --git a/test/test-generic.el b/test/test-generic.el
index d7b6880..d0356b7 100644
--- a/test/test-generic.el
+++ b/test/test-generic.el
@@ -3,6 +3,8 @@
default-directory))
"utils.el") nil 'nomessage 'nosuffix)
+(require 'imenu)
+
(describe "lua-forward-sexp"
(it "properly scans through curly braces"
(with-lua-buffer
@@ -77,3 +79,31 @@
(it "is derived from prog-mode"
(with-lua-buffer
(expect (derived-mode-p 'prog-mode)))))
+
+(describe "imenu integration"
+ (it "indexes functions"
+ (with-lua-buffer
+ (insert "\
+function foo()
+ function bar() end
+ local function baz() end
+ qux = function() end
+ local quux = function() end
+end
+")
+ (expect (mapcar 'car (funcall imenu-create-index-function))
+ :to-equal '("foo" "bar" "baz" "qux" "quux"))))
+
+ (it "indexes require statements"
+ (with-lua-buffer
+ (insert "\
+foo = require (\"foo\")
+local bar = require (\"bar\")
+")
+ (expect (mapcar (lambda (item) (cons (car item)
+ (if (listp (cdr item))
+ (mapcar 'car (cdr item))
+ -1)))
+ (funcall imenu-create-index-function))
+ :to-equal '(("Requires" . ("foo" "bar")))))))
+
- [nongnu] elpa/lua-mode 432d9a0 333/468: lua-try-match-multiline-begin: reword the comment, (continued)
- [nongnu] elpa/lua-mode 432d9a0 333/468: lua-try-match-multiline-begin: reword the comment, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode ecfe465 352/468: Remove testing for Emacs < 24.3, and add 25.2 and 25.3, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 99312b8 365/468: Merge pull request #134 from velkyel/master, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 4342dd1 372/468: Fix compatibility with new rx package from Emacs 27, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 50d94a4 373/468: tests: silence "Indenting region..." messages, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode d746b7e 381/468: Fix typos, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode dc30240 384/468: Merge pull request #160 from tarsiiformes/typo, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 4db05e8 389/468: Use cl-lib instead of cl, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 3f67365 394/468: Renamed word “Result” to “Actual” in matcher's message, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 658bf8f 397/468: Merge pull request #166 from veprbl/patch-1, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 6436a45 398/468: Index "require" as imenu items,
Philip Kaludercic <=
- [nongnu] elpa/lua-mode 0e6813a 405/468: Refactor indentation tests to use test cases defined in *.lua files, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode acbcdc9 407/468: Don't prevent "block starter" tokens from starting continuation lines, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 4a45c6d 410/468: lua-make-indentation-info-pair: optimize "same-line" checks, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 8270df5 411/468: lua-is-continuing-statement-p: remove N^2 complexity on openers/closers, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode bf80b7e 414/468: Enable continuation after comma outside of parens/braces/brackets, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode afd5aa3 415/468: test-indentation: remove unused subr-x dependency, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode b170500 416/468: Add backport of string-trim not available in Emacs 24, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 5bfdea5 420/468: Merge pull request #177 from immerrr/refactor-variable-list-fontification, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 0546418 423/468: Extend lua-default-application doc a bit, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 9d46ad3 424/468: Update readme, Philip Kaludercic, 2021/08/05