From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.devel Subject: Re: NonGNU ELPA: Conditions for accepting a potential new package 'rmsbolt' ? Date: Tue, 27 Feb 2024 07:47:58 +0000 Message-ID: <87y1b6tkk1.fsf@posteo.net> References: <87jzmsmecw.fsf@jeremybryant.net> <877cir8yap.fsf@posteo.net> <877ciqn8wg.fsf@jeremybryant.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5591"; mail-complaints-to="usenet@ciao.gmane.io" Cc: "emacs-devel@gnu.org" , Jay Kamat , To: Jeremy Bryant Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Feb 27 08:49:19 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1resDG-0001Fz-KQ for ged-emacs-devel@m.gmane-mx.org; Tue, 27 Feb 2024 08:49:18 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1resCD-0004q5-7y; Tue, 27 Feb 2024 02:48:13 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1resC7-0004oh-Rw for emacs-devel@gnu.org; Tue, 27 Feb 2024 02:48:08 -0500 Original-Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1resC3-0003iV-73 for emacs-devel@gnu.org; Tue, 27 Feb 2024 02:48:07 -0500 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id A131D240028 for ; Tue, 27 Feb 2024 08:48:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1709020080; bh=4cy7BOX9jj+QFoCauSOKhsE6XqEiNkG6zNulQYlK3t4=; h=From:To:Cc:Subject:OpenPGP:Date:Message-ID:MIME-Version: Content-Type:From; b=VqojPjDBFEIOKgIWOTAPXe+qIJnkhntdxjuoZGh6r8ja/daCakUyGIk7MFn9fAkIQ X5477JJDQAd+Inj+qOlpGJPbt4SA2gfbVgKq8LDVYDNKN+7THhH4Q6MOjETyoS9APH JIv+ae/EpaOfOJzaCqpAy84npIGxi66ZlQV3odI52AiGPDamrqyg4XmWO7mtE9AcQt GRhsbPAYcdPntoHT5bZiEQjT1+4TXCM+dZZxkWXhLeYSF15twfiu9k1O+ntbTa8zhE kBZcERWhfPm46GVADcXZdJdYP/05YlJeRLiRWiXFXzn1U8WfYIT/zcuNEVrUQym19p 0wBj2/DjepkgQ== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4TkV2l37j2z6v0l; Tue, 27 Feb 2024 08:47:59 +0100 (CET) In-Reply-To: <877ciqn8wg.fsf@jeremybryant.net> (Jeremy Bryant's message of "Mon, 26 Feb 2024 22:40:17 +0000") OpenPGP: id=7126E1DE2F0CE35C770BED01F2C3CC513DB89F66; url="https://keys.openpgp.org/vks/v1/by-fingerprint/7126E1DE2F0CE35C770BED01F2C3CC513DB89F66"; preference=signencrypt Received-SPF: pass client-ip=185.67.36.65; envelope-from=philipk@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:316584 Archived-At: --=-=-= Content-Type: text/plain Jeremy Bryant writes: > Philip Kaludercic writes: > >> Jeremy Bryant 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: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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; -*- =20 -;; Copyright (C) 2018-2021 Jay Kamat +;; Copyright (C) 2018-2023 Jay Kamat + ;; Author: Jay Kamat ;; 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 y= ou + +;;;; 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) =20 (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 visib= le." - :type 'boolean - :group 'rmsbolt) -(defcustom rmsbolt-mode-lighter " RMS=F0=9F=97=B2" + :type 'boolean) + +(defcustom rmsbolt-mode-lighter " RMS=F0=9F=97=B2" ;could the unicode char= achter 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))) =20 ;;;;; 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 =20 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. =20 @@ -155,45 +158,44 @@ If you are not on x86, you most likely want to set th= is 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. =20 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. =20 Note that basic flags to ensure basic usage are always modified." :type 'boolean - :safe 'booleanp - :group 'rmsbolt) + :safe 'booleanp) =20 (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) =20 ;;;; Faces @@ -241,16 +242,15 @@ Used to work around inconsistencies in alternative sh= ells.") Please DO NOT modify this blindly, as this directory will get deleted on Emacs exit.") =20 -(defvar rmsbolt-dir nil +(defvar rmsbolt-dir (and load-file-name (file-name-directory load-file-nam= e)) "The directory which rmsbolt is installed to.") -(when load-file-name - (setq rmsbolt-dir (file-name-directory load-file-name))) =20 (defvar-local rmsbolt-src-buffer nil) =20 (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 enou= gh. (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 mos= t logic and is generally not useful.")) =20 ;;;; 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 eq= ual 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)) =20 -(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. =20 @@ -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=3D--x86-asm-syntax= =3D" 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. =20 @@ -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")) =20 (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)))) =20 (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-c= md - :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-cm= d)) - (rust-mode - . ,(make-rmsbolt-lang :compile-cmd "rustc" - :supports-asm t - :supports-disass nil - :objdumper 'objdump - :demangler "rustfilt" - :compile-cmd-function #'rmsbolt--rust-compile-cm= d)) - ;; 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-cm= d)) - (ponylang-mode - . ,(make-rmsbolt-lang :compile-cmd "ponyc" - :supports-asm t - :supports-disass t - :objdumper 'objdump - :compile-cmd-function #'rmsbolt--pony-compile-cm= d)) - (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-by= tecode)) - ;; 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-b= ytecode)) - (emacs-lisp-mode - . ,(make-rmsbolt-lang :supports-asm t - :supports-disass nil - ;; Nop - :process-asm-custom-fn (lambda (_src-buffer line= s) - 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-li= nes)) - (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-c= md)) - )) +(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-c= md)) + (rust-mode + . ,(make-rmsbolt-lang :compile-cmd "rustc" + :supports-asm t + :supports-disass nil + :objdumper 'objdump + :demangler "rustfilt" + :compile-cmd-function #'rmsbolt--rust-compile-c= md)) + ;; 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-c= md)) + (ponylang-mode + . ,(make-rmsbolt-lang :compile-cmd "ponyc" + :supports-asm t + :supports-disass t + :objdumper 'objdump + :compile-cmd-function #'rmsbolt--pony-compile-c= md)) + (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-b= ytecode)) + ;; 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-pytho= n-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-c= md + :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 lin= es) + lines) + :elisp-compile-override #'rmsbolt--elisp-compil= e-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)) + )) =20 (defvar rmsbolt-c-dwarf-language (make-rmsbolt-lang :compile-cmd "gcc" @@ -1014,7 +1021,6 @@ This should be an object of type `rmsbolt-lang', norm= ally set by the major mode" display-buffer-overriding-action))) ,@body)) =20 - ;;;; Functions ;; Functions to parse and lint assembly were lifted almost directly from t= he compiler-explorer =20 @@ -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))) =20 -;;;;; 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 sta= rt 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)) =20 (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/d32617b5= edb660b8a046053af3b92cf14f9b978e/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))))) =20 @@ -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 =3D 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 t= he 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 wh= ile killing emacs? =20 ;;;;; Starter Definitions =20 ;; 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. =20 -(defvar rmsbolt-starter-files +(defvar rmsbolt-starter-files ;should this be part of a secondary file th= at 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 (>=3D point (window-start w)) - (<=3D point (window-end w)))) - (get-buffer-window-list)) - t)) + (cl-find-if (lambda (w) + (<=3D (window-start w) point (window-end w))) + (get-buffer-window-list))) =20 (cl-defun rmsbolt-update-overlays (&key (force nil)) "Update overlays to highlight the currently selected source and asm line= s. - 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-vis= ible start-pt) (rmsbolt--point-vis= ible end-pt) - (and (> saved-pt st= art-pt) - (< saved-pt en= d-pt))))) + (< start-pt saved-p= t end-pt)))) (push (rmsbolt--setup-overlay start-pt end-p= t output-buffer) rmsbolt-overlays))))) (when (or (not line-visible) force) @@ -1931,9 +1930,7 @@ and return it." "Toggle rmsbolt-mode. =20 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 --=-=-= Content-Type: text/plain -- Philip Kaludercic on peregrine --=-=-=--