camlspotter avatar camlspotter committed e721ec4

not a complete fix but we have now tuareg-case-arrow-extra-indent

Comments (0)

Files changed (1)

 setting this variable to nil."
   :group 'tuareg :type 'boolean)
+(defcustom tuareg-case-arrow-extra-indent 2
+  "*How many spaces to indent from a `->' keyword in a pattern match case."
+  :group 'tuareg :type 'integer)
 (defcustom tuareg-electric-close-vector t
   "*Non-nil means electrically insert `|' before a vector-closing `]' or
 `>' before an object-closing `}'.
         (point (point)))
     ;; We don't need to find the keyword matching `and' since we know it's `let'!
+    (message "Xtuareg-semicolon-indent-kwop-point %s %d %s" leading-semi-colon (point) kwop)
        ((string= kwop ";")
        ((string= kwop "method")
         (+ (tuareg-paren-or-indentation-column) tuareg-method-indent))
-       ((string= kwop "->")
+       ((string= kwop "->") ;; -> ...; \n []
         (if (save-excursion
               (or (looking-at "\\<fun\\>\\||")
                   (looking-at (tuareg-give-extra-unindent-regexp))))
-            (tuareg-paren-or-indentation-indent)
+	    (progn
+	      (message "XXX %s" (match-string 0))
+	      (if (or (string= (match-string 0) "|"))
+		  (+ tuareg-case-arrow-extra-indent (tuareg-paren-or-indentation-indent))
+		(- (+ tuareg-case-arrow-extra-indent (tuareg-paren-or-indentation-indent))
+		   tuareg-pipe-extra-unindent)))
        ((string= kwop "end")
 (defun tuareg-compute-arrow-indent (start-pos)
   (let (kwop pos)
     (save-excursion (setq kwop (tuareg-find-arrow-match) pos (point)))
-    (cond ((string= kwop "|")
+    (cond ((string= kwop "|") ;; | ... ->
-           (+ (current-column) tuareg-default-indent))
+           (+ (current-column) tuareg-default-indent tuareg-case-arrow-extra-indent))
           ((or (string= kwop "val")
                (string= kwop "let"))
            (goto-char pos)
           (t (tuareg-paren-or-indentation-indent)))))
 (defun tuareg-compute-keyword-indent (kwop leading-operator start-pos)
+  (message "Xcomp-key-indent %s %s %s" kwop leading-operator start-pos)
   (cond ((string= kwop ";")
-         (if (looking-at (tuareg-no-code-after ";"))
+         (if (looking-at (tuareg-no-code-after ";")) ;; previous line ends with `;'
              (let* ((pos (point)) (indent (tuareg-find-semicolon-match)))
                (if (looking-at tuareg-phrase-regexp-1)
                (tuareg-indent-from-paren leading-operator start-pos)
              (+ tuareg-default-indent
                 (tuareg-indent-from-paren leading-operator start-pos))))
-          ((looking-at "->")
+          ((looking-at "->") ;; line after ->. A case or arrow type with a new line 
+	   (message "Xlooking-at ->")
            (tuareg-compute-arrow-indent start-pos))
           ((looking-at (tuareg-give-keyword-regexp))
            (tuareg-compute-keyword-indent kwop leading-operator start-pos))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.