如何设置一个键绑定使Emacs像我想要的透明/不透明? [英] How to set a key binding to make Emacs as transparent/opaque as I want?

查看:156
本文介绍了如何设置一个键绑定使Emacs像我想要的透明/不透明?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Emacs中有一个命令,使其变得不透明/透明(参考神话般的问题,指出可以在Emacs中实现透明度, EmacsWiki 页面链接在那里,其中包含我以下使用的代码。)



EmacsWiki代码设置Cc t以打开和关闭以前设置的透明度: (< active> [<非活动])(set-frame-parameter )
(set-frame-parameter(selected-frame)'alpha'(85 50))
(add-to-list'default-frame-alist'(alpha 85 50))

在这里输入代码(eval-when-compile(require'cl))
(defun toggle-transparency()
(interactive)
(if(/ =
(cadr(find'alpha(frame-parameters nil):key#'car))
100)
( set-frame-parameter nil'alpha'(100 100))
(set-frame-parameter nil'alpha'(85 60))))
(global-set-key(kbdCc t )'toggle-transparency)

我想做的是能够选择%当我在Emacs时透明度。



如果可能,我想要一个命令,我键入例如活动帧的Cc t N(其中N是%不透明),然后是Mc t N表示非活动窗口。



如果不能这样做,那么也可能是一个命令,如果我键入Cc t,它会询问我提供的活动的不透明的数字窗口(对于使用Mc t的不活动窗口也是一样的)。



提前感谢您的时间:)



以下只是一些意见,如果您不感兴趣,回答问题并不重要:



我真的想要这个,因为当我告诉我的主管我正在学习Emacs时,他说TexShop好多了,而且我在使用80年代的软件。我告诉他关于Emacs的奇迹,他说TexShop有所有这一切。我匹配他显示的所有东西,除了透明度(尽管他不能匹配预览乳胶Emacs中的预览)。我偶然发现了透明度的东西,现在我想向他展示Emacs规则!



我想像这将是一些你的一些蛋糕,即使如果我花了足够的时间尝试学习lisp或阅读,我可以完成它,我不是一个程序员,我只使用Emacs和mac一个星期。我已经迷失了!所以感谢您的时间和帮助 - 我将最终学习lisp!



编辑:我的主管使用TextMate,而不是TeXShop。现在更有意义了吗?

解决方案

 (defun set-frame-alpha &可选活动)
(交互式nEnter alpha值(1-100):\\\
p)
(let *((elt(assoc'alpha default-frame-alist))
(old(frame-parameter nil'alpha))
(new(cond((atom old))(arg,arg))
((eql 1 active)旧的))
(t`(,(car old),arg)))))
(如果elt(setcdr elt new)(push`(alpha,@ new)default-frame-alist )
(set-frame-parameter nil'alpha new)))
(global-set-key(kbdCc t)'set-frame-alpha)

使用 Cc t 作为活动框架, Cu Cc t 非活动框架。



编辑:



使会话持续的一种方法是启用 desktop-save-mode 并将 default-frame-alist 添加到 desktop-glo bals-to-save ,通过自定义界面:
M-x自定义组RET桌面


I want to have a command in Emacs to make it as opaque/transparent as I want (refer to the fabulous question that pointed out that transparency is possible in Emacs, and the EmacsWiki page linked there which has the code I am using below).

The EmacsWiki code sets "C-c t" to toggle the previously set transparency on and off:

;;(set-frame-parameter (selected-frame) 'alpha '(<active> [<inactive>]))  
(set-frame-parameter (selected-frame) 'alpha '(85 50))  
(add-to-list 'default-frame-alist '(alpha 85 50))

enter code here(eval-when-compile (require 'cl))  
(defun toggle-transparency ()  
(interactive)  
(if (/= 
    (cadr (find 'alpha (frame-parameters nil) :key #'car)) 
    100)  
   (set-frame-parameter nil 'alpha '(100 100))
 (set-frame-parameter nil 'alpha '(85 60))))  
 (global-set-key (kbd "C-c t") 'toggle-transparency)

What I would like to do is to be able to choose the % transparency when I am in Emacs.

If possible, I would like a command where I type for example "C-c t N" (where N is the % opaqueness) for the active frame, and then "M-c t N" for the inactive window.

If that can't be done like that, then maybe a command where if I type "C-c t" it asks me for the number which gives the opaqueness of the active window (and the same for the inactive window using "M-c t").

Thanks in advance for your time :)

Below are just some comments that are not important to answer the question if you are not interested:

I really want this because when I told my supervisor I was learning Emacs he said TexShop is much better and that I am using software from the 80's. I told him about the wonders of Emacs and he said TexShop has all of it and more. I matched everything he showed me except for the transparency (though he couldn't match the preview inside Emacs from preview-latex). I found the transparency thing by chance, and now I want to show him Emacs rules!

I imagine this will be a piece of cake for some of you, and even though I could get it done if I spent enough time trying to learn lisp or reading around, I am not a programmer and I have only been using Emacs and a mac for a week. I am lost already as it is! So thanks in advance for your time and help - I will learn lisp eventually!

Edit: My supervisor uses TextMate, not TeXShop. Does it make more sense now?

解决方案

(defun set-frame-alpha (arg &optional active)
  (interactive "nEnter alpha value (1-100): \np")
  (let* ((elt (assoc 'alpha default-frame-alist))
         (old (frame-parameter nil 'alpha))
         (new (cond ((atom old)     `(,arg ,arg))
                    ((eql 1 active) `(,arg ,(cadr old)))
                    (t              `(,(car old) ,arg)))))
    (if elt (setcdr elt new) (push `(alpha ,@new) default-frame-alist))
    (set-frame-parameter nil 'alpha new)))
(global-set-key (kbd "C-c t") 'set-frame-alpha)

Use C-c t for the active frame, and C-u C-c t for the non-active frame.

Edit:

One way to make the effect persists across sessions is to enable desktop-save-mode and add default-frame-alist to desktop-globals-to-save, through the customization interface: M-x customize-group RET desktop.

这篇关于如何设置一个键绑定使Emacs像我想要的透明/不透明?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