2011-04-12 30 views
3

问题如何指定一个用户的emacs init文件来加载emacsclient?

如何指定一个用户的emacs init文件来加载emacsclient?

emacsclient不理解'-u用户'和'-ALTERNATE-EDITOR'不允许我引用它并提供'-u用户'。

例如,运行:

/usr/bin/emacsclient -n -a '/usr/bin/emacs -u <username>' ~<username>/notes.txt 

回报

/usr/bin/emacsclient: error executing alternate editor "/usr/bin/emacs -u <username>" 

背景

我使用emacs版本23.1.1和emacsclient版本23.1。

emacs本身支持'-u user'加载指定用户的init文件。

我用我的别名下面的bash函数文件来调用emacs的

# a wrapper is needed to sandwich multiple command line arguments in bash 
# 2>/dev/null hides 
# "emacsclient: can't find socket; have you started the server?" 
emacs_wrapper() { 
    if [ 0 -eq $# ] 
    then 
    /usr/bin/emacsclient -n -a /usr/bin/emacs ~<username>/notes.txt 2>/dev/null & 
    else 
    /usr/bin/emacsclient -n -a /usr/bin/emacs $* 2>/dev/null & 
    fi 
} 
alias x='emacs_wrapper' 

打字X,接着文件的列表:

  • 如果正在运行连接到现有的emacs的服务器,否则开始一个新的
  • 作为后台进程执行
  • 如果没有提供文件,打开文件或笔记文件列表

当我以我自己的身份登录时,此功能非常有用。但是,许多生产箱需要我作为生产用户登录。我已经将我的别名分隔成一个bash脚本,因此我可以通过简单的运行来获得我的别名和bash函数。

. ~<username>/alias.sh 

不幸的是,这会不会让我用我的.emacs文件(〜<用户名> /.emacs):(

这个问题已经快把我逼疯了。

回答

3

如果可以的话在替代编辑器规范中不包括命令行参数,那么只需编写一个shell脚本,它就可以替代您,并将其作为备用编辑器参数提供。

#!/bin/sh 
emacs -u (username) "[email protected]" 
+0

谢谢;这很好用! – vlee 2011-04-12 21:56:03

1

服务器/客户端模型的要点是,您拥有一个具有自己的一组配置的现有Emacs,然后通过一个或多个客户端进行连接。

如果服务器已被配置为显示菜单栏(全局设置),客户端应该怎么做,客户端说不显示它?如果另一位客户附加说明要显示它呢?

如果您想对Emacs使用不同的设置,请使用不同的emacs会话。

相关问题