unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Philip Kaludercic <philipk@posteo.net>
To: Jeremy Bryant <jb@jeremybryant.net>
Cc: "emacs-devel@gnu.org" <emacs-devel@gnu.org>,
	 Jay Kamat <jaygkamat@gmail.com>,  <monnier@iro.umontreal.ca>
Subject: Re: NonGNU ELPA: Conditions for accepting a potential new package 'rmsbolt' ?
Date: Tue, 27 Feb 2024 07:47:58 +0000	[thread overview]
Message-ID: <87y1b6tkk1.fsf@posteo.net> (raw)
In-Reply-To: <877ciqn8wg.fsf@jeremybryant.net> (Jeremy Bryant's message of "Mon, 26 Feb 2024 22:40:17 +0000")

[-- Attachment #1: Type: text/plain, Size: 815 bytes --]

Jeremy Bryant <jb@jeremybryant.net> writes:

> Philip Kaludercic <philipk@posteo.net> writes:
>
>> Jeremy Bryant <jb@jeremybryant.net> writes:
>>
>>> I would like to recommend the package 'rmsbolt' for NonGNU ELPA and
>>> volunteer for any required changes.
>>>
>>> The author is Jay Kamat, who as I understand is potentially supportive
>>> if the changes are minimal (and I am volunteering for these.)
>>
>> Minimal as in "small diff" or "small effort"?
>
> I believe the author is supportive if the changes are a small effort.

It would be nice if the checkdoc errors could be address, since there
are a few of them, but that is not a hard-constraint.

>>
>>> It is currently hosted on gitlab and distributed on MELPA.
>>
>> Could you provide a URL?
>
> https://gitlab.com/jgkamat/rmsbolt

Here are my comments:


[-- Attachment #2: Type: text/plain, Size: 32335 bytes --]

diff --git a/rmsbolt.el b/rmsbolt.el
index bdc457f..b2f2049 100644
--- a/rmsbolt.el
+++ b/rmsbolt.el
@@ -1,6 +1,7 @@
 ;;; rmsbolt.el --- A compiler output viewer -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2018-2021 Jay Kamat
+;; Copyright (C) 2018-2023 Jay Kamat
+
 ;; Author: Jay Kamat <jaygkamat@gmail.com>
 ;; Version: 0.1.2
 ;; Keywords: compilation, tools
@@ -40,8 +41,10 @@
 ;; 4. Provide an interface for highlighting the matched assembly/bytecode line
 ;; to the source and vice versa
 ;;
-;; Tweakables:
-;; RMSBolt is primarily configured with Emacs local variables. This lets you
+
+;;;; Tweakables:
+
+;; RMSBolt is primarily configured with Emacs local variables.  This lets you
 ;; change compiler and rmsbolt options simply by editing a local variable block.
 ;;
 ;; Notable options:
@@ -80,25 +83,25 @@
 ;;; Code:
 ;;;; Customize:
 (defgroup rmsbolt nil
-  "rmsbolt customization options"
+  "rmsbolt customization options."
   :group 'applications)
 
 (defcustom rmsbolt-use-overlays t
   "Whether we should use overlays to show matching code."
-  :type 'boolean
-  :group 'rmsbolt)
+  :type 'boolean)
+
 (defcustom rmsbolt-goto-match t
   "Whether we should goto the match in the other buffer if it is non visible."
-  :type 'boolean
-  :group 'rmsbolt)
-(defcustom rmsbolt-mode-lighter " RMS🗲"
+  :type 'boolean)
+
+(defcustom rmsbolt-mode-lighter " RMS🗲"	;could the unicode charachter be removed?  it can unnecessarily resize the mode line.
   "Lighter displayed in mode line when function `rmsbolt-mode' is active."
-  :type 'string
-  :group 'rmsbolt)
+  :type 'string)
+
 (defcustom rmsbolt-large-buffer-size 500
   "Number of lines past which a buffer is considred large."
-  :type 'integer
-  :group 'rmsbolt)
+  :type 'natnum)
+
 (defcustom rmsbolt-automatic-recompile t
   "Whether to automatically save and recompile the source buffer.
 This setting is automatically disabled on large buffers, set to
@@ -107,29 +110,28 @@ manually saved, set to `on-save'."
   :type '(choice (const :tag "Off" nil)
                  (const :tag "On save" on-save)
                  (const :tag "On" t)
-                 (const :tag "Always" force))
-  :group 'rmsbolt)
+                 (const :tag "Always" force)))
 
 ;;;;; Buffer Local Tweakables
 (defcustom rmsbolt-disassemble nil
   "Whether we should disassemble an output binary."
   :type 'boolean
-  :safe 'booleanp
-  :group 'rmsbolt)
+  :safe 'booleanp)
+
 (defcustom rmsbolt-command nil
   "The base command to run rmsbolt from."
   :type 'string
   ;; nil means use default command
-  :safe (lambda (v) (or (booleanp v) (stringp v)))
-  :group 'rmsbolt)
+  :safe (lambda (v) (or (booleanp v) (stringp v))))
+
 (defcustom rmsbolt-default-directory nil
   "The default directory to compile from.
 This must be an absolute path if set.
 Some exporters (such as pony) may not work with this set."
   :type 'string
   ;; nil means use default command
-  :safe (lambda (v) (or (booleanp v) (stringp v)))
-  :group 'rmsbolt)
+  :safe (lambda (v) (or (booleanp v) (stringp v))))
+
 (define-obsolete-variable-alias 'rmsbolt-intel-x86
   'rmsbolt-asm-format "RMSBolt-0.2"
   "Sorry about not providing a proper migration for this variable.
@@ -142,6 +144,7 @@ tool defaults -> nil
 
 This means that if you had rmsbolt-intel-x86 set manually, you
 are now getting tool defaults.")
+
 (defcustom rmsbolt-asm-format "intel"
   "Which output assembly format to use.
 
@@ -155,45 +158,44 @@ If you are not on x86, you most likely want to set this to nil.
 Since this defaults to \"intel\", implementers must support this
 being set (at worst falling back to nil if passed \"intel\")."
   :type 'string
-  :safe (lambda (v) (or (booleanp v) (stringp v)))
-  :group 'rmsbolt)
+  :safe (lambda (v) (or (booleanp v) (stringp v))))
+
 (defcustom rmsbolt-filter-directives t
   "Whether to filter assembly directives."
   :type 'boolean
-  :safe 'booleanp
-  :group 'rmsbolt)
+  :safe 'booleanp)
+
 (defcustom rmsbolt-filter-labels t
   "Whether to filter unused labels."
   :type 'boolean
-  :safe 'booleanp
-  :group 'rmsbolt)
+  :safe 'booleanp)
+
 (defcustom rmsbolt-filter-comment-only t
   "Whether to filter comment-only lines."
   :type 'boolean
-  :safe 'booleanp
-  :group 'rmsbolt)
+  :safe 'booleanp)
+
 (defcustom rmsbolt-ignore-binary-limit nil
-  "Whether to ignore the binary limit. Could hang emacs..."
+  "Whether to ignore the binary limit.  Could hang emacs..."
   :type 'boolean
-  :safe 'booleanp
-  :group 'rmsbolt)
+  :safe 'booleanp)
+
 (defcustom rmsbolt-demangle t
   "Whether to attempt to demangle the resulting assembly."
   :type 'boolean
-  :safe 'booleanp
-  :group 'rmsbolt)
+  :safe 'booleanp)
+
 (defcustom rmsbolt-flag-quirks t
   "Whether to tweak flags to enable as many features as possible.
 
 In most cases, we will try to honor flags in rmsbolt-command as
-much as possible. However, some features may be disabled with
-some odd combinations of flags. This variable controls
+much as possible.  However, some features may be disabled with
+some odd combinations of flags.  This variable controls
 removing/adding flags to handle those cases.
 
 Note that basic flags to ensure basic usage are always modified."
   :type 'boolean
-  :safe 'booleanp
-  :group 'rmsbolt)
+  :safe 'booleanp)
 
 (defcustom rmsbolt-after-parse-hook nil
   "Hook after all parsing is done, but before compile command is run.
@@ -201,7 +203,6 @@ Note that basic flags to ensure basic usage are always modified."
 Exercise caution when setting variables in this hook - doing so
 can disrupt rmsbolt state and cause issues. Variables set here
 may not be cleared to default as variables are usually."
-  :group 'rmsbolt
   :type 'hook)
 
 ;;;; Faces
@@ -241,16 +242,15 @@ Used to work around inconsistencies in alternative shells.")
 Please DO NOT modify this blindly, as this directory will get
 deleted on Emacs exit.")
 
-(defvar rmsbolt-dir nil
+(defvar rmsbolt-dir (and load-file-name (file-name-directory load-file-name))
   "The directory which rmsbolt is installed to.")
-(when load-file-name
-  (setq rmsbolt-dir (file-name-directory load-file-name)))
 
 (defvar-local rmsbolt-src-buffer nil)
 
 (defvar-local rmsbolt--real-src-file nil
   "If set, the real filename that we compiled from,
-probably due to a copy from this file.")
+probably due to a copy from this file.") ;^there is a checkdoc warning here
+
 ;; FIXME should we be unbinding the list here, or is setting nil good enough.
 (defvar-local rmsbolt--default-variables nil
   "A list of the buffer-local variables we filled in with defaults.
@@ -395,7 +395,7 @@ Please be careful when setting this, as it bypasses most logic and is
 generally not useful."))
 
 ;;;; Helper Functions
-(defun rmsbolt--convert-file-name-to-system-type (file-name)
+(defun rmsbolt--convert-file-name-to-system-type (file-name) ;perhaps use `convert-standard-filename'?
   "Convert the argument FILE-NAME to windows format if `system-type' is equal to `cygwin'.
 Additional escaping with double quotes included to avoid backslashes loss in cygwin environment.
 If not `cygwin' then bypass the FILE-NAME."
@@ -417,7 +417,7 @@ Return value is quoted for passing to the shell."
             (rmsbolt-output-filename ,src-buffer)))))
      ,@body))
 
-(defmacro rmsbolt--set-local (var val)
+(defmacro rmsbolt--set-local (var val)	;`setq-local' is avaliable from 24.3 onwards
   "Set unquoted variable VAR to value VAL in current buffer."
   (declare (debug (symbolp form)))
   `(set (make-local-variable ,var) ,val))
@@ -513,6 +513,7 @@ this."
                                            " "))
                           " ")))
      cmd)))
+
 (cl-defun rmsbolt--lisp-compile-cmd (&key src-buffer)
   "Process a compile command for common lisp.
 
@@ -542,6 +543,7 @@ this."
                    " "))
        (_
         (error "This Common Lisp interpreter is not supported"))))))
+
 (cl-defun rmsbolt--rust-compile-cmd (&key src-buffer)
   "Process a compile command for rustc."
   (rmsbolt--with-files
@@ -563,6 +565,7 @@ this."
                                   (concat "-Cllvm-args=--x86-asm-syntax=" asm-format)))
                           " ")))
      cmd)))
+
 (cl-defun rmsbolt--go-compile-cmd (&key src-buffer)
   "Process a compile command for go."
   (rmsbolt--with-files
@@ -576,12 +579,13 @@ this."
                                 src-filename)
                           " ")))
      cmd)))
+
 (cl-defun rmsbolt--d-compile-cmd (&key src-buffer)
   "Process a compile command for d"
   (rmsbolt--with-files
    src-buffer
    (let* ((compiler (buffer-local-value 'rmsbolt-command src-buffer))
-          (cmd (mapconcat
+          (cmd (mapconcat		;you have `string-join' in subr-x
                 #'identity
                 (list compiler "-g" "-output-s" src-filename "-of" output-filename)
                 " ")))
@@ -624,6 +628,7 @@ this."
                                (buffer-file-name))
                               dir)))
     cmd))
+
 (cl-defun rmsbolt--py-compile-cmd (&key src-buffer)
   "Process a compile command for python3."
   (rmsbolt--with-files
@@ -676,6 +681,7 @@ https://github.com/derickr/vld"
                                 "-o" output-filename)
                           " ")))
      cmd)))
