* Red background color when editing a file as root (using TRAMP)
@ 2008-11-14 6:48 Nordlöw
2008-11-14 9:06 ` Paul R
[not found] ` <mailman.337.1226653574.26697.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 6+ messages in thread
From: Nordlöw @ 2008-11-14 6:48 UTC (permalink / raw)
To: help-gnu-emacs
I would like to visually hint that I am editing a buffer as root
(using TRAMP) by setting the background to a slightly more red color.
What hooks are involved?
/Nordlöw
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Red background color when editing a file as root (using TRAMP)
2008-11-14 6:48 Red background color when editing a file as root (using TRAMP) Nordlöw
@ 2008-11-14 9:06 ` Paul R
[not found] ` <mailman.337.1226653574.26697.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 6+ messages in thread
From: Paul R @ 2008-11-14 9:06 UTC (permalink / raw)
To: Nordlöw; +Cc: help-gnu-emacs
On Thu, 13 Nov 2008 22:48:26 -0800 (PST), Nordlöw <per.nordlow@gmail.com> said:
Nordlöw> I would like to visually hint that I am editing a buffer as
Nordlöw> root (using TRAMP) by setting the background to a slightly more
Nordlöw> red color. What hooks are involved?
Exemple to change the header line :
(defun my-tramp-header-line-function ()
(when (string-match "^/su\\(do\\)?:" default-directory)
(setq header-line-format
(format-mode-line "----- THIS BUFFER IS VISITED WITH ROOT PRIVILEGES -----"
'font-lock-warning-face))))
(add-hook 'find-file-hooks 'my-tramp-header-line-function)
(add-hook 'dired-mode-hook 'my-tramp-header-line-function)
--
Paul
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Red background color when editing a file as root (using TRAMP)
[not found] ` <mailman.337.1226653574.26697.help-gnu-emacs@gnu.org>
@ 2008-11-14 11:04 ` Nordlöw
2008-11-14 13:10 ` Kevin Rodgers
[not found] ` <mailman.348.1226668233.26697.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 6+ messages in thread
From: Nordlöw @ 2008-11-14 11:04 UTC (permalink / raw)
To: help-gnu-emacs
On 14 Nov, 10:06, Paul R <paul.r...@gmail.com> wrote:
> On Thu, 13 Nov 2008 22:48:26 -0800 (PST), Nordlöw <per.nord...@gmail.com> said:
>
> Nordlöw> I would like to visually hint that I am editing a buffer as
> Nordlöw> root (using TRAMP) by setting the background to a slightly more
> Nordlöw> red color. What hooks are involved?
>
> Exemple to change the header line :
>
> (defun my-tramp-header-line-function ()
> (when (string-match "^/su\\(do\\)?:" default-directory)
> (setq header-line-format
> (format-mode-line "----- THIS BUFFER IS VISITED WITH ROOT PRIVILEGES -----"
> 'font-lock-warning-face))))
>
> (add-hook 'find-file-hooks 'my-tramp-header-line-function)
> (add-hook 'dired-mode-hook 'my-tramp-header-line-function)
>
> --
> Paul
How do I buffer-locally set the background color?
/Nordlöw
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Red background color when editing a file as root (using TRAMP)
2008-11-14 11:04 ` Nordlöw
@ 2008-11-14 13:10 ` Kevin Rodgers
[not found] ` <mailman.348.1226668233.26697.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 6+ messages in thread
From: Kevin Rodgers @ 2008-11-14 13:10 UTC (permalink / raw)
To: help-gnu-emacs
Nordlöw wrote:
> How do I buffer-locally set the background color?
You can't: background color is a frame parameter, so it can be set
local to each frame but not each buffer.
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Red background color when editing a file as root (using TRAMP)
[not found] ` <mailman.348.1226668233.26697.help-gnu-emacs@gnu.org>
@ 2008-11-14 13:59 ` Andreas Politz
2008-11-15 10:14 ` Johan Bockgård
0 siblings, 1 reply; 6+ messages in thread
From: Andreas Politz @ 2008-11-14 13:59 UTC (permalink / raw)
To: help-gnu-emacs
Kevin Rodgers wrote:
> Nordlöw wrote:
>> How do I buffer-locally set the background color?
>
> You can't: background color is a frame parameter, so it can be set
> local to each frame but not each buffer.
>
You can fake it with an overlay. But this works only on the non-empty
parts of a buffer.
(let ((ov (make-overlay (point-min) (point-max) (current-buffer) nil t)))
(overlay-put ov 'face '(:background "red")))
-ap
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Red background color when editing a file as root (using TRAMP)
2008-11-14 13:59 ` Andreas Politz
@ 2008-11-15 10:14 ` Johan Bockgård
0 siblings, 0 replies; 6+ messages in thread
From: Johan Bockgård @ 2008-11-15 10:14 UTC (permalink / raw)
To: help-gnu-emacs
Andreas Politz <politza@fh-trier.de> writes:
> Kevin Rodgers wrote:
>> Nordlöw wrote:
>>> How do I buffer-locally set the background color?
>>
>> You can't: background color is a frame parameter, so it can be set
>> local to each frame but not each buffer.
>>
>
> You can fake it with an overlay. But this works only on the non-empty
> parts of a buffer.
>
> (let ((ov (make-overlay (point-min) (point-max) (current-buffer) nil t)))
> (overlay-put ov 'face '(:background "red")))
In Emacs 23 you can use
(set (make-local-variable 'face-remapping-alist)
'((default (:background "red"))))
(which has the same limitation).
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-11-15 10:14 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-14 6:48 Red background color when editing a file as root (using TRAMP) Nordlöw
2008-11-14 9:06 ` Paul R
[not found] ` <mailman.337.1226653574.26697.help-gnu-emacs@gnu.org>
2008-11-14 11:04 ` Nordlöw
2008-11-14 13:10 ` Kevin Rodgers
[not found] ` <mailman.348.1226668233.26697.help-gnu-emacs@gnu.org>
2008-11-14 13:59 ` Andreas Politz
2008-11-15 10:14 ` Johan Bockgård
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).