Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

emacs caml-mode indents shebang line in toplevel scripts #5727

vicuna opened this issue Aug 14, 2012 · 1 comment

emacs caml-mode indents shebang line in toplevel scripts #5727

vicuna opened this issue Aug 14, 2012 · 1 comment


Copy link

@vicuna vicuna commented Aug 14, 2012

Original bug ID: 5727
Reporter: Drakken
Assigned to: @damiendoligez
Status: closed (set by @xavierleroy on 2015-12-11T18:08:11Z)
Resolution: fixed
Priority: low
Severity: tweak
Version: 3.12.1
Target version: 4.00.1+dev
Category: ~DO NOT USE (was: OCaml general)

Bug description

When editing a toplevel script in emacs caml-mode,
auto-tabbing indents the shebang line and the directive
immediately following it if one is present.

Steps to reproduce

Create and auto-indent a toplevel script with a shebang line,
using emacs and caml-mode.

Additional information

The following code is a patch for caml.el.
It seems to work, but I'm not an elisp expert,
so it may be slow or otherwise suboptimal :(

;small addition to caml-compute-basic-indent
(defun caml-compute-basic-indent (prio)
(if (= 1 (line-beginning-position))

;new function
(defun caml-in-shebang-line ()
(and (= 1 (point)) (looking-at "#!"))))

;one-line insertion into the COND form in caml-in-expr-p
(defun caml-in-expr-p ()
(let (...)
(caml-find-kwop ...)
((caml-in-shebang-line) (setq in-expr nil)) ;; maybe reset pos?
; special case for ;;

Copy link

@vicuna vicuna commented Sep 27, 2012

Comment author: @damiendoligez

I have applied a simplified version of your patch. There is one remaining problem (with or without the simplification): if the shebang line is already indented to any non-zero level, then emacs will indent it to two spaces.

Edit: I had forgotten to commit the change. It is now done in 4.00.1+dev (r 12973) and trunk (r 12974).

@vicuna vicuna closed this as completed Dec 11, 2015
@vicuna vicuna added this to the 4.00.1 milestone Mar 14, 2019
@vicuna vicuna added the bug label Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

2 participants