el/dot-emacs.el: Hack on `comint-line-beginning-position'.
authorMark Wooding <mdw@distorted.org.uk>
Sat, 5 Aug 2017 23:52:05 +0000 (00:52 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 5 Aug 2017 23:52:05 +0000 (00:52 +0100)
It's quite badly broken in the case where it's using fields to mark
prompts: it goes straight to the start of the entire input area, rather
than to the start of the current line if there's more than one.  In
particular, this confuses IELM, which uses `comint-bol' to decide
whether to indent when you press TAB.

Fix this bogosity.

el/dot-emacs.el

index 37bd96a..8195411 100644 (file)
@@ -3770,6 +3770,15 @@ that character only to be normal punctuation.")
   (and mdw-auto-indent
        (indent-for-tab-command)))
 
+(defadvice comint-line-beginning-position
+    (around mdw-calculate-it-properly () activate compile)
+  "Calculate the actual line start for multi-line input."
+  (if (or comint-use-prompt-regexp
+         (eq (field-at-pos (point)) 'output))
+      ad-do-it
+    (setq ad-return-value
+         (constrain-to-field (line-beginning-position) (point)))))
+
 (defun mdw-setup-m4 ()
 
   ;; Inexplicably, Emacs doesn't match braces in m4 mode.  This is very