chiark / gitweb /
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 37bd96a6c07ce38822f9cae6b43f6b85431d40fe..8195411ab293a8e0c79e71590d2a076ec157a555 100644 (file)
@@ -3770,6 +3770,15 @@ (defun comint-send-and-indent ()
   (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