all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: john muhl via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 65673@debbugs.gnu.org
Cc: philipk@posteo.net, arstoffel@gmail.com, maurooaranda@gmail.com,
	~emacs/emacs-devel@lists.sr.ht
Subject: bug#65673: [PATCH emacs 1/1 v2] Add lua-ts-mode
Date: Sat,  9 Sep 2023 10:17:20 -0500	[thread overview]
Message-ID: <20230909151834.3613907-1-jm@pub.pink> (raw)
In-Reply-To: <169352253839.28940.16024479871485106701-0@git.sr.ht>

Mauro Aranda <maurooaranda@gmail.com> writes:

> I just have some comments/questions about the defcustoms:

Fixed.

Philip Kaludercic <philipk@posteo.net> writes:

> ~johnmuhl <johnmuhl@git.sr.ht> writes:
>
>> +(defcustom lua-ts-lua-manual
>> +  (if (file-readable-p "/usr/share/doc/lua/manual.html")
>> +      "file:///usr/share/doc/lua/manual.html" "")
>> +  "Location of the Lua `manual.html' file."
>> +  :type 'string
>> +  :safe 'stringp
>> +  :group 'lua
>> +  :version "30.1")
>
> Could this fall back to some online manual?

I went with Augusto’s suggestion and removed the documentation
command.

>> +(defcustom inferior-lua-interpreter "lua"
>> +  "Program to run in the inferior Lua process."
>> +  :type 'string
>> +  :safe 'stringp
>> +  :group 'lua
>> +  :version "30.1")
>
> Are you sure that any string is safe?  That would include "rm -rf ~".

Fixed here and for the startfile and command line options.

>> +;;;###autoload
>> +(define-derived-mode lua-ts-mode prog-mode "Lua"
>> +  "Major mode for editing Lua files, powered by tree-sitter."
>> +  :group 'lua
>
> The :group is redundant here, it will automatically use the last
> defgroup defined in the file.

Fixed.

Augusto Stoffel <arstoffel@gmail.com> writes:

> On Thu, 31 Aug 2023 at 16:32, ~johnmuhl wrote:
>
>> +(defcustom inferior-lua-switches "-i"
>> +  "Command line options for the inferior Lua process."
>> +  :type 'string
>> +  :safe 'stringp
>> +  :group 'lua
>> +  :version "30.1")
>
> This should be given as a list of strings rather a string that you later
> need to call split-string-shell-command on.

Fixed.

> Also, I think it's probably best to use the same lua-ts- prefix

Changed to lua-ts-inferior-*

>> +(defun lua-ts-documentation-at-point ()
>> +  "Show documentation of function at point in Lua manual."
>> +  (interactive)
>> +  (unless (string-blank-p lua-ts-lua-manual)
>> +    (let ((character-before (char-to-string (char-before)))
>> +          id)
>> +      (save-excursion
>> +        ;; When point is mid-word `treesit-thing-at-point'
>> +        ;; may return the parent node of the thing at point.
>> +        (unless (or (bolp)
>> +                    (not (string-match-p "[[:alnum:]]" character-before)))
>> +          (backward-word))
>> +        (let ((node (treesit-thing-at-point 'builtin nil)))
>> +          (setq id (pcase (treesit-node-type node)
>> +                     ("dot_index_expression" (treesit-node-text node t))
>> +                     ("function_call"
>> + (let* ((child (treesit-node-child-by-field-name node "name"))
>> +                             (name (treesit-node-text child t)))
>> +                        (if (string-match-p ":" name)
>> +                            (replace-regexp-in-string "^.*:" "file:" name)
>> +                          name)))))))
>> +      (when id (browse-url (concat lua-ts-lua-manual "#pdf-" id))))))
>
> I wouldn't add this command.  It's not polished enough and too ad-hoc in
> the sense that this functionality is (or should be) covered by other
> mechanisms: Info, Eldoc, etc.

Removed.

>> +    ;; Outline.
>> +    (setq-local outline-regexp
>> +                (rx (or "--[[" "do" "for" "if" "repeat" "while"
>> +                        (seq (** 0 1 "local ") "function"))))
>
> What is the idea behind "--[["?

I like the way o-m-m folds the header sections of elisp files and
since my lua files often start with a multi-line comment containing
similar information I added it to get that effect in lua too.

> Should one allow whitespace in front of these strings (also inferring
> the outline level from that)?

Done.

> Also, one should allow arbitrary whitespace after "local" (I'd say
> "local\\s-+") and enclose the keywords with "\\_<...\\_>".

Fixed.







  parent reply	other threads:[~2023-09-09 15:17 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-31 22:55 bug#65673: [PATCH emacs 0/1] Add lua-ts-mode ~johnmuhl
2023-08-31 21:32 ` bug#65672: [PATCH emacs 1/1] " ~johnmuhl
2023-09-02 12:14   ` bug#65673: [PATCH emacs 0/1] " Philip Kaludercic
2023-09-02 14:10   ` bug#65672: [PATCH emacs 1/1] " Augusto Stoffel
     [not found]   ` <handler.65672.B.169354983214451.ack@debbugs.gnu.org>
2023-09-04 14:36     ` john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-04 15:18       ` Eli Zaretskii
2023-09-04 15:54       ` Philip Kaludercic
2023-09-01 22:46 ` bug#65673: [PATCH emacs 0/1] " Mauro Aranda
2023-09-09 15:17 ` john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-09-09 15:17   ` bug#65673: [PATCH] " john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-10 11:12     ` Philip Kaludercic
2023-09-10 12:57       ` Augusto Stoffel
2023-09-11 15:03 ` john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-16 10:03   ` Eli Zaretskii
2023-09-16 11:17     ` Eli Zaretskii
2023-09-16 11:21       ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230909151834.3613907-1-jm@pub.pink \
    --to=bug-gnu-emacs@gnu.org \
    --cc=65673@debbugs.gnu.org \
    --cc=arstoffel@gmail.com \
    --cc=jm@pub.pink \
    --cc=maurooaranda@gmail.com \
    --cc=philipk@posteo.net \
    --cc=~emacs/emacs-devel@lists.sr.ht \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.