unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Erik Selberg <erik@selberg.org>
To: emacs-devel@gnu.org
Subject: comint fix for shell colors
Date: Mon, 14 Nov 2016 23:14:25 -0800	[thread overview]
Message-ID: <CAHa5c_PffwbxLuJhGapqX41_0UrpkTKqZY9+g1687fOiCP_0jQ@mail.gmail.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 490 bytes --]

I've been trying to use shell (vs term / mult-term) with bash / zsh and my
color prompts. In comint, comint-highlight-prompt clobbers the colors. I
made the following patch against 24.5 but I see comint has been updated in
25. What's the right process for adding this for 25? This is solved for me
locally, but seems something that could be added for all.

Screenshot included (I use a variant of the agnoster theme and zsh, along
with solarized-dark and power line mode lines)

Thanks,
-e

[-- Attachment #1.2: Type: text/html, Size: 578 bytes --]

[-- Attachment #2: comint-24.5.patch --]
[-- Type: application/octet-stream, Size: 3186 bytes --]

*** /tmp/comint.el	2016-11-14 23:04:50.000000000 -0800
--- /Users/selberg/elisp/comint.el	2016-11-14 23:06:36.000000000 -0800
***************
*** 104,109 ****
--- 104,110 ----
  (require 'ring)
  (require 'ansi-color)
  (require 'regexp-opt)                   ;For regexp-opt-charset.
+ (require 'simple)                       ;For password-word-equivalents
  \f
  ;; Buffer Local Variables:
  ;;============================================================================
***************
*** 154,159 ****
--- 155,168 ----
  ;;;   :prefix "comint-"
  ;;;   :group 'comint)
  
+ (defcustom comint-do-highlight-prompt t
+   "Highlight prompt. Set to nil to let underlying process set colors (useful for modern shells)"
+   :type 'boolean
+   :group 'comint
+   :version "22.1"
+   )
+ 
+ 
  (defvar comint-prompt-regexp "^"
    "Regexp to recognize prompts in the inferior process.
  Defaults to \"^\", the null string at BOL.
*************** the start, the cdr to the end of the las
*** 1922,1936 ****
    "Snapshot the current `comint-last-prompt'.
  Freezes the `font-lock-face' text property in place."
    (when comint-last-prompt
      (with-silent-modifications
        (add-text-properties
         (car comint-last-prompt)
         (cdr comint-last-prompt)
!        '(font-lock-face comint-highlight-prompt)))
      ;; Reset comint-last-prompt so later on comint-output-filter does
      ;; not remove the font-lock-face text property of the previous
      ;; (this) prompt.
!     (setq comint-last-prompt nil)))
  
  (defun comint-carriage-motion (start end)
    "Interpret carriage control characters in the region from START to END.
--- 1931,1949 ----
    "Snapshot the current `comint-last-prompt'.
  Freezes the `font-lock-face' text property in place."
    (when comint-last-prompt
+     (if comint-do-highlight-prompt
      (with-silent-modifications
        (add-text-properties
         (car comint-last-prompt)
         (cdr comint-last-prompt)
!        '(font-lock-face comint-highlight-prompt))
!       )
!     )
      ;; Reset comint-last-prompt so later on comint-output-filter does
      ;; not remove the font-lock-face text property of the previous
      ;; (this) prompt.
!     (setq comint-last-prompt nil)
!     ))
  
  (defun comint-carriage-motion (start end)
    "Interpret carriage control characters in the region from START to END.
*************** Make backspaces delete the previous char
*** 2082,2090 ****
  					'(font-lock-face)))
  	      (setq comint-last-prompt
  		    (cons (copy-marker prompt-start) (point-marker)))
! 	      (add-text-properties prompt-start (point)
! 				   '(rear-nonsticky t
! 				     font-lock-face comint-highlight-prompt)))
  	    (goto-char saved-point)))))))
  
  (defun comint-preinput-scroll-to-bottom ()
--- 2095,2106 ----
  					'(font-lock-face)))
  	      (setq comint-last-prompt
  		    (cons (copy-marker prompt-start) (point-marker)))
! 	      (if comint-do-highlight-prompt
! 		  (add-text-properties prompt-start (point)
! 				       '(rear-nonsticky t
! 							font-lock-face comint-highlight-prompt))
! 		)
! 	      )
  	    (goto-char saved-point)))))))
  
  (defun comint-preinput-scroll-to-bottom ()

[-- Attachment #3: Screen Shot 2016-11-14 at 11.12.29 PM.png --]
[-- Type: image/png, Size: 54018 bytes --]

             reply	other threads:[~2016-11-15  7:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-15  7:14 Erik Selberg [this message]
2016-11-18 10:07 ` comint fix for shell colors Eli Zaretskii
2016-11-18 14:25   ` Wolfgang Jenkner
2016-11-18 14:40     ` Eli Zaretskii
2016-11-18 15:06       ` Wolfgang Jenkner
2016-11-18 15:34         ` Eli Zaretskii
2016-11-18 15:40           ` Erik Selberg
2016-11-18 15:49           ` Wolfgang Jenkner
2016-11-18 15:53             ` Erik Selberg
2016-11-18 19:24               ` Erik Selberg
2016-11-18 19:50                 ` Eli Zaretskii
2016-11-18 22:43                   ` Erik Selberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHa5c_PffwbxLuJhGapqX41_0UrpkTKqZY9+g1687fOiCP_0jQ@mail.gmail.com \
    --to=erik@selberg.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).