unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* survey: indentation declaration style
@ 2009-05-11  9:48 Thien-Thi Nguyen
  2009-05-11 12:30 ` Andreas Rottmann
  2009-05-11 17:27 ` Linas Vepstas
  0 siblings, 2 replies; 3+ messages in thread
From: Thien-Thi Nguyen @ 2009-05-11  9:48 UTC (permalink / raw)
  To: guile-user

I've tentatively adopted the following indentation declaration style.
Non-coincidentally, it resembles that used for Emacs Lisp code.
The #; represents pan-Scheme (R7RS?) wishful thinking.

  (define-macro (forse precond . corpo)
    ;;#;(declare (indent 1))
    `(or (and-let* ,precond (list ,@corpo))
         '()))

Here is Emacs Lisp, suitable for scheme-mode-hook, that recognizes this.

  (defun ttn-scheme-set-macro-indentation ()
    (save-excursion
      (goto-char (point-min))
      (while (re-search-forward
              (concat
               "^(def\\S-+\\Sw+\\(\\S-+\\)[^\n]+\n"
               ;; TODO: parameterize
               "  ;;#;(declare (indent \\(.\\)")
              nil t)
        (put (intern (match-string 1))
             'scheme-indent-function
             (string-to-number (match-string 2))))))

What do other people do?

thi




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: survey: indentation declaration style
  2009-05-11  9:48 survey: indentation declaration style Thien-Thi Nguyen
@ 2009-05-11 12:30 ` Andreas Rottmann
  2009-05-11 17:27 ` Linas Vepstas
  1 sibling, 0 replies; 3+ messages in thread
From: Andreas Rottmann @ 2009-05-11 12:30 UTC (permalink / raw)
  To: guile-user

Thien-Thi Nguyen <ttn@gnuvola.org> writes:

> I've tentatively adopted the following indentation declaration style.
> Non-coincidentally, it resembles that used for Emacs Lisp code.
> The #; represents pan-Scheme (R7RS?) wishful thinking.
>
>   (define-macro (forse precond . corpo)
>     ;;#;(declare (indent 1))
>     `(or (and-let* ,precond (list ,@corpo))
>          '()))
>
> Here is Emacs Lisp, suitable for scheme-mode-hook, that recognizes this.
>
>   (defun ttn-scheme-set-macro-indentation ()
>     (save-excursion
>       (goto-char (point-min))
>       (while (re-search-forward
>               (concat
>                "^(def\\S-+\\Sw+\\(\\S-+\\)[^\n]+\n"
>                ;; TODO: parameterize
>                "  ;;#;(declare (indent \\(.\\)")
>               nil t)
>         (put (intern (match-string 1))
>              'scheme-indent-function
>              (string-to-number (match-string 2))))))
>
> What do other people do?
>
I do this:

;; Local Variables:
;; scheme-indent-styles: (trc-testing (test-pn= 1))
;; End:

I have an extended version of the scheme indenting code that understands
that; you can specify "indent styles" like this:

(scheme-add-indent-style
 'trc-testing
 '((test-eq 1)
   (test-equal 1)
   (test-equiv 1)
   (test-compare 2)))

See [0] for the code and some "indent styles" I use.

[0] http://github.com/rotty/dotfiles/blob/aaa620b65ef4112ece0d9fd491982768b2d3c93c/.emacs.d/config/scheme.el

HTH, Rotty




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: survey: indentation declaration style
  2009-05-11  9:48 survey: indentation declaration style Thien-Thi Nguyen
  2009-05-11 12:30 ` Andreas Rottmann
@ 2009-05-11 17:27 ` Linas Vepstas
  1 sibling, 0 replies; 3+ messages in thread
From: Linas Vepstas @ 2009-05-11 17:27 UTC (permalink / raw)
  To: Thien-Thi Nguyen; +Cc: guile-user

Hi,

2009/5/11 Thien-Thi Nguyen <ttn@gnuvola.org>:
> I've tentatively adopted the following indentation declaration style.

I do something similar, except that, for clauses that
do not fit on one line, I put the closing paren on a
new line.  This allows for much  easier visual
inspection; also, I find it easier to read code that
has a fair amount of white-space in it; I have visual
problems reading dense, blackletter gothic coding
styles.  This may be because I skim much more
than I read, and blackletter impedes skimming.

Also I use tabs for indentation. (you can set tab-stops
as you wish)
So for example:

  (defun ttn-scheme-set-macro-indentation ()
    (save-excursion
      (goto-char (point-min))
      (while (re-search-forward
              (concat
               "^(def\\S-+\\Sw+\\(\\S-+\\)[^\n]+\n"
               ;; TODO: parameterize
               "  ;;#;(declare (indent \\(.\\)")
               nil t
              )
        (put (intern (match-string 1))
             'scheme-indent-function
             (string-to-number (match-string 2)
         )
        )
      )
    )
  )

--linas




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-05-11 17:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-11  9:48 survey: indentation declaration style Thien-Thi Nguyen
2009-05-11 12:30 ` Andreas Rottmann
2009-05-11 17:27 ` Linas Vepstas

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).