Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005727OCamlOCaml generalpublic2012-08-14 19:452012-09-27 18:03
ReporterDrakken 
Assigned Todoligez 
PrioritylowSeveritytweakReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version3.12.1 
Target Version4.00.1+devFixed in Version 
Summary0005727: emacs caml-mode indents shebang line in toplevel scripts
DescriptionWhen 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 ReproduceCreate and auto-indent a toplevel script with a shebang line,
using emacs and caml-mode.
Additional InformationThe 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))
      0
    <current body of caml-compute-basic-indent>))

;new function
(defun caml-in-shebang-line ()
  (save-excursion
    (beginning-of-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 ...)
    (cond
     ((caml-in-shebang-line) (setq in-expr nil)) ;; maybe reset pos?
     ; special case for ;;
     ...)
   ...)
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0008173)
doligez (administrator)
2012-09-27 18:03
edited on: 2012-09-28 18:56

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


- Issue History
Date Modified Username Field Change
2012-08-14 19:45 Drakken New Issue
2012-09-06 16:43 doligez Target Version => 4.00.1+dev
2012-09-27 15:57 doligez Assigned To => doligez
2012-09-27 15:57 doligez Status new => assigned
2012-09-27 18:03 doligez Note Added: 0008173
2012-09-27 18:03 doligez Status assigned => resolved
2012-09-27 18:03 doligez Resolution open => fixed
2012-09-28 18:56 doligez Note Edited: 0008173 View Revisions


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker