如何设置键绑定以使 Emacs 按照我的需要透明/不透明?

发布于 2024-09-03 14:20:54 字数 1530 浏览 8 评论 0原文

我想在 Emacs 中使用一个命令将其设置为我想要的不透明/透明(请参阅精彩的 问题指出 Emacs 中可以实现透明,以及 EmacsWiki 页面链接那里有我在下面使用的代码)。

EmacsWiki 代码设置“Cc t”来打开和关闭先前设置的透明度:

;;(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)

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

如果可能的话,我想要一个命令,例如为活动框架键入“Cc t N”(其中 N 是不透明性百分比),然后为非活动窗口键入“Mc t N”。

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

提前感谢您抽出时间:)

下面只是一些评论,如果您不感兴趣,这些评论对回答问题并不重要:

我真的很想要这个,因为当我告诉我的主管我正在学习 Emacs 时,他说TexShop 好多了,我使用的是 80 年代的软件。我告诉他 Emacs 的神奇之处,他说 TexShop 拥有这一切,甚至更多。除了透明度之外,我匹配了他向我展示的所有内容(尽管他无法匹配来自 Preview-latex 的 Emacs 内的预览)。我偶然发现了透明这个东西,现在我想向他展示Emacs规则!

我想这对你们中的一些人来说是小菜一碟,尽管如果我花足够的时间尝试学习 lisp 或四处阅读,我就可以完成它,但我不是程序员,我只使用过 Emacs 和 mac一周。我已经迷路了!所以提前感谢您的时间和帮助 - 我最终会学习 lisp!

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

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

念三年u 2024-09-10 14:20:54
(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)

对活动帧使用 Cc t,对非活动帧使用 Cu Cc t

编辑:

使效果在会话中持续存在的一种方法是启用 desktop-save-mode 并将 default-frame-alist 添加到 desktop-globals-to-保存,通过自定义接口:
Mx 自定义组 RET 桌面

(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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文