Emacs 设置透明度
很多Emacs的配置是小而杂的,今天发一个关于透明度的几个函数,能让你方便的使用它们。
你真正用到的方法,见最后。
;;; my-alpha.el ---
;; Copyright 2013 Scinart Ouyang
;;
;; Author: akubeej@gmail.com
;; Version: $Id: my-alpha.el,v 0.0 2013/06/03 12:22:42 scinart Exp $
;; Keywords:
;; X-URL: not distributed yet
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, write to the Free Software
;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
;;; Code:
;; emacs的透明度有两个,一个是激活状态下的透明度,一个是非激活状态下的透明度。
;; 默认透明度增减幅度为2或1,初始为激活不透明,非激活状态透明度50%
(defvar frame-alpha-active-walk-step 2)
(defvar frame-alpha-inactive-walk-step 1)
(defvar frame-alpha-default (list 100 50))
(defconst frame-alpha-original-lower-limit 20)
;; 透明度下限
(setq frame-alpha-lower-limit 10)
(defvar frame-alpha-max 100)
(defvar frame-alpha-min frame-alpha-lower-limit)
(defun frame-alpha-initialize ()
(set-frame-parameter nil 'alpha (or (frame-parameter nil 'alpha) frame-alpha-default)))
;; important
(frame-alpha-initialize)
(defun frame-alpha-set-active (arg)
(cond ((> arg frame-alpha-max)
(dolist (f (frame-list))
(set-frame-parameter f 'alpha (list frame-alpha-max (second (frame-parameter nil 'alpha))))))
((< arg frame-alpha-min)
(dolist (f (frame-list))
(set-frame-parameter f 'alpha (list frame-alpha-min (second (frame-parameter nil 'alpha))))))
(t
(dolist (f (frame-list))
(set-frame-parameter f 'alpha (list arg (second (frame-parameter nil 'alpha))))))))
(defun frame-alpha-get-active ()
(first (frame-parameter nil 'alpha)))
(defun frame-alpha-set-inactive (arg)
(cond ((> arg frame-alpha-max)
(dolist (f (frame-list))
(set-frame-parameter f 'alpha (list (first (frame-parameter nil 'alpha)) frame-alpha-max))))
((< arg frame-alpha-min)
(dolist (f (frame-list))
(set-frame-parameter f 'alpha (list (first (frame-parameter nil 'alpha)) frame-alpha-min))))
(t
(dolist (f (frame-list))
(set-frame-parameter f 'alpha (list (first (frame-parameter nil 'alpha)) arg))))))
(defun frame-alpha-get-inactive ()
(second (frame-parameter nil 'alpha)))
(defun frame-alpha-set-all (arg)
(if (and (list arg)
(list (cdr arg))
(null (cddr arg))
(numberp (first arg))
(numberp (second arg)))
(progn
(frame-alpha-set-active (first arg))
(frame-alpha-set-inactive (second arg)))
(message "%s in not a valid parameter like (100 80)" arg)))
(defun frame-alpha-get-all ()
(frame-parameter nil 'alpha))
(defun frame-alpha-active-increase ()
(interactive)
(frame-alpha-set-active (+ (frame-alpha-get-active) frame-alpha-active-walk-step)))
(defun frame-alpha-active-decrease ()
(interactive)
(frame-alpha-set-active (- (frame-alpha-get-active) frame-alpha-active-walk-step)))
(defun frame-alpha-inactive-increase ()
(interactive)
(frame-alpha-set-inactive (+ (frame-alpha-get-inactive) frame-alpha-inactive-walk-step)))
(defun frame-alpha-inactive-decrease ()
(interactive)
(frame-alpha-set-inactive (- (frame-alpha-get-inactive) frame-alpha-inactive-walk-step)))
(defun frame-alpha-all-increase ()
(frame-alpha-active-increase)
(frame-alpha-inactive-increase))
(defun frame-alpha-all-decrease ()
(frame-alpha-active-decrease)
(frame-alpha-inactive-decrease))
(defun frame-alpha-get ()
(interactive)
(message "%s" (frame-parameter (selected-frame) 'alpha)))
(defun frame-alpha-reset ()
(interactive)
(set-frame-parameter (selected-frame) 'alpha frame-alpha-default))
(provide 'my-alpha)
;;;; User Options, Variables
;;;;##########################################################################
;; 这是一个模仿C-x e e e e 这样的宏,感觉很神奇。当需要经常重复一些函数里很有用。
(defmacro continuous-do-things (name round-expression)
"continuous-do-things, no arg now, please.
example: (continuous-do-things continuous-downcase-word (downcase-word 1))
2013-05-30 Thursday 09:43:50 by Scinart.
so great"
`(defun ,name ()
(interactive)
,round-expression
(let ((repeat-key (and (> (length (this-single-command-keys)) 1)
last-input-event))
repeat-key-str)
(setq repeat-key-str (format-kbd-macro (vector repeat-key) nil))
(while repeat-key
(unless (current-message)
(message "(Type %s to repeat)"
repeat-key-str))
(if (equal repeat-key (read-event))
(progn
(clear-this-command-keys t)
,round-expression
(setq last-input-event nil))
(setq repeat-key nil)))
(when last-input-event
(clear-this-command-keys t)
(setq unread-command-events (list last-input-event))))))
(continuous-do-things continuous-frame-alpha-active-increase (frame-alpha-active-increase))
(continuous-do-things continuous-frame-alpha-active-decrease (frame-alpha-active-decrease))
(continuous-do-things continuous-frame-alpha-inactive-increase (frame-alpha-inactive-increase))
(continuous-do-things continuous-frame-alpha-inactive-decrease (frame-alpha-inactive-decrease))
(continuous-do-things continuous-frame-alpha-all-increase (frame-alpha-all-increase))
(continuous-do-things continuous-frame-alpha-all-decrease (frame-alpha-all-decrease))
;; 这六个是你需要用的函数。自行绑定你喜欢的快捷键。
;; peek 就是暂时透明1.5秒。C-u peek 就是2秒多,C-u C-u peek 就是三秒多。依此类推。
(defun peek (arg)
"temporary set transparent to arg seconds
2013-06-06 Thursday 22:45:34 by Scinart"
(interactive "p")
(let ((alpha (car (frame-alpha-get-all)))
(time (1+ (log (+ 1 (abs arg)) 4))))
(when (< 50 alpha)
(frame-alpha-set-active 33)
(message "%d" time)
(sleep-for (abs time) 500)
(frame-alpha-set-active alpha))))
;; 保持透明,直到按任意键,不过不可以按C-g,否则会保持透明状态的透明度,还没想出来怎么解决。
(defun perspective ()
"be transparent until a key stroke
2013-06-06 Thursday 22:45:58 by Scinart"
(interactive)
(let ((active-alpha (frame-alpha-get-active))
(inactive-alpha (frame-alpha-get-inactive)))
(frame-alpha-set-active frame-alpha-min)
(frame-alpha-set-inactive frame-alpha-min)
(read-event)
(when last-input-event
(frame-alpha-set-active active-alpha)
(frame-alpha-set-inactive inactive-alpha)
(setq unread-command-events (list last-input-event)))))
;; 重新定义了make-frame-command,即C-x 5 2,让新窗口具有与原来窗口一样的透明度。
(defun make-frame-command ()
"Make a new frame, on the same terminal as the selected frame.
If the terminal is a text-only terminal, this also selects the
new frame.
modified 2013-06-04 Tuesday 00:23:47)"
(interactive)
(if (display-graphic-p)
(make-frame (list (cons 'alpha (frame-parameter (selected-frame) 'alpha))))
(select-frame (make-frame))))
2018年11月29日 10:56
A senior function is painted for the struggle and all vital parts for the candidates. All the issues of my assignment help australia review are reflected for the candidates. The hidden items have been done for the use of the tools and all partial items for the humans in various slots and reforms for the people.
2019年3月18日 18:01
It is very necessary that the students put down genuine <a href="https://topassignmentreviews.com/review/myassignmenthelp-com/">my assignment help review</a> because it serves the purpose of letting the other students know how the service is. And students must also read the reviews to get an outlook on the services that the site is giving. Let us come to the point why reading reviews are necessary.
2019年3月19日 15:36
Identify your purpose before you start <a href="https://myassignmenthelp.com/business-report-writing.html">business report writing</a>. <a href="https://myassignmenthelp.com">Myassignmenthelp</a> will save you lots of time rewriting later on and prevent a sense of aimlessness from creeping into your content.
2019年3月19日 15:36
Identify your purpose before you start business report writing. Myassignmenthelp will save you lots of time rewriting later on and prevent a sense of aimlessness from creeping into your content.
2019年3月27日 18:34
At the initial stage, you need to plan your work and gather the information about the thesis topic. The online experts are here to provide you the best thesis writing help for your university semesters.
2019年12月06日 18:57
Our academic pursuits, along with a range of extracurricular activities, help in honing a child's skills and ensuring that he/she grows to be a mature and responsible citizen.
best school in greater noida
2020年1月27日 19:23
We offers end-to-end technical consultancy and know-how as well as know-why to broad spectrum of different requirements of broadcasting industry.
mac pro reseller in delhi
ipad mini 4 reseller in kolkata
ipad air reseller in delhi
mac mini reseller in ahmedabad
newsroom automation in india
ipad service center in guwahati
mac pro reseller in ahmedabad
2020年2月26日 16:10
We provide the cheapest and most reliable csgo accounts compared to anywhere on the internet. This site is run by people who have boosted their way up the ladder.
cheap csgo accounts for sale
2020年2月26日 16:11
Our approach brings together best-in-class virtualized compute, storage, and networking infrastructure.
IT services and support company in uae
cloud partner in uae
citrix partner in uae
AWS partner in uae
2020年2月26日 16:11
Welcome to the world of gaming, where life is fast paced and interesting. There is always an adventure waiting for you online.
csgo accounts
2020年6月05日 19:44
We are best Professional SEO, Digital Marketing, Web Designing and Web Development Company in Bangalore.<br>
<a href="https://www.prinfosolutions.com">best digital marketing agency in bangalore</a><br>
<a href="https://www.prinfosolutions.com/search-engine-optimization.html">seo services company in bangalore</a><br>
<a href="https://www.prinfosolutions.com/digital-marketing.html">best digital marketing company in bangalore</a><br>
<a href="https://www.prinfosolutions.com/pay-per-click.html">PPC services in bangalore</a>