Coder Social home page Coder Social logo

Any good formatters? about discussion HOT 5 OPEN

timmyjose avatar timmyjose commented on June 11, 2024
Any good formatters?

from discussion.

Comments (5)

MitchBradley avatar MitchBradley commented on June 11, 2024 1

https://www.emacswiki.org/emacs/Forth-mode works pretty well

from discussion.

quozl avatar quozl commented on June 11, 2024 1

Welcome @timmyjose. I also use the Emacs Forth Mode, as I was working with @MitchBradley's source and it just made sense to stick to the same indentation. But I was and keep using it in my unpublished work. I also have some customisations in .emacs;

(add-to-list 'auto-mode-alist '("\\.fth$" . forth-mode))
(add-to-list 'auto-mode-alist '("\\.bth$" . forth-mode))
(add-hook 'forth-mode-hook (function (lambda ()
				       (setq forth-indent-level 3)
				       (setq forth-minor-indent-level 1)
				       (setq forth-hilight-level 3))))

from discussion.

MitchBradley avatar MitchBradley commented on June 11, 2024 1

My set of customizations is a bit more extensive that that of my good friend @quozl . To wit:

(defvar GFORTH_EL (concat HOME "/lisp/gforth.el"))
(cond ((file-readable-p GFORTH_EL)
  (load-library GFORTH_EL)
  (autoload 'forth-mode GFORTH_EL)
  (setq auto-mode-alist (cons '("\\.fth\\'" . forth-mode) auto-mode-alist))
  (setq auto-mode-alist (cons '("\\.bth\\'" . forth-mode) auto-mode-alist))
  (autoload 'forth-block-mode GFORTH_EL)
  (setq auto-mode-alist (cons '("\\.fb\\'" . forth-block-mode) auto-mode-alist))
  (add-hook 'forth-mode-hook (function (lambda ()
    (setq forth-indent-level 3)
    (setq forth-minor-indent-level 2)
    (setq forth-hilight-level 3)
    (setq forth-custom-words
          '(
            (("label") non-immediate (font-lock-keyword-face . 1)
             "[ \t\n]" t name (font-lock-function-name-face . 3))
            (("stand-init:") definition-starter (font-lock-function-name-face . 1)
             "[\t\n]" nil comment (font-lock-string-face . 1))
            (("end-code") definition-ender (font-lock-keyword-face . 1))
            (("loopa") compile-only (font-lock-keyword-face . 2))
            (("fload" "fl" "in:") 
             non-immediate (font-lock-keyword-face . 1) 
             "[\n\t ]" t string (font-lock-string-face . 1))
            (("\"") immediate (font-lock-string-face . 1)
             "[\"\n]" nil string (font-lock-string-face . 1))
            (("purpose:") immediate (font-lock-comment-face . 1)
             "[\n]" nil comment (font-lock-comment-face . 1))
            (("[ifndef]") immediate (font-lock-keyword-face . 2)
             "[ \t\n]" t name (font-lock-function-name-face . 3))
            (("/n" "/w" "/c") 
             non-immediate (font-lock-constant-face . 2))
            (("2value" "buffer:")
             non-immediate (font-lock-type-face . 2)
             "[ \t\n]" t name (font-lock-variable-name-face . 3))
            (("end-string-array") non-immediate (font-lock-keyword-face . 2)
             "[ \t\n]" t name (font-lock-type-face . 3))
            (("string-array") non-immediate (font-lock-keyword-face . 2))
            ("-?[0-9a-f]+\\(\\.[0-9]*e\\(-?[0-9]+\\)?\\|\\.?[0-9a-f]*\\)\\.?" 
             immediate (font-lock-constant-face . 3))
            ))
    (setq forth-custom-indent-words
      '((("[ifndef]")
	 (0 . 2) (0 . 2))
	(("label")
	 (0 . 2) (0 . 2) non-immediate)
	(("end-code")
	 (-2 . 0) (0 . -2) non-immediate)
	(("c;")
	 (-2 . 0) (0 . -2) non-immediate)))
    (define-key forth-mode-map "\C-h" 'backward-delete-char)
)))))

Some of the keywords mentioned above are specific to Open Firmware source, but you might find a few of interest.

from discussion.

timmyjose avatar timmyjose commented on June 11, 2024

@MitchBradley @quozl Thank you! I was able to locate it on melpa as well, so it should be easy to set it up.

And @quozl, that snippet will come in very handy indeed. Thanks again!

Cheers.

from discussion.

timmyjose avatar timmyjose commented on June 11, 2024

@MitchBradley Wow, that is quite something indeed. I must confess I don't understand most of it, but I can pick and incorporate some useful tidbits from there as I progress in Forth myself. Thank you for sharing the coniguration!

from discussion.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.