Sourcing ~/.bashrc when starting Emacs from stumpwm

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Sourcing ~/.bashrc when starting Emacs from stumpwm

Shakthi Kannan-3
Hi,

I have the following code in my ~/.stumpwmrc on Ubuntu 14.10:

=== ~/.stumpwmrc ===

;; Emacs
(defvar *emacs-command* nil
  "Start an emacs client frame. Starts an emacs daemon if necessary.")
(setf *emacs-command* "emacsclient -c -a \"\"")

(define-key *root-map* (kbd "e") "run-emacs")
(define-key *root-map* (kbd "C-e") "run-emacs")

(defcommand run-emacs () ()
    (run-shell-command (concat "exec " *emacs-command*)))

=== END ===

When I login to stumpwm, an Emacs server starts in the background, and
an Emacs client opens up. This unfortunately doesn't run my ~/.profile
(which sources ~/.bashrc). Hence, I don't get the variables defined in
~/.bashrc when I open eshell.

#1

But, if I open a Bash terminal after logging into stumpwm and execute:

  $ bash -c 'emacsclient -c -a ""'

it opens up an Emacs client, and I am able to see the ~/.bashrc
environment variables in eshell.

#2

I tried using the following in ~/.stumpwmrc:

  (setf *emacs-command* "bash -c 'emacsclient -c -a \"\"'")

but, I was not able to see the environment variables inside eshell.

#3

I also tried running a command directly from inside stumpwm using "C-t
!" and 'sh -c emacsclient -c -a ""', and it opened the Emacs client,
but, I still don't see the environment variables in eshell.

Is there a way to start an Emacs client after logging into stumpwmrc,
that inherits the bash environment settings?

Appreciate any inputs in this regard,

Thanks!

SK

--
Shakthi Kannan
http://www.shakthimaan.com

_______________________________________________
Stumpwm-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/stumpwm-devel
Reply | Threaded
Open this post in threaded view
|

Re: Sourcing ~/.bashrc when starting Emacs from stumpwm