+
 (cl-defun rmsbolt--java-compile-cmd (&key src-buffer)
   "Process a compile command for ocaml.
 
@@ -771,6 +777,7 @@ https://github.com/derickr/vld"
               "frame_dummy"
               (and ".plt" (0+ any)))
       eol))
+
 (defvar rmsbolt--hidden-func-ocaml
   (rx bol
       (or (and "__" (0+ any))
@@ -782,11 +789,13 @@ https://github.com/derickr/vld"
           (and (or "caml_" "camlStd_") (0+ any))
           (and "caml" (or "Pervasives" "List" "Bytes"
                           "String" "Buffer" "Printf"
-                          "Char" "Sys") "__" (0+ any))
+                          "Char" "Sys")
+	       "__" (0+ any))
           ;; Ocaml likes to make labels following camlModule__,
           ;; filter out any lowercase
           (and (1+ (1+ lower) (opt (or "64" "32" "8" "16")) (opt "_"))))
       eol))
+
 (defvar rmsbolt--hidden-func-zig
   (rx bol (or (and "_" (0+ any))
               (and (opt "de") "register_tm_clones")
@@ -810,8 +819,7 @@ https://github.com/derickr/vld"
   (rmsbolt--path-to-swift-tool "swiftc"))
 
 (defun rmsbolt--path-to-swift-tool (swift-tool)
-  "Return the path to SWIFT-TOOL, depending on the active
-toolchain."
+  "Return the path to SWIFT-TOOL, depending on the active toolchain."
   (let* ((swift-tool-binary swift-tool)
          (swift-tool-toolchain-path (shell-command-to-string (format "echo -n `xcrun --find %s`" swift-tool-binary))))
     ;; If we have the Swift tool in PATH, just return it (this is the
@@ -821,8 +829,7 @@ toolchain."
      ((executable-find swift-tool-binary)
       swift-tool-binary)
      ((executable-find swift-tool-toolchain-path)
-      swift-tool-toolchain-path)
-     (t nil))))
+      swift-tool-toolchain-path))))
 
 (defun rmsbolt--parse-compile-commands (comp-cmds file)
   "Parse COMP-CMDS and extract a compilation dir and command for FILE."
@@ -840,6 +847,7 @@ toolchain."
              (dir (alist-get 'directory entry))
              (cmd (alist-get 'command entry)))
     (list dir cmd)))
+
 (defun rmsbolt--handle-c-compile-cmd (src-buffer)
   "Handle compile_commands.json for c/c++ for a given SRC-BUFFER.
 return t if successful."
@@ -866,126 +874,125 @@ return t if successful."
                     (rmsbolt-split-rm-single "-flto" #'string-prefix-p)
                     (rmsbolt-split-rm-double "-o")))
       t)))
