hylang / hy-mode

Hy mode for Emacs
GNU General Public License v3.0
189 stars 48 forks source link

newline after comment tends to indent the comment #23

Closed theanalyst closed 10 years ago

theanalyst commented 10 years ago

I'm not sure whether this behaviour is because of something in my emacs config. But in general doing a

; foo <pressing RET>

will indent the comment as something like

               ;foo

The behaviour is as expected for inline comments however; this is only a problem when comment character is the start of the line

berkerpeksag commented 10 years ago

I can't reproduce the problem on Emacs 24.3.1 with hy-mode (commit 22125f0cfcd531139a3cafe43f980953c8cdaab9).

theanalyst commented 10 years ago

Actually it is not tabs as in hard tabs..it is just indented with whitespace. ie simply try typing something like ; a on a new line and hitting RET, will indent ; a to the right

algernon commented 10 years ago

I've seen this in other modes too (clojure-mode, hy-mode, elisp-mode, etc). Using ;; is a reasonable workaround. But if someone figures out what the underlying setting is to make a single ; not behave so strangely, let me know.

theanalyst commented 10 years ago

Hm, actually you're right, looks like a common (maybe expected) behaviour in elisp and clojure modes as well. I guess line comments should start with ;;. In the clojure style guide it is mentioned to use 2 semicolons; and in elisp as well all files seem to have 2 comments in fragments of code. Maybe this is the convention to be followed? (In that case I'll update the style guide as well)

On Thu, Jan 23, 2014 at 4:01 PM, Gergely Nagy notifications@github.comwrote:

I've seen this in other modes too (clojure-mode, hy-mode, elisp-mode, etc). Using ;; is a reasonable workaround. But if someone figures out what the underlying setting is to make a single ; not behave so strangely, let me know.

— Reply to this email directly or view it on GitHubhttps://github.com/hylang/hy-mode/issues/23#issuecomment-33112547 .

theanalyst commented 10 years ago

Hm looks like the indentation is according the variable comment-column. This defaults to 40 or something and hence the indentation like that. A (setq-local comment-column 0) should do the trick. But I don't think this should be set in hy-mode if the general lisp convention is to use ;; for comments in code fragments.

Maybe people more experienced in lisp than me maybe able to comment on this ;)

algernon commented 10 years ago

From what I can tell, the reason for ; and big indentation is that if you have short functions, much indented comments go to the other side of the screen. At least back in 80x25 days, they did. So you got a nice "code on one side, prose on the other" setup. Which makes sense, is a good setup, but... not with zillion*billion resolutions we have nowadays.

theanalyst commented 10 years ago

So what do you think we should do about this? I guess we leave it as it is..any users wanting such a single comment may add a hook (setq-local comment-column 0) and set it themselves?

algernon commented 10 years ago

That sounds reasonable to me.