all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Deleting the shell prompt in Shell Mode
@ 2015-07-07 19:16 Raffaele Ricciardi
  0 siblings, 0 replies; only message in thread
From: Raffaele Ricciardi @ 2015-07-07 19:16 UTC (permalink / raw)
  To: help-gnu-emacs

I am using the function `shell-snarf-envar' to read environment
variables in Shell Mode.  However, `shell-snarf-envar' leaves trace of
its passage, whilst I would rather have it act invisibly.  For instance,
calling:

     (shell-snarf-envar "SHELL")

leaves the following output (the first line belongs to my custom
prompt):

     ~/Downloads
     $ printenv "SHELL"
     /bin/bash

Therefore I have written a wrapper function to delete the shell
interaction performed by `shell-snarf-envar':

     (defun stealth-shell-snarf-envar/rr ($var)
       "Like `shell-snarf-envar', but leaves no trace."
       ;; fixme: does not delete the prompt.
       (lexical-let (($start (point)))
         (prog1
             (shell-snarf-envar "PS1")
           (delete-region $start (point)))))

But as the comment says, the above function does not delete the prompt,
as I would like it to do.

I have read that Shell Mode keeps track of prompts with text properties,
therefore I have run `shell-snarf-envar' with Edebug to understand its
inner workings, but Edebug has hung each time, leaving me without a clue
about how to detect shell prompts.

Thank you.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-07-07 19:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-07 19:16 Deleting the shell prompt in Shell Mode Raffaele Ricciardi

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.