+
 ;;;; Language Definitions
-(defvar rmsbolt-languages)
-(setq
- rmsbolt-languages
- `((c-mode
-    . ,(make-rmsbolt-lang :compile-cmd "gcc"
-                          :supports-asm t
-                          :supports-disass t
-                          :demangler "c++filt"
-                          :compile-cmd-function #'rmsbolt--c-compile-cmd
-                          :disass-hidden-funcs rmsbolt--hidden-func-c))
-   (c++-mode
-    . ,(make-rmsbolt-lang :compile-cmd "g++"
-                          :supports-asm t
-                          :supports-disass t
-                          :demangler "c++filt"
-                          :compile-cmd-function #'rmsbolt--c-compile-cmd
-                          :disass-hidden-funcs rmsbolt--hidden-func-c))
-   (d-mode
-    . ,(make-rmsbolt-lang :compile-cmd "ldc2"
-                          :supports-asm t
-                          :supports-disass nil
-                          :demangler "ddemangle"
-                          :compile-cmd-function #'rmsbolt--d-compile-cmd))
-   ;; In order to parse ocaml files, you need the emacs ocaml mode, tuareg
-   (tuareg-mode
-    . ,(make-rmsbolt-lang :compile-cmd "ocamlopt"
-                          :supports-asm t
-                          :supports-disass t
-                          :compile-cmd-function #'rmsbolt--ocaml-compile-cmd
-                          :disass-hidden-funcs rmsbolt--hidden-func-ocaml))
-   (lisp-mode
-    . ,(make-rmsbolt-lang :compile-cmd "sbcl"
-                          :supports-asm t
-                          :supports-disass nil
-                          :objdumper 'cat
-                          :compile-cmd-function #'rmsbolt--lisp-compile-cmd))
-   (rust-mode
-    . ,(make-rmsbolt-lang :compile-cmd "rustc"
-                          :supports-asm t
-                          :supports-disass nil
-                          :objdumper 'objdump
-                          :demangler "rustfilt"
-                          :compile-cmd-function #'rmsbolt--rust-compile-cmd))
-   ;; Copy of above
-   (rustic-mode
-    . ,(make-rmsbolt-lang :compile-cmd "rustc"
-                          :supports-asm t
-                          :supports-disass nil
-                          :objdumper 'objdump
-                          :demangler "rustfilt"
-                          :compile-cmd-function #'rmsbolt--rust-compile-cmd))
-   (ponylang-mode
-    . ,(make-rmsbolt-lang :compile-cmd "ponyc"
-                          :supports-asm t
-                          :supports-disass t
-                          :objdumper 'objdump
-                          :compile-cmd-function #'rmsbolt--pony-compile-cmd))
-   (php-mode
-    . ,(make-rmsbolt-lang :compile-cmd #'rmsbolt--php-default-compile-cmd
-                          :supports-asm t
-                          :supports-disass nil
-                          :compile-cmd-function #'rmsbolt--php-compile-cmd
-                          :process-asm-custom-fn #'rmsbolt--process-php-bytecode))
-   ;; ONLY SUPPORTS PYTHON 3
-   (python-mode
-    . ,(make-rmsbolt-lang :compile-cmd "python3"
-                          :supports-asm t
-                          :supports-disass nil
-                          :compile-cmd-function #'rmsbolt--py-compile-cmd
-                          :process-asm-custom-fn #'rmsbolt--process-python-bytecode))
-   (haskell-mode
-    . ,(make-rmsbolt-lang :compile-cmd "ghc"
-                          :supports-asm t
-                          :supports-disass nil
-                          :demangler "haskell-demangler"
-                          :compile-cmd-function #'rmsbolt--hs-compile-cmd))
-   (java-mode
-    . ,(make-rmsbolt-lang :compile-cmd "javac"
-                          :supports-asm t
-                          :supports-disass nil
-                          :objdumper 'cat
-                          :compile-cmd-function #'rmsbolt--java-compile-cmd
-                          :process-asm-custom-fn #'rmsbolt--process-java-bytecode))
-   (emacs-lisp-mode
-    . ,(make-rmsbolt-lang :supports-asm t
-                          :supports-disass nil
-                          ;; Nop
-                          :process-asm-custom-fn (lambda (_src-buffer lines)
-                                                   lines)
-                          :elisp-compile-override #'rmsbolt--elisp-compile-override))
-   (nim-mode
-    . ,(make-rmsbolt-lang :compile-cmd "nim c"
-                          :supports-disass t
-                          :objdumper 'objdump
-                          :demangler "c++filt"
-                          :compile-cmd-function #'rmsbolt--nim-compile-cmd
-                          :disass-hidden-funcs rmsbolt--hidden-func-c))
-   (zig-mode
-    . ,(make-rmsbolt-lang :compile-cmd "zig build-obj -O ReleaseFast"
-                          :supports-asm t
-                          :supports-disass t
-                          :objdumper 'objdump
-                          :compile-cmd-function #'rmsbolt--zig-compile-cmd
-                          :disass-hidden-funcs rmsbolt--hidden-func-zig))
-   (go-mode
-    . ,(make-rmsbolt-lang :compile-cmd "go"
-			                    :supports-asm nil
-			                    :supports-disass t
-			                    :objdumper 'go-objdump
-			                    :compile-cmd-function #'rmsbolt--go-compile-cmd
-			                    :process-asm-custom-fn #'rmsbolt--process-go-asm-lines))
-   (swift-mode
-    . ,(make-rmsbolt-lang :compile-cmd (rmsbolt--path-to-swift-compiler)
-                          :supports-asm t
-                          :supports-disass nil
-                          :objdumper 'objdump
-                          :demangler (rmsbolt--path-to-swift-demangler)
-                          :compile-cmd-function #'rmsbolt--swift-compile-cmd))
-   ))
+(defvar rmsbolt-languages
+  `((c-mode
+     . ,(make-rmsbolt-lang :compile-cmd "gcc"
+                           :supports-asm t
+                           :supports-disass t
+                           :demangler "c++filt"
+                           :compile-cmd-function #'rmsbolt--c-compile-cmd
+                           :disass-hidden-funcs rmsbolt--hidden-func-c))
+    (c++-mode
+     . ,(make-rmsbolt-lang :compile-cmd "g++"
+                           :supports-asm t
+                           :supports-disass t
+                           :demangler "c++filt"
+                           :compile-cmd-function #'rmsbolt--c-compile-cmd
+                           :disass-hidden-funcs rmsbolt--hidden-func-c))
+    (d-mode
+     . ,(make-rmsbolt-lang :compile-cmd "ldc2"
+                           :supports-asm t
+                           :supports-disass nil
+                           :demangler "ddemangle"
+                           :compile-cmd-function #'rmsbolt--d-compile-cmd))
+    ;; In order to parse ocaml files, you need the emacs ocaml mode, tuareg
+    (tuareg-mode
+     . ,(make-rmsbolt-lang :compile-cmd "ocamlopt"
+                           :supports-asm t
+                           :supports-disass t
+                           :compile-cmd-function #'rmsbolt--ocaml-compile-cmd
+                           :disass-hidden-funcs rmsbolt--hidden-func-ocaml))
+    (lisp-mode
+     . ,(make-rmsbolt-lang :compile-cmd "sbcl"
+                           :supports-asm t
+                           :supports-disass nil
+                           :objdumper 'cat
+                           :compile-cmd-function #'rmsbolt--lisp-compile-cmd))
+    (rust-mode
+     . ,(make-rmsbolt-lang :compile-cmd "rustc"
+                           :supports-asm t
+                           :supports-disass nil
+                           :objdumper 'objdump
+                           :demangler "rustfilt"
+                           :compile-cmd-function #'rmsbolt--rust-compile-cmd))
+    ;; Copy of above
+    (rustic-mode
+     . ,(make-rmsbolt-lang :compile-cmd "rustc"
+                           :supports-asm t
+                           :supports-disass nil
+                           :objdumper 'objdump
+                           :demangler "rustfilt"
+                           :compile-cmd-function #'rmsbolt--rust-compile-cmd))
+    (ponylang-mode
+     . ,(make-rmsbolt-lang :compile-cmd "ponyc"
+                           :supports-asm t
+                           :supports-disass t
+                           :objdumper 'objdump
+                           :compile-cmd-function #'rmsbolt--pony-compile-cmd))
+    (php-mode
+     . ,(make-rmsbolt-lang :compile-cmd #'rmsbolt--php-default-compile-cmd
+                           :supports-asm t
+                           :supports-disass nil
+                           :compile-cmd-function #'rmsbolt--php-compile-cmd
+                           :process-asm-custom-fn #'rmsbolt--process-php-bytecode))
+    ;; ONLY SUPPORTS PYTHON 3
+    (python-mode
+     . ,(make-rmsbolt-lang :compile-cmd "python3"
+                           :supports-asm t
+                           :supports-disass nil
+                           :compile-cmd-function #'rmsbolt--py-compile-cmd
+                           :process-asm-custom-fn #'rmsbolt--process-python-bytecode))
+    (haskell-mode
+     . ,(make-rmsbolt-lang :compile-cmd "ghc"
+                           :supports-asm t
+                           :supports-disass nil
+                           :demangler "haskell-demangler"
+                           :compile-cmd-function #'rmsbolt--hs-compile-cmd))
+    (java-mode
+     . ,(make-rmsbolt-lang :compile-cmd "javac"
+                           :supports-asm t
+                           :supports-disass nil
+                           :objdumper 'cat
+                           :compile-cmd-function #'rmsbolt--java-compile-cmd
+                           :process-asm-custom-fn #'rmsbolt--process-java-bytecode))
+    (emacs-lisp-mode
+     . ,(make-rmsbolt-lang :supports-asm t
+                           :supports-disass nil
+                           ;; Nop
+                           :process-asm-custom-fn (lambda (_src-buffer lines)
+                                                    lines)
+                           :elisp-compile-override #'rmsbolt--elisp-compile-override))
+    (nim-mode
+     . ,(make-rmsbolt-lang :compile-cmd "nim c"
+                           :supports-disass t
+                           :objdumper 'objdump
+                           :demangler "c++filt"
+                           :compile-cmd-function #'rmsbolt--nim-compile-cmd
+                           :disass-hidden-funcs rmsbolt--hidden-func-c))
+    (zig-mode
+     . ,(make-rmsbolt-lang :compile-cmd "zig build-obj -O ReleaseFast"
+                           :supports-asm t
+                           :supports-disass t
+                           :objdumper 'objdump
+                           :compile-cmd-function #'rmsbolt--zig-compile-cmd
+                           :disass-hidden-funcs rmsbolt--hidden-func-zig))
+    (go-mode
+     . ,(make-rmsbolt-lang :compile-cmd "go"
+			   :supports-asm nil
+			   :supports-disass t
+			   :objdumper 'go-objdump
+			   :compile-cmd-function #'rmsbolt--go-compile-cmd
+			   :process-asm-custom-fn #'rmsbolt--process-go-asm-lines))
+    (swift-mode
+     . ,(make-rmsbolt-lang :compile-cmd (rmsbolt--path-to-swift-compiler)
+                           :supports-asm t
+                           :supports-disass nil
+                           :objdumper 'objdump
+                           :demangler (rmsbolt--path-to-swift-demangler)
+                           :compile-cmd-function #'rmsbolt--swift-compile-cmd))
+    ))
 
 (defvar rmsbolt-c-dwarf-language
   (make-rmsbolt-lang :compile-cmd "gcc"
@@ -1014,7 +1021,6 @@ This should be an object of type `rmsbolt-lang', normally set by the major mode"
             display-buffer-overriding-action)))
      ,@body))
 
-
 ;;;; Functions
 ;; Functions to parse and lint assembly were lifted almost directly from the compiler-explorer
 
@@ -1066,9 +1072,7 @@ Lifted from https://emacs.stackexchange.com/questions/35936/disassembly-of-a-byt
   "Check if LINE has opcodes."
   (save-match-data
     (let* ((match (string-match rmsbolt-label-def line))
-           (line (if match
-                     (substring line (match-end 0))
-                   line))
+           (line (substring line (and match (match-end 0))))
            (line (cl-first (split-string line (rx (1+ (any ";#")))))))
       (if (string-match-p rmsbolt-assignment-def line)
           nil
@@ -1434,7 +1438,7 @@ Argument ASM-LINES input lines."
     (setq result (nconc die result))
     (nreverse result)))
 
-;;;;; Handlers
+;;;;; HANDLERS
 (cl-defun rmsbolt--handle-finish-compile (buffer str &key override-buffer stopped)
   "Finish hook for compilations.
 Argument BUFFER compilation buffer.
@@ -1476,23 +1480,22 @@ Argument STOPPED The compilation was stopped to start another compilation."
                    (let ((property
                           (get-text-property
                            0 'rmsbolt-src-line line)))
-                     (progn
-                       (cl-tagbody
-                        run-conditional
-                        (cond
-                         ((and in-match (eq in-match property))
-                          ;; We are continuing an existing match
-                          nil)
-                         (in-match
-                          ;; We are in a match that has just expired
-                          (push (cons start-match (1- linum))
-                                (gethash in-match ht))
-                          (setq in-match nil
-                                start-match nil)
-                          (go run-conditional))
-                         (property
-                          (setq in-match property
-                                start-match linum))))))
+                     (cl-tagbody
+                      run-conditional
+                      (cond
+                       ((and in-match (eq in-match property))
+                        ;; We are continuing an existing match
+                        nil)
+                       (in-match
+                        ;; We are in a match that has just expired
+                        (push (cons start-match (1- linum))
+                              (gethash in-match ht))
+                        (setq in-match nil
+                              start-match nil)
+                        (go run-conditional))
+                       (property
+                        (setq in-match property
+                              start-match linum)))))
                    (cl-incf linum))
 
                  (with-current-buffer src-buffer
@@ -1544,7 +1547,7 @@ Argument STOPPED The compilation was stopped to start another compilation."
                  ;; https://github.com/renzmann/treesit-auto/blob/d32617b5edb660b8a046053af3b92cf14f9b978e/treesit-auto.el#L89
                  (assoc (thread-last
                           (symbol-name major-mode)
-                          (replace-regexp-in-string "ts-mode$" "mode")
+                          (replace-regexp-in-string "-ts-mode\\'" "-mode")
                           (intern))
                         rmsbolt-languages)))))
 
@@ -1608,6 +1611,7 @@ and return it."
 (defun rmsbolt-compile ()
   "Compile the current rmsbolt buffer."
   (interactive)
+  ;; perhaps use `save-some-buffers'?
   (when (and (buffer-modified-p)
              (yes-or-no-p (format "Save buffer %s? " (buffer-name))))
     (save-buffer))
@@ -1615,7 +1619,7 @@ and return it."
   ;; Current buffer = src-buffer at this point
   (setq rmsbolt-src-buffer (current-buffer))
   (cond
-   ((eq major-mode 'asm-mode)
+   ((derived-mode-p 'asm-mode)
     ;; We cannot compile asm-mode files
     (message "Cannot compile assembly files. Are you sure you are not in the output buffer?"))
    ((rmsbolt-l-elisp-compile-override (rmsbolt--get-lang))
@@ -1641,8 +1645,7 @@ and return it."
                                   rmsbolt--temp-dir)))
       (run-hooks 'rmsbolt-after-parse-hook)
       (when (buffer-local-value 'rmsbolt-disassemble src-buffer)
-        (pcase
-            (rmsbolt-l-objdumper lang)
+        (pcase-exhaustive (rmsbolt-l-objdumper lang)
           ('objdump
            (setq cmd
                  (mapconcat #'identity
@@ -1670,9 +1673,7 @@ and return it."
                                   "&&" "mv"
                                   (rmsbolt-output-filename src-buffer)
                                   (rmsbolt-output-filename src-buffer t))
-                            " ")))
-          (_
-           (error "Objdumper not recognized"))))
+                            " ")))))
       ;; Convert to demangle if we need to
       (setq cmd (rmsbolt--demangle-command cmd lang src-buffer))
       (with-current-buffer ; With compilation buffer
@@ -1720,14 +1721,14 @@ and return it."
                            rmsbolt--temp-dir
                            (file-directory-p rmsbolt--temp-dir))
                   (delete-directory rmsbolt--temp-dir t))
-                (setq rmsbolt--temp-dir nil)))))
+                (setq rmsbolt--temp-dir nil))))) ;why is this necessary while killing emacs?
 
 ;;;;; Starter Definitions
 
 ;; IIUC, this "starter" business is not a necessary part of RMSBolt, but is
 ;; a way to provide sample files with which users can try out RMSBolt.
 
-(defvar rmsbolt-starter-files
+(defvar rmsbolt-starter-files		;should this be part of a secondary file that isn't loaded by default?
   '(("c" . "rmsbolt.c")
     ("c++" . "rmsbolt.cpp")
     ("ocaml" . "rmsbolt.ml")
@@ -1778,24 +1779,23 @@ and return it."
   (when line
     (let ((cur (line-number-at-pos)))
       (forward-line (- line cur)))))
+
 (defun rmsbolt--setup-overlay (start end buf)
   "Setup overlay with START and END in BUF."
   (let ((o (make-overlay start end buf)))
     (overlay-put o 'face 'rmsbolt-current-line-face)
     o))
+
 (cl-defun rmsbolt--point-visible (point)
   "Check if the current point is visible in a window in the current buffer."
-  (when (cl-find-if (lambda (w)
-                      (and (>= point (window-start w))
-                           (<= point (window-end w))))
-                    (get-buffer-window-list))
-    t))
+  (cl-find-if (lambda (w)
+		(<= (window-start w) point (window-end w)))
+              (get-buffer-window-list)))
 
 (cl-defun rmsbolt-update-overlays (&key (force nil))
   "Update overlays to highlight the currently selected source and asm lines.
-  If FORCE, always scroll overlay, even when one is visible.
-  FORCE also scrolls to the first line, instead of the first line
-  of the last block."
+If FORCE, always scroll overlay, even when one is visible.  FORCE also
+scrolls to the first line, instead of the first line of the last block."
   (when rmsbolt-mode
     (if-let ((should-run rmsbolt-use-overlays)
              (output-buffer (get-buffer rmsbolt-output-buffer))
@@ -1841,8 +1841,7 @@ and return it."
                                          (not scroll-src-buffer-p))
                                 (setq line-visible (or (rmsbolt--point-visible start-pt)
                                                        (rmsbolt--point-visible end-pt)
-                                                       (and (> saved-pt start-pt)
-                                                            (< saved-pt end-pt)))))
+                                                       (< start-pt saved-pt end-pt))))
                               (push (rmsbolt--setup-overlay start-pt end-pt output-buffer)
                                     rmsbolt-overlays)))))
             (when (or (not line-visible) force)
@@ -1931,9 +1930,7 @@ and return it."
   "Toggle rmsbolt-mode.
 
 This mode is enabled in both src and assembly output buffers."
-  :global nil
   :lighter rmsbolt-mode-lighter
-  :keymap rmsbolt-mode-map
   ;; Init
   (cond
    (rmsbolt-mode

[-- Attachment #3: Type: text/plain, Size: 38 bytes --]



-- 
	Philip Kaludercic on peregrine

  reply	other threads:[~2024-02-27  7:47 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-25 21:07 NonGNU ELPA: Conditions for accepting a potential new package 'rmsbolt' ? Jeremy Bryant
2024-02-26  7:44 ` Philip Kaludercic
2024-02-26 22:40   ` Jeremy Bryant
2024-02-27  7:47     ` Philip Kaludercic [this message]
2024-02-27 16:13       ` Jay Kamat
2024-02-27 17:10         ` Philip Kaludercic
2024-02-27 17:14           ` Jay Kamat
2024-02-27 17:21             ` Philip Kaludercic
2024-02-27 17:21         ` Stefan Monnier
2024-02-27 17:27           ` Philip Kaludercic
2024-02-27 17:49             ` Stefan Monnier
2024-02-27 18:42               ` Philip Kaludercic
2024-02-27 19:43                 ` Stefan Monnier
2024-02-27 18:46               ` Eli Zaretskii
2024-03-01 17:37           ` Jay Kamat

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87y1b6tkk1.fsf@posteo.net \
    --to=philipk@posteo.net \
    --cc=emacs-devel@gnu.org \
    --cc=jaygkamat@gmail.com \
    --cc=jb@jeremybryant.net \
    --cc=monnier@iro.umontreal.ca \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).