Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1058353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:00:53+00:00 2026-05-16T18:00:53+00:00

Im making a DSL in lisp (basically what i think is a nicer syntax),

  • 0

Im making a DSL in lisp (basically what i think is a nicer syntax), its the same thing as lisp except with different ‘primitives’, no instead of not, ‘as’ instead of let.Thus i need to change both indentation and color only in files which end in .goby (it should not effect ones which end in .lisp) So i would like to create files with extension of .goby, and have my new, minor/major mode enabled (but with everything else besides syntax inherited from lisp).

However, whatever i do it also effects .lisp files! Anyone?

For example, I tried to make a local variable for unique lisp indentation which would indent
‘hi’ by 10 spaces. but it effected all .lisp files also

;;in goby.el
(define-derived-mode
  goby-mode lisp-mode "Goby"
  "Major mode"
  (let ((func #'lisp-indent-function))
    (set (make-local-variable 'lisp-indent-function) func)
    (put 'hi 'lisp-indent-function 10)))


(provide 'goby)

;;in .emacs
(setq auto-mode-alist
      (append auto-mode-alist
          '(("\\.gy\\'" . goby-mode))))
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T18:00:54+00:00Added an answer on May 16, 2026 at 6:00 pm

    There’s probably a cleaner way, but a way that works is to rewrite 'lisp-indent-function to be 'goby-indent-function and use your own table of offsets like so:

    (define-derived-mode
      goby-mode lisp-mode "Goby"
      "Major mode"
      (set (make-local-variable 'lisp-indent-function) 'goby-indent-function))
    
    ;; goby specific offsets here
    (put 'hi 'goby-indent-function 10)
    (put 'if 'goby-indent-function 4)
    
    (defun goby-indent-function (indent-point state)
      "Same as 'lisp-indent-function but uses 'goby-indent-function symbol
    
    This function is the normal value of the variable `goby-indent-function'.
    It is used when indenting a line within a function call, to see if the
    called function says anything special about how to indent the line.
    
    INDENT-POINT is the position where the user typed TAB, or equivalent.
    Point is located at the point to indent under (for default indentation);
    STATE is the `parse-partial-sexp' state for that position.
    
    If the current line is in a call to a Lisp function
    which has a non-nil property `goby-indent-function',
    that specifies how to do the indentation.  The property value can be
    * `defun', meaning indent `defun'-style;
    * an integer N, meaning indent the first N arguments specially
      like ordinary function arguments and then indent any further
      arguments like a body;
    * a function to call just as this function was called.
      If that function returns nil, that means it doesn't specify
      the indentation.
    
    This function also returns nil meaning don't specify the indentation."
      (let ((normal-indent (current-column)))
        (goto-char (1+ (elt state 1)))
        (parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t)
        (if (and (elt state 2)
                 (not (looking-at "\\sw\\|\\s_")))
            ;; car of form doesn't seem to be a symbol
            (progn
              (if (not (> (save-excursion (forward-line 1) (point))
                          calculate-lisp-indent-last-sexp))
                  (progn (goto-char calculate-lisp-indent-last-sexp)
                         (beginning-of-line)
                         (parse-partial-sexp (point)
                                             calculate-lisp-indent-last-sexp 0 t)))
              ;; Indent under the list or under the first sexp on the same
              ;; line as calculate-lisp-indent-last-sexp.  Note that first
              ;; thing on that line has to be complete sexp since we are
              ;; inside the innermost containing sexp.
              (backward-prefix-chars)
              (current-column))
          (let ((function (buffer-substring (point)
                                            (progn (forward-sexp 1) (point))))
                method)
            (setq method (or (get (intern-soft function) 'goby-indent-function)
                             (get (intern-soft function) 'lisp-indent-hook)))
            (cond ((or (eq method 'defun)
                       (and (null method)
                            (> (length function) 3)
                            (string-match "\\`def" function)))
                   (lisp-indent-defform state indent-point))
                  ((integerp method)
                   (lisp-indent-specform method state
                                         indent-point normal-indent))
                  (method
                   (funcall method indent-point state)))))))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Making echo of a question around the web: Is the syntax for svn:ignore patterns
When making changes using SubmitChanges() , LINQ sometimes dies with a ChangeConflictException exception with
After making some changes in my models (eg. new field in a model and
After making a few modifications to a rails app I am tinkering on, railroad
Im making a small python script to upload files on the net. The script
I've been making a concerted effort to improve my javascript skills lately by reading
I am making a simple game in order to learn a new language. I
I'm thinking about making a networked game. I'm a little new to this, and
I have been making a little toy web application in C# along the lines
I'm making a WinForms app with a ListView set to detail so that several

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.