Mehul Sanghvi-2
How are you starting your stumpwm ?   I never had this problem when I was using stumpwm.  I always started it from my ~/.xinitrc and if I recall (that system died over a year ago and I didn't have any backups) and it had #!/bin/bash at the top of it.



On Tue, Sep 8, 2015 at 1:53 PM, Shakthi Kannan <[hidden email]> wrote:
Hi,

I have the following code in my ~/.stumpwmrc on Ubuntu 14.10:

=== ~/.stumpwmrc ===

;; Emacs
(defvar *emacs-command* nil
  "Start an emacs client frame. Starts an emacs daemon if necessary.")
(setf *emacs-command* "emacsclient -c -a \"\"")

(define-key *root-map* (kbd "e") "run-emacs")
(define-key *root-map* (kbd "C-e") "run-emacs")

(defcommand run-emacs () ()
    (run-shell-command (concat "exec " *emacs-command*)))

=== END ===

When I login to stumpwm, an Emacs server starts in the background, and
an Emacs client opens up. This unfortunately doesn't run my ~/.profile
(which sources ~/.bashrc). Hence, I don't get the variables defined in
~/.bashrc when I open eshell.

#1

But, if I open a Bash terminal after logging into stumpwm and execute:

  $ bash -c 'emacsclient -c -a ""'

it opens up an Emacs client, and I am able to see the ~/.bashrc
environment variables in eshell.

#2

I tried using the following in ~/.stumpwmrc:

  (setf *emacs-command* "bash -c 'emacsclient -c -a \"\"'")

but, I was not able to see the environment variables inside eshell.

#3

I also tried running a command directly from inside stumpwm using "C-t
!" and 'sh -c emacsclient -c -a ""', and it opened the Emacs client,
but, I still don't see the environment variables in eshell.

Is there a way to start an Emacs client after logging into stumpwmrc,
that inherits the bash environment settings?

Appreciate any inputs in this regard,

Thanks!

SK

--
Shakthi Kannan
http://www.shakthimaan.com

_______________________________________________
Stumpwm-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/stumpwm-devel



--
Mehul N. Sanghvi
email: [hidden email]

_______________________________________________
Stumpwm-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/stumpwm-devel
Reply | Threaded
Open this post in threaded view
|

Re: Sourcing ~/.bashrc when starting Emacs from stumpwm

Burton Samograd-6
Hi Mehul,

The trick to sourcing your ~/.profile in your emacs shell is to create
a file ~/.emacs_bash with the following line:

    . ~/.profile


or ~/.bashrc or whatever you want the emacs shell to source on
startup. Make sure you put a newline at the end of the file.

Hopefully this helps and actually is the problem you're trying to solve.

Burton Samograd

On 9/8/15, Mehul Sanghvi <[hidden email]> wrote:

> How are you starting your stumpwm ?   I never had this problem when I was
> using stumpwm.  I always started it from my ~/.xinitrc and if I recall
> (that system died over a year ago and I didn't have any backups) and it had
> #!/bin/bash at the top of it.
>
>
>
> On Tue, Sep 8, 2015 at 1:53 PM, Shakthi Kannan <[hidden email]>
> wrote:
>
>> Hi,
>>
>> I have the following code in my ~/.stumpwmrc on Ubuntu 14.10:
>>
>> === ~/.stumpwmrc ===
>>
>> ;; Emacs
>> (defvar *emacs-command* nil
>>   "Start an emacs client frame. Starts an emacs daemon if necessary.")
>> (setf *emacs-command* "emacsclient -c -a \"\"")
>>
>> (define-key *root-map* (kbd "e") "run-emacs")
>> (define-key *root-map* (kbd "C-e") "run-emacs")
>>
>> (defcommand run-emacs () ()
>>     (run-shell-command (concat "exec " *emacs-command*)))
>>
>> === END ===
>>
>> When I login to stumpwm, an Emacs server starts in the background, and
>> an Emacs client opens up. This unfortunately doesn't run my ~/.profile
>> (which sources ~/.bashrc). Hence, I don't get the variables defined in
>> ~/.bashrc when I open eshell.
>>
>> #1
>>
>> But, if I open a Bash terminal after logging into stumpwm and execute:
>>
>>   $ bash -c 'emacsclient -c -a ""'
>>
>> it opens up an Emacs client, and I am able to see the ~/.bashrc
>> environment variables in eshell.
>>
>> #2
>>
>> I tried using the following in ~/.stumpwmrc:
>>
>>   (setf *emacs-command* "bash -c 'emacsclient -c -a \"\"'")
>>
>> but, I was not able to see the environment variables inside eshell.
>>
>> #3
>>
>> I also tried running a command directly from inside stumpwm using "C-t
>> !" and 'sh -c emacsclient -c -a ""', and it opened the Emacs client,
>> but, I still don't see the environment variables in eshell.
>>
>> Is there a way to start an Emacs client after logging into stumpwmrc,
>> that inherits the bash environment settings?
>>
>> Appreciate any inputs in this regard,
>>
>> Thanks!
>>
>> SK
>>
>> --
>> Shakthi Kannan
>> http://www.shakthimaan.com
>>
>> _______________________________________________
>> Stumpwm-devel mailing list
>> [hidden email]
>> https://lists.nongnu.org/mailman/listinfo/stumpwm-devel
>>
>
>
>
> --
> Mehul N. Sanghvi
> email: [hidden email]
>

_______________________________________________
Stumpwm-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/stumpwm-devel
Reply | Threaded
Open this post in threaded view
|

Re: Sourcing ~/.bashrc when starting Emacs from stumpwm

Joram Schrijver
In reply to this post by Shakthi Kannan-3
Hi,

The reason prefixing your *emacs-command* with `bash -c` doesn't work is
probably that the shell that is then started is not interactive.
Non-interactive shells don't source `~/.profile`. Adding `-i` to the
bash command should turn it into an interactive shell, making it source
`~/.profile`.

--
Joram

Shakthi Kannan writes:

> Hi,
>
> I have the following code in my ~/.stumpwmrc on Ubuntu 14.10:
>
> === ~/.stumpwmrc ===
>
> ;; Emacs
> (defvar *emacs-command* nil
>   "Start an emacs client frame. Starts an emacs daemon if necessary.")
> (setf *emacs-command* "emacsclient -c -a \"\"")
>
> (define-key *root-map* (kbd "e") "run-emacs")
> (define-key *root-map* (kbd "C-e") "run-emacs")
>
> (defcommand run-emacs () ()
>     (run-shell-command (concat "exec " *emacs-command*)))
>
> === END ===
>
> When I login to stumpwm, an Emacs server starts in the background, and
> an Emacs client opens up. This unfortunately doesn't run my ~/.profile
> (which sources ~/.bashrc). Hence, I don't get the variables defined in
> ~/.bashrc when I open eshell.
>
> #1
>
> But, if I open a Bash terminal after logging into stumpwm and execute:
>
>   $ bash -c 'emacsclient -c -a ""'
>
> it opens up an Emacs client, and I am able to see the ~/.bashrc
> environment variables in eshell.
>
> #2
>
> I tried using the following in ~/.stumpwmrc:
>
>   (setf *emacs-command* "bash -c 'emacsclient -c -a \"\"'")
>
> but, I was not able to see the environment variables inside eshell.
>
> #3
>
> I also tried running a command directly from inside stumpwm using "C-t
> !" and 'sh -c emacsclient -c -a ""', and it opened the Emacs client,
> but, I still don't see the environment variables in eshell.
>
> Is there a way to start an Emacs client after logging into stumpwmrc,
> that inherits the bash environment settings?
>
> Appreciate any inputs in this regard,
>
> Thanks!
>
> SK

--
Joram

_______________________________________________
Stumpwm-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/stumpwm-devel
Reply | Threaded
Open this post in threaded view
|

Re: Sourcing ~/.bashrc when starting Emacs from stumpwm

Shakthi Kannan-3
Hi Joram,

--- On Wed, Sep 9, 2015 at 2:17 AM, Joram Schrijver <[hidden email]> wrote:
| The reason prefixing your *emacs-command* with `bash -c` doesn't work is
| probably that the shell that is then started is not interactive.
| Non-interactive shells don't source `~/.profile`. Adding `-i` to the
| bash command should turn it into an interactive shell, making it source
| `~/.profile`.
\--

That did it. Using `-i` worked.

Thanks for all your replies!

SK

--
Shakthi Kannan
http://www.shakthimaan.com

_______________________________________________
Stumpwm-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/stumpwm-devel
Reply | Threaded
Open this post in threaded view
|

Re: Sourcing ~/.bashrc when starting Emacs from stumpwm

Stefan Reichör
Shakthi Kannan <[hidden email]> writes:

> Hi Joram,
>
> --- On Wed, Sep 9, 2015 at 2:17 AM, Joram Schrijver <[hidden email]> wrote:
> | The reason prefixing your *emacs-command* with `bash -c` doesn't work is
> | probably that the shell that is then started is not interactive.
> | Non-interactive shells don't source `~/.profile`. Adding `-i` to the
> | bash command should turn it into an interactive shell, making it source
> | `~/.profile`.
> \--
>
> That did it. Using `-i` worked.
>
> Thanks for all your replies!
>
> SK

Thanks a lot for these ideas. I use emacs since about 20 years.
Today I changed the way I start emacs:

(defcommand emacs () ()
  "run emacs"
  (run-or-raise "zsh -ic 'emacsclient -c -a \"\"'" '(:instance "^emacs$")))

Up to now I used:
;; (defcommand emacs () ()
;;   "run emacs"
;;   (run-or-raise "emacs -T emacs" '(:instance "^emacs$")))


I use zsh. My new command starts an emacs daemon that is initialized
with my zsh setup. run-or-raise is used to switch to an already
available emacs frame when available.

Just wanted to share my cool new setup.

Stefan.

_______________________________________________
Stumpwm-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/stumpwm-devel
Reply | Threaded
Open this post in threaded view
|

Re: Sourcing ~/.bashrc when starting Emacs from stumpwm

W. Greenhouse
In reply to this post by Shakthi Kannan-3
Shakthi Kannan <[hidden email]> writes:

> Hi Joram,
>
> --- On Wed, Sep 9, 2015 at 2:17 AM, Joram Schrijver <[hidden email]> wrote:
> | The reason prefixing your *emacs-command* with `bash -c` doesn't work is
> | probably that the shell that is then started is not interactive.
> | Non-interactive shells don't source `~/.profile`. Adding `-i` to the
> | bash command should turn it into an interactive shell, making it source
> | `~/.profile`.
> \--
>
> That did it. Using `-i` worked.
>
> Thanks for all your replies!
>
> SK
I do a somewhat kludgey variation on this: I actually start the whole
.xsession or .xinitrc as an interactive shell by having the hashbang line
be #!/bin/zsh -i.

That way any processes invoked from stumpwm inherit the ~/.profile, even when
I am reaching stumpwm from a X login session manager. I get very confused
by the precedence and rules for when the different shell init files get run,
so I tried to simplify this to have a more consistent environment between my
GUI and shell worlds.


#!/bin/zsh -i

userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/etc/X11/xinit/.Xresources
sysmodmap=/etc/X11/xinit/.Xmodmap

# merge in defaults and keymaps

if [ -f $sysresources ]; then
    xrdb -merge $sysresources
fi

if [ -f $sysmodmap ]; then
    xmodmap $sysmodmap
fi

if [ -f $userresources ]; then
    xrdb -merge $userresources
fi

if [ -x ~/git/tomorrow-theme/Xdefaults/ ]; then
    xrdb -merge ~/git/tomorrow-theme/Xdefaults/XresourceTomorrowNightBright
fi

if [ -f $usermodmap ]; then
    xmodmap $usermodmap
fi

xcompmgr &

fbsetbg -a /usr/share/wallpapers/slack-empire-1920x1080.jpg

# Start the window manager:
# if [ -z "$DESKTOP_SESSION" -a -x /usr/bin/ck-launch-session ]; then
#   exec ck-launch-session sbcl --eval '(ql:quickload "stumpwm")' --eval '(stumpwm:stumpwm)'
# else
#   exec sbcl --eval '(ql:quickload "stumpwm")' --eval '(stumpwm:stumpwm)'
# fi
exec sbcl --eval '(ql:quickload "stumpwm")' --eval '(stumpwm:stumpwm)'


--
Regards,
WGG

_______________________________________________
Stumpwm-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/stumpwm-devel