From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.bugs Subject: bug#117: bug 117: messed up frame parameters Date: Wed, 9 Jul 2008 08:27:57 -0700 Message-ID: <000a01c8e1d8$5dbe5780$c2b22382@us.oracle.com> References: <003101c8e10b$b1c77d70$0200a8c0@us.oracle.com> <4873D420.4070303@gnu.org> Reply-To: Drew Adams , 117@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_000B_01C8E19D.B15F7F80" X-Trace: ger.gmane.org 1215618494 21970 80.91.229.12 (9 Jul 2008 15:48:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 9 Jul 2008 15:48:14 +0000 (UTC) To: <117@emacsbugs.donarmstrong.com> Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jul 09 17:48:58 2008 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KGbuP-0008Du-V8 for geb-bug-gnu-emacs@m.gmane.org; Wed, 09 Jul 2008 17:48:51 +0200 Original-Received: from localhost ([127.0.0.1]:45231 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KGbtX-0000N8-T1 for geb-bug-gnu-emacs@m.gmane.org; Wed, 09 Jul 2008 11:47:51 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KGbt9-00006a-VJ for bug-gnu-emacs@gnu.org; Wed, 09 Jul 2008 11:47:28 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KGbt6-0008Vn-Hr for bug-gnu-emacs@gnu.org; Wed, 09 Jul 2008 11:47:26 -0400 Original-Received: from [199.232.76.173] (port=49732 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KGbt6-0008VU-6p for bug-gnu-emacs@gnu.org; Wed, 09 Jul 2008 11:47:24 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:45286) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KGbt4-0005VF-CF for bug-gnu-emacs@gnu.org; Wed, 09 Jul 2008 11:47:23 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m69FlFx4020119; Wed, 9 Jul 2008 08:47:15 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.13.8/8.13.8/Submit) id m69FZ4Ft016710; Wed, 9 Jul 2008 08:35:04 -0700 X-Loop: don@donarmstrong.com Resent-From: "Drew Adams" Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Wed, 09 Jul 2008 15:35:03 +0000 Resent-Message-ID: Resent-Sender: don@donarmstrong.com X-Emacs-PR-Message: report 117 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by 117-submit@emacsbugs.donarmstrong.com id=B117.121561733215404 (code B ref 117); Wed, 09 Jul 2008 15:35:03 +0000 Original-Received: (at 117) by emacsbugs.donarmstrong.com; 9 Jul 2008 15:28:52 +0000 Original-Received: from rgminet01.oracle.com (rgminet01.oracle.com [148.87.113.118]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m69FSm3e015396 for <117@emacsbugs.donarmstrong.com>; Wed, 9 Jul 2008 08:28:49 -0700 Original-Received: from rgmgw2.us.oracle.com (rgmgw2.us.oracle.com [138.1.186.111]) by rgminet01.oracle.com (Switch-3.2.4/Switch-3.1.6) with ESMTP id m69FSgul022361 for <117@emacsbugs.donarmstrong.com>; Wed, 9 Jul 2008 09:28:42 -0600 Original-Received: from acsmt350.oracle.com (acsmt350.oracle.com [141.146.40.150]) by rgmgw2.us.oracle.com (Switch-3.2.4/Switch-3.2.4) with ESMTP id m69C5N6b015882 for <117@emacsbugs.donarmstrong.com>; Wed, 9 Jul 2008 09:28:41 -0600 Original-Received: from inet-141-146-46-1.oracle.com by acsmt350.oracle.com with ESMTP id 3706087261215617279; Wed, 09 Jul 2008 08:27:59 -0700 Original-Received: from dradamslap1 (/130.35.178.194) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 09 Jul 2008 08:27:58 -0700 X-Mailer: Microsoft Office Outlook 11 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 In-Reply-To: <4873D420.4070303@gnu.org> Thread-Index: AcjhPO9aHK5VbqvMQhmBOA4ZV/11ZwAmp6EA X-Brightmail-Tracker: AAAAAQAAAAI= X-Brightmail-Tracker: AAAAAQAAAAI= X-Whitelist: TRUE X-Whitelist: TRUE X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) Resent-Date: Wed, 09 Jul 2008 11:47:26 -0400 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:18679 Archived-At: This is a multi-part message in MIME format. ------=_NextPart_000_000B_01C8E19D.B15F7F80 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit You can use the attached code to repro the problem. See initial bug report for symptom details. emacs -Q --debug-init -l ".../path/to/hexrgb.el" -l ".../path/to/oneonone.el" -f "1on1-emacs" ------=_NextPart_000_000B_01C8E19D.B15F7F80 Content-Type: application/octet-stream; name="oneonone.el" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="oneonone.el" ;;; oneonone.el --- Frame configuration that uses one frame per window.=0A= ;;=0A= ;; Filename: oneonone.el=0A= ;; Description: Frame configuration that uses one frame per window.=0A= ;; Author: Drew Adams=0A= ;; Maintainer: Drew Adams=0A= ;; Copyright (C) 1999-2008, Drew Adams, all rights reserved.=0A= ;; Created: Fri Apr 2 12:34:20 1999=0A= ;; Version: 21.1=0A= ;; Last-Updated: Tue Feb 12 07:08:17 2008 (Pacific Standard Time)=0A= ;; By: dradams=0A= ;; Update #: 2344=0A= ;; URL: http://www.emacswiki.org/cgi-bin/wiki/oneonone.el=0A= ;; Keywords: local, frames=0A= ;; Compatibility: GNU Emacs 20.x, GNU Emacs 21.x, GNU Emacs 22.x=0A= ;;=0A= ;; Features that might be required by this library:=0A= ;;=0A= ;; `avoid', `cl', `files+', `frame-cmds', `frame-fns', `hexrgb',=0A= ;; `misc-fns', `oneonone', `strings', `thingatpt', `thingatpt+',=0A= ;; `zoom-frm'.=0A= ;;=0A= ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;=0A= ;;=0A= ;;; Commentary:=0A= ;;=0A= ;; Frame configuration that uses one frame per window.=0A= ;;=0A= ;; This library is part of One-on-One Emacs, a collection of=0A= ;; libraries that try to make Emacs more frame-oriented and less=0A= ;; window-oriented.=0A= ;;=0A= ;; This library sets up Emacs to use multiple frames: individual=0A= ;; frames are used, by default, instead of Emacs windows. That is,=0A= ;; the default is to use a frame for each Emacs window: one window on=0A= ;; one frame.=0A= ;;=0A= ;; You can configure each of the frames defined here.=0A= ;;=0A= ;; Default properties are defined here for normal frames and=0A= ;; "special" frames, which show "special-display buffers" (see Emacs=0A= ;; manual for info on such frames).=0A= ;;=0A= ;; In addition, these user options control the creation of three=0A= ;; separate, specialized frames:=0A= ;;=0A= ;; - `1on1-*Help*-frame-flag' - *Help* buffer frame=0A= ;; - `1on1-*Completions*-frame-flag' - *Completions* buffer frame=0A= ;; - `1on1-minibuffer-frame-flag' - minibuffer frame=0A= ;;=0A= ;; Buffers *Help* and *Completions* are always displayed in their own=0A= ;; frames. In addition, if `1on1-*Help*-frame-flag' or=0A= ;; `1on1-*Completions*-frame-flag' is non-nil, then the *Help* or=0A= ;; *Completions* frame has a special (customizable) appearance.=0A= ;;=0A= ;; If `1on1-minibuffer-frame-flag' is non-nil (the default value),=0A= ;; then the minibuffer is shown in its own frame,=0A= ;; `1on1-minibuffer-frame'; this is the only frame to have a=0A= ;; minibuffer. If you customize `1on1-minibuffer-frame-flag' to nil,=0A= ;; then each frame will have its own minibuffer, as usual, and there=0A= ;; will be no standalone minibuffer frame.=0A= ;; =0A= ;; By default, if you use a standalone minibuffer frame, it is=0A= ;; automatically sized to the full width of your display and placed=0A= ;; at the bottom of the display. During minibuffer input, you can=0A= ;; use `1on1-fit-minibuffer-frame' (bind to `C-o') to resize its=0A= ;; height to fit the input text - the height is reset when inputting=0A= ;; is done. To help you perceive changes to different minibuffer=0A= ;; recursion levels, the background color of the minibuffer frame is=0A= ;; changed slightly with each recursion-depth change.=0A= ;;=0A= ;; This library is especially useful if used in combination with=0A= ;; One-on-One Emacs libraries `autofit-frame.el', which automatically=0A= ;; fits frames to their sole window, and `fit-frame.el', which lets=0A= ;; you fit a frame to its selected window manually. Library=0A= ;; `autofit-frame.el' uses library `fit-frame.el'.=0A= ;;=0A= ;; Because Emacs is not really designed to be frame-oriented, there=0A= ;; are many built-in and standard functions that produce=0A= ;; less-than-optimal results when frames, instead of windows, are the=0A= ;; default. In other One-on-One Emacs libraries, I have fixed most=0A= ;; of these built-in functions to play well with frames.=0A= ;;=0A= ;; For more information on One-on-One Emacs see=0A= ;; http://www.emacswiki.org/cgi-bin/wiki/OneOnOneEmacs.=0A= ;;=0A= ;; To use this library, put the following at the *END* of your init=0A= ;; file, `.emacs' (or `_emacs'). In particular, if your init file=0A= ;; contains a `custom-set-variables' expression, then the following=0A= ;; must appear *AFTER* that expression, in order for this to take=0A= ;; into account your customizations of any `1on1-' user options.=0A= ;;=0A= ;; (require 'oneonone)=0A= ;; (1on1-emacs)=0A= ;;=0A= ;; Initial frame: By default, the initial Emacs frame is like all=0A= ;; other normal (non-special-display) frames; that is,=0A= ;; `initial-frame-alist' effectively uses the frame properties=0A= ;; defined in `default-frame-alist'. If you would like the initial=0A= ;; frame to be different, set `default-frame-alist' to nil after=0A= ;; requiring `oneonone.el' but before executing `1on1-emacs':=0A= ;;=0A= ;; (require 'oneonone)=0A= ;; (setq default-frame-alist nil)=0A= ;; (setq initial-frame-alist '((background-color . "White"))); e.g.=0A= ;; (1on1-emacs)=0A= ;;=0A= ;; If you want the text cursor to change to a box when Emacs is idle,=0A= ;; then add this line also to your init file:=0A= ;;=0A= ;; (toggle-box-cursor-when-idle 1) ; Turn on box cursor when idle.=0A= ;;=0A= ;; Info and Customize frames: I recommend that you put the following=0A= ;; code in your init file, so that Info and Customize buffers will=0A= ;; display in their own frames. Which code to use depends on your=0A= ;; version of GNU Emacs.=0A= ;;=0A= ;; (cond ((< emacs-major-version 21)=0A= ;; (remove-hook 'same-window-buffer-names "*info*"))=0A= ;; ((=3D emacs-version 21)=0A= ;; (remove-hook 'same-window-buffer-names "*info*")=0A= ;; (remove-hook 'same-window-regexps "\\`\\*Customiz.*\\*\\'"))=0A= ;; (t=0A= ;; (remove-hook 'same-window-regexps = "\\*info\\*\\(\\|<[0-9]+>\\)")=0A= ;; (remove-hook 'same-window-regexps = "\\`\\*Customiz.*\\*\\'")))=0A= ;;=0A= ;; Recommended key bindings (requires library `fit-frame.el'):=0A= ;;=0A= ;; (define-key minibuffer-local-map "\C-o"=0A= ;; '1on1-fit-minibuffer-frame)=0A= ;; (define-key minibuffer-local-must-match-map "\C-o"=0A= ;; '1on1-fit-minibuffer-frame)=0A= ;; (define-key minibuffer-local-completion-map "\C-o"=0A= ;; '1on1-fit-minibuffer-frame)=0A= ;;=0A= ;;=0A= ;; Notes on user options defined here:=0A= ;; ---------------------------------=0A= ;;=0A= ;; Some user options are used here only as conveniences to define=0A= ;; frame-parameter alists. They are defined using `defvar', not=0A= ;; `defcustom', because you cannot use Customize to define them=0A= ;; independently of the alist user options they help to define. The=0A= ;; alists themselves are the variables to customize. If you want to=0A= ;; change the `defvar' variables individually and then use them to=0A= ;; set the alist variables, then use `setq', not Customize, to change=0A= ;; them, and restart Emacs for their changes to take effect.=0A= ;;=0A= ;; Changes to any user options defined here with `defcustom' will=0A= ;; take effect as soon as `1on1-emacs' is executed, so you can do=0A= ;; `M-x 1on1-emacs' to see their changes (no need to restart=0A= ;; Emacs).=0A= ;;=0A= ;; User options `1on1-color-minibuffer-frame-on-setup-increment' and=0A= ;; `1on1-color-minibuffer-frame-on-exit-increment' determine how much=0A= ;; to change the color of the minibuffer frame when the minibuffer is=0A= ;; entered and exitted. They are hue increments, and should be=0A= ;; opposite in sign. They should cancel each other out, so that the=0A= ;; color returns to what it was initially at any given=0A= ;; recursive-minibuffer depth. However, because of the way HSV and=0A= ;; RGB color-component conversion works, the best cancellation does=0A= ;; not occur when these have the same absolute value. And, how much=0A= ;; their absolute values should differ depends on that magnitude.=0A= ;; It's best to just set one of these to an increment you like, and=0A= ;; then fiddle with the other until they more or less cancel.=0A= ;;=0A= ;;=0A= ;; New functions and macros defined here (each has prefix `1on1-'):=0A= ;;=0A= ;; `box-cursor-when-idle', `change-cursor-on-input-method',=0A= ;; `change-cursor-on-overwrite/read-only',=0A= ;; `color-minibuffer-frame-on-exit',=0A= ;; `color-minibuffer-frame-on-setup',=0A= ;; `color-isearch-minibuffer-frame', `display-*Completions*-frame',=0A= ;; `display-*Help*-frame', `emacs', `fit-minibuffer-frame',=0A= ;; `flash-ding-minibuffer-frame', `increment-color-hue',=0A= ;; `minibuffer-prompt-end', `reset-minibuffer-frame',=0A= ;; `set-box-cursor-when-idle-interval', `set-cursor-type',=0A= ;; `set-minibuffer-frame-top/bottom', `set-minibuffer-frame-width',=0A= ;; `setup-minibuffer-frame-coloring',=0A= ;; `setup-mode-line'. `toggle-box-cursor-when-idle'.=0A= ;;=0A= ;; Customizable user options defined here (each has prefix `1on1-'):=0A= ;;=0A= ;; `*Completions*-frame-flag', `*Completions*-frame-at-right-flag',=0A= ;; `*Help*-frame-flag', `active-minibuffer-frame-background',=0A= ;; `active-mode-line-background',=0A= ;; `change-cursor-on-overwrite/read-only-flag',=0A= ;; `color-minibuffer-frame-on-exit-increment',=0A= ;; `color-minibuffer-frame-on-setup-increment',=0A= ;; `color-mode-line-flag', `completions-frame-background',=0A= ;; `completions-frame-mouse+cursor-color',=0A= ;; `completions-frame-width', `default-frame-alist',=0A= ;; `help-frame-background', `help-frame-mouse+cursor-color',=0A= ;; `inactive-minibuffer-frame-background',=0A= ;; `inactive-mode-line-background',=0A= ;; `isearch-minibuffer-frame-background', `minibuffer-frame-alist',=0A= ;; `minibuffer-frame-left', `minibuffer-frame-top/bottom',=0A= ;; `minibuffer-frame-width', `minibuffer-frame-width-percent',=0A= ;; `special-display-frame-alist'.=0A= ;;=0A= ;; Non-customizable user options defined here (prefix `1on1-'):=0A= ;;=0A= ;; `default-frame-background', `default-frame-cursor-color',=0A= ;; `default-frame-cursor-color-input-method',=0A= ;; `default-frame-cursor-type',=0A= ;; `default-frame-cursor-type-overwrite/read-only',=0A= ;; `default-frame-font', `default-frame-foreground',=0A= ;; `default-frame-menu-bar-lines', `default-frame-mouse-color',=0A= ;; `default-frame-size', `default-frame-upper-left-corner',=0A= ;; `default-special-frame-background',=0A= ;; `default-special-frame-cursor-color',=0A= ;; `default-special-frame-font',=0A= ;; `default-special-frame-foreground',=0A= ;; `default-special-frame-menu-bar-lines',=0A= ;; `default-special-frame-mouse-color',=0A= ;; `default-special-frame-size',=0A= ;; `default-special-frame-upper-left-corner',=0A= ;; `minibuffer-frame-background', `minibuffer-frame-cursor-color',=0A= ;; `minibuffer-frame-flag', `minibuffer-frame-font',=0A= ;; `minibuffer-frame-foreground', `minibuffer-frame-height',=0A= ;; `minibuffer-frame-mouse-color'.=0A= ;;=0A= ;; Other new variables defined here (each has prefix `1on1-'):=0A= ;;=0A= ;; `box-cursor-when-idle-p', `box-cursor-when-idle-interval',=0A= ;; `box-cursor-when-idle-timer', `last-cursor-type',=0A= ;; `minibuffer-frame'.=0A= ;;=0A= ;;=0A= ;; ***** NOTE: These EMACS PRIMITIVES have been REDEFINED HERE:=0A= ;;=0A= ;; `abort-recursive-edit', `top-level' -=0A= ;; Reset color of minibuffer frame to "inactive" color.=0A= ;;=0A= ;; `y-or-n-p' - Temporarily color minibuffer frame to "active" color.=0A= ;;=0A= ;;=0A= ;; Acknowledgements:=0A= ;;=0A= ;; The cursor-changing on input method and read-only was inspired by=0A= ;; Juri Linkov . Joe Casadonte =0A= ;; wrote a similar hook (`joc-cursor-type-set-hook'), which he got=0A= ;; from Steve Kemp...=0A= ;;=0A= ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;=0A= ;;=0A= ;;; Change log:=0A= ;;=0A= ;; 2007/12/05 dadams=0A= ;; 1on1-minibuffer-frame-left: Added :type.=0A= ;; 1on1-color-mode-line-flag, 1on1-minibuffer-frame-flag: defvar -> = defcustom.=0A= ;; 1on1-(minibuffer|(special-)default)-frame-*: Removed * doc-string = prefix.=0A= ;; 2007/11/22 dadams=0A= ;; Added: 1on1-reset-minibuffer-frame, 1on1-fit-minibuffer-frame,=0A= ;; 1on1-minibuffer-prompt-end. Recommend C-o key binding.=0A= ;; Use 1on1-reset-minibuffer-frame on minibuffer-exit-hook.=0A= ;; 2007/08/14 dadams=0A= ;; 1on1-emacs:=0A= ;; Add *Completions* to special-display-buffer-names even if=0A= ;; 1on1-*Completions*-frame-flag is nil, so minibuffer gets = focus.=0A= ;; Set w(in)32-grab-focus-on-raise to nil.=0A= ;; 1on1-display-*Completions*-frame:=0A= ;; Don't change mouse pointer unless 1on1-*Completions*-frame-flag.=0A= ;; 1on1-minibuffer-frame-background: Use std minibuffer-frame-alist = bg, if defined.=0A= ;; 2007/05/28 dadams=0A= ;; 1on1-display-*Completions*-frame:=0A= ;; Wrap zoom-frm-out in condition-case (hack for Emacs 23 problem = changing size).=0A= ;; 2007/03/10 dadams=0A= ;; Added: 1on1-completions-frame-width. Use it in 1on1-emacs.=0A= ;; 2007/02/08 dadams=0A= ;; Removed: ^L-appearance-vector.=0A= ;; 1on1-emacs: No longer change ^L appearance - use my library = pp-c-l.el to do that.=0A= ;; 2007/02/04 dadams=0A= ;; 1on1-emacs:=0A= ;; Initialize standard-display-table if nil (default is nil!). = Thx to FidelSalas.=0A= ;; 2006/12/27 dadams=0A= ;; 1on1-change-cursor-on-input-method: Respect = 1on1-change-cursor-on-input-method-flag=0A= ;; 2006/12/12 dadams=0A= ;; Added: 1on1-^L-appearance-vector.=0A= ;; 1on1-emacs: Use 1on1-^L-appearance-vector to set ^L appearance.=0A= ;; 2006/12/11 dadams=0A= ;; 1on1-set-minibuffer-frame-top/bottom: 2 chars up, not 1, to fit = Emacs 22 better.=0A= ;; 2006/10/28 dadams=0A= ;; 1on1-(in)active-minibuffer-frame-background,=0A= ;; 1on1-isearch-minibuffer-frame-background, = 1on1-(in)active-mode-line-background,=0A= ;; 1on1-(help|completions)-frame-background,=0A= ;; 1on1-(help|completions)-frame-mouse+cursor-color,=0A= ;; 1on1-default-frame-cursor-color(-input-method):=0A= ;; Changed :type to 'color for Emacs 21+.=0A= ;; 2006/09/14 dadams=0A= ;; Removed mode-line position enhancements - use new library = modeline-posn.el.=0A= ;; Removed: 1on1-color-mode-line-column-flag, = 1on1-mode-line-column-limit.=0A= ;; 2006/09/04 dadams=0A= ;; 1on1-box-cursor-when-idle-timer: Cancel beforehand, and cancel = after defining.=0A= ;; 1on1-toggle-box-cursor-when-idle:=0A= ;; Use 1on1-box-cursor-when-idle-off on pre-command-hook.=0A= ;; Don't read an event; just turn it on.=0A= ;; Added: 1on1-box-cursor-when-idle-off.=0A= ;; 2006/09/02 dadams=0A= ;; 1on1-toggle-box-cursor-when-idle: Corrected.=0A= ;; 2006/08/27 dadams=0A= ;; Added: 1on1-box-cursor-when-idle(-p|-interval|-timer), = 1on1-last-cursor-type,=0A= ;; (1on1-)toggle-box-cursor-when-idle, = 1on1-set-box-cursor-when-idle-interval.=0A= ;; 2006/08/13 dadams=0A= ;; defalias set-cursor-type to 1on1-set-cursor-type.=0A= ;; 2006/07/25 dadams=0A= ;; Added: 1on1-minibuffer-frame-left. Use in = 1on1-minibuffer-frame-alist.=0A= ;; 2006/03/31 dadams=0A= ;; 1on1-default-frame-alist:=0A= ;; Changed (left|right)-fringe code, to reflect Emacs 22 change.=0A= ;; 2006/03/17 dadams=0A= ;; Renamed:=0A= ;; 1on1-color-active-minibuffer-frame to = 1on1-color-minibuffer-frame-on-setup,=0A= ;; 1on1-color-inactive-minibuffer-frame to = 1on1-color-minibuffer-frame-on-exit.=0A= ;; 1on1-color-minibuffer-frame-on-setup:=0A= ;; Redefined so hue depends on minibuffer-depth.=0A= ;; 2006/03/14 dadams=0A= ;; 1on1-color-(in)active-minibuffer-frame: Change hue for each = minibuffer recursion.=0A= ;; Added: 1on1-increment-color-hue.=0A= ;; Require hexrgb.el=0A= ;; 2006/03/13 dadams=0A= ;; 1on1-color-inactive-minibuffer-frame:=0A= ;; Change color only when not in recursive minibuffer.=0A= ;; abort-recursive-edit: Change minibuffer color after, not before, = abort.=0A= ;; 2006/01/07 dadams=0A= ;; Added :link=0A= ;; 2005/12/14 dadams=0A= ;; Added: 1on1-*Completions*-frame-at-right-flag.=0A= ;; Use in 1on1-display-*Completions*-frame.=0A= ;; 2005/11/28 dadams=0A= ;; Added: 1on1-change-cursor-on-overwrite-flag,=0A= ;; 1on1-change-cursor-on-input-method-flag, = 1on1-default-frame-cursor-type,=0A= ;; 1on1-default-frame-cursor-type-overwrite, = 1on1-default-frame-cursor-color,=0A= ;; 1on1-default-frame-cursor-color-input-mode, = 1on1-change-cursor-on-overwrite,=0A= ;; 1on1-change-cursor-on-insert-mode, 1on1-set-cursor-type = (thanks to=0A= ;; Juri Linkov for the last three).=0A= ;; 1on1-emacs: Use 1on1-change-cursor-* in post-command-hook.=0A= ;; 1on1-mode-line-column-limit: Corrected custom group.=0A= ;; 2005/11/22 dadams=0A= ;; Added: 1on1-setup-mode-line, 1on1-mode-line-column-limit,=0A= ;; 1on1-color-mode-line(-column)-flag, = 1on1-(in)active-mode-line-background.=0A= ;; 2005/10/28 dadams=0A= ;; 1on1-display-*Completions*-frame: Zoom to smaller font.=0A= ;; 2005/07/31 dadams=0A= ;; 1on1-emacs: Do not set initial-frame-alist to default-frame-alist = (D. Reitter).=0A= ;; 2005/07/25 dadams=0A= ;; Added :prefix to defgroup.=0A= ;; 2005/07/17 dadams=0A= ;; Switched default colors for = 1on1-(in)active-minibuffer-frame-background,=0A= ;; so active is the brighter color. Change inactive to LightBlue.=0A= ;; 2005/06/01 dadams=0A= ;; Corrected typo that gave minibuffer frame a vertical scroll bar.=0A= ;; 2005/05/29 dadams=0A= ;; *-alist: Use values from standard alist variables, if available = (that is,=0A= ;; don't override user settings.)=0A= ;; 2005/05/28 dadams=0A= ;; Renamed: 1on1-separate-minibuffer-frame-flag -> = 1on1-minibuffer-frame-flag,=0A= ;; 1on1-separate-*Help*-frame-flag -> 1on1-*Help*-frame-flag,=0A= ;; 1on1-separate-*Completions*-frame-flag -> = 1on1-*Completions*-frame-flag.=0A= ;; Added: setup-minibuffer-frame-coloring.=0A= ;; Added info in doc strings about use of each variable = (restart/1on1-emacs).=0A= ;; Corrected 1on1-minibuffer-frame-alist and = 1on1-special-display-frame-alist=0A= ;; for menu-bar-lines (nil).=0A= ;; 1on1-set-minibuffer-frame-top/bottom: Rewrote with = modify-frame-parameters.=0A= ;; 1on1-emacs:=0A= ;; Make sensitive to any changes to = 1on1-*[Help|Completions]*-frame-flag.=0A= ;; Move defcustom's, defvar's, and defun's outside 1on1-emacs.=0A= ;; If 1on1-minibuffer-frame already exists, just modify it.=0A= ;; Don't step on other parameters in standard alists; just append = new values.=0A= ;; 2005/05/23 dadams=0A= ;; Changed some individual frame-parameter variables from defcustom = to defvar.=0A= ;; Left them as user options, however, so you can change them with=0A= ;; set-variable before loading oneonone.el.=0A= ;; Renamed:=0A= ;; 1on1-upper-left-frame-corner-default ->=0A= ;; 1on1-default-frame-upper-left-corner=0A= ;; 1on1-default-special-display-frame-size ->=0A= ;; 1on1-default-special-frame-size=0A= ;; 1on1-upper-left-special-display-frame-corner-default ->=0A= ;; 1on1-default-special-frame-upper-left-corner=0A= ;; Split 1on1-menu-bar-lines into: = 1on1-default-special-frame-menu-bar-lines,=0A= ;; 1on1-default-frame-menu-bar-lines=0A= ;; 2005/05/18 dadams=0A= ;; Fixed typo: "oneoneone" -> "oneonone".=0A= ;; 2005/05/17 dadams=0A= ;; Updated to work with Emacs 22.x.=0A= ;; 2005/05/09 dadams=0A= ;; Major reorganization/rewrite. Created, from previous version = setup-frames.el.=0A= ;; Added prefix "1on1-".=0A= ;; Encapsulated stuff in new command 1on1-emacs.=0A= ;; 2005/01/29 dadams=0A= ;; 1on1-default-frame-font: Fixed bug - misplaced parens, so no good = if not Windows.=0A= ;; 2005/01/19 dadams=0A= ;; Use defcustom now.=0A= ;; Removed (put ... 'variable-interactive...).=0A= ;; 1on1-minibuffer-frame-top/bottom: Must be an integer (for = set-frame-position).=0A= ;; 2004/12/18 dadams=0A= ;; Bind after-make-frame-functions to nil when create = 1on1-minibuffer-frame.=0A= ;; 2004/11/26 dadams=0A= ;; Removed ;;;###autoload's.=0A= ;; 2004/11/20 dadams=0A= ;; Refined to deal with Emacs 21 < 21.3.50 (soon to be 22.x)=0A= ;; 2004/10/01 dadams=0A= ;; Ensure loaded before compile.=0A= ;; No fringe.=0A= ;; Remove *info* and *Customiz.* buffers from `same-window-regexps'=0A= ;; 2004/09/21 dadams=0A= ;; Updated to work with Emacs 21 (and Emacs 20).=0A= ;; 2004/03/19 dadams=0A= ;; 1on1-minibuffer-frame-width -> 1on1-set-minibuffer-frame-width.=0A= ;; added 1on1-set-minibuffer-frame-top/bottom.=0A= ;; 2001/01/05 dadams=0A= ;; 1. 1on1-minibuffer-frame-width: Use 1on1-minibuffer-frame arg for = frame-char-width.=0A= ;; 2. Don't define width when initially set = 1on1-minibuffer-frame-alist. Instead,=0A= ;; use set-frame-width afterward, so 1on1-minibuffer-frame-width = uses correct=0A= ;; character size.=0A= ;; 2001/01/05 dadams=0A= ;; 1. These vars no longer user options (interactively changeable):=0A= ;; 1on1-completions-frame-background, = 1on1-completions-frame-mouse+cursor-color,=0A= ;; 1on1-help-frame-background, 1on1-help-frame-mouse+cursor-color,=0A= ;; 1on1-minibuffer-frame-cursor-color, 1on1-minibuffer-frame-font,=0A= ;; 1on1-minibuffer-frame-foreground, 1on1-minibuffer-frame-height,=0A= ;; 1on1-minibuffer-frame-mouse-color, = 1on1-minibuffer-frame-top/bottom,=0A= ;; 1on1-minibuffer-frame-width.=0A= ;; 2. Added: 1on1-minibuffer-frame-width (function),=0A= ;; 1on1-minibuffer-frame-width-percent (var).=0A= ;; 3. Changed var 1on1-minibuffer-frame-width to nil default (now = use *-percent).=0A= ;; 2000/09/27 dadams=0A= ;; 1. Added: 1on1-display-*Completions*-frame, = 1on1-display-*Help*-frame.=0A= ;; 2. *Help* & *Completions* frames not created here. Instead, use=0A= ;; special-display-buffer-names & display-*-frame fns to define = them.=0A= ;; 3. Added: top-level, abort-recursive-edit.=0A= ;; 1999/08/24 dadams=0A= ;; 1. Windows: win32-grab-focus-on-raise =3D nil.=0A= ;; 2. 1on1-default-frame-font different if Windows.=0A= ;; 3. Added: 1on1-separate-minibuffer-frame-flag, = 1on1-menu-bar-lines,=0A= ;; 1on1-upper-left-frame-corner-default, 1on1-default-frame-size,=0A= ;; 1on1-upper-left-special-display-frame-corner-default,=0A= ;; 1on1-default-special-display-frame-size, = 1on1-default-special-frame-foreground,=0A= ;; 1on1-default-special-frame-background, = 1on1-default-special-frame-font,=0A= ;; 1on1-default-special-frame-mouse-color, = 1on1-default-special-frame-cursor-color.=0A= ;; 4. Use new vars to define default-frame-alist, = special-display-frame-alist.=0A= ;; 5. Only create built-in frames if = 1on1-separate-minibuffer-frame-flag.=0A= ;; 6. Protected refs to x-* vars.=0A= ;;=0A= ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;=0A= ;;=0A= ;; This program is free software; you can redistribute it and/or modify=0A= ;; it under the terms of the GNU General Public License as published by=0A= ;; the Free Software Foundation; either version 2, or (at your option)=0A= ;; any later version.=0A= =0A= ;; This program is distributed in the hope that it will be useful,=0A= ;; but WITHOUT ANY WARRANTY; without even the implied warranty of=0A= ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the=0A= ;; GNU General Public License for more details.=0A= =0A= ;; You should have received a copy of the GNU General Public License=0A= ;; along with this program; see the file COPYING. If not, write to=0A= ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth=0A= ;; Floor, Boston, MA 02110-1301, USA.=0A= ;;=0A= ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;=0A= ;;=0A= ;;; Code:=0A= =0A= (eval-and-compile (require 'cl)) ;; remove-if (plus, for Emacs < 20, = when, unless)=0A= =0A= (require 'frame-cmds nil t) ;; (no error if not found): rename-frame=0A= (require 'files+ nil t) ;; (no error if not found): = switch-to-buffer-other-frame=0A= (require 'zoom-frm nil t) ;; (no error if not found): zoom-frm-out=0A= (require 'hexrgb) ;; hexrgb-color-values-to-hex, hexrgb-hsv-to-rgb, = hexrgb-rgb-to-hsv=0A= =0A= =0A= ;; Ensure that this is loaded before compiling it.=0A= (provide 'oneonone)=0A= (require 'oneonone)=0A= =0A= =0A= ;; To quiet the byte compiler=0A= (unless (> emacs-major-version 21)=0A= (defvar x-pointer-box-spiral)=0A= (defvar x-pointer-xterm))=0A= =0A= ;;;;;;;;;;;;;;;;;;;;;;;;=0A= =0A= =0A= (defgroup One-On-One nil=0A= "Options to define initial frame configuration."=0A= :prefix "1on1-" :group 'frames=0A= :link `(url-link :tag "Send Bug Report"=0A= ,(concat "mailto:" "drew.adams" "@" "oracle" ".com?subject=3D\=0A= oneonone.el bug: \=0A= &body=3DDescribe bug here, starting with `emacs -q'. \=0A= Don't forget to mention your Emacs and library versions."))=0A= :link '(url-link :tag "Other Libraries by Drew"=0A= "http://www.emacswiki.org/cgi-bin/wiki/DrewsElispLibraries")=0A= :link '(url-link :tag "Download" = "http://www.emacswiki.org/cgi-bin/wiki/oneonone.el")=0A= :link '(url-link :tag "Description"=0A= "http://www.emacswiki.org/cgi-bin/wiki/OneOnOneEmacs")=0A= :link '(emacs-commentary-link :tag "Commentary" "oneonone")=0A= )=0A= =0C=0A= =0A= =0A= ;;; Minibuffer frame: ********************************=0A= ;;;=0A= (defvar 1on1-minibuffer-frame nil=0A= "Minibuffer-only frame used by One-on-One Emacs.=0A= Note: This is not used if `1on1-minibuffer-frame-flag' is nil.")=0A= =0A= (defcustom 1on1-minibuffer-frame-flag t=0A= "*Non-nil means use a separate, specialized frame for the minibuffer.=0A= If you change this variable, you will need to restart Emacs for it to=0A= take effect."=0A= :type 'boolean :group 'One-On-One)=0A= =0A= (defvar 1on1-minibuffer-frame-foreground "Red"=0A= "Default foreground color for the minibuffer frame.=0A= =0A= Note: This is not used if `1on1-minibuffer-frame-flag' is nil.=0A= =0A= This is used only to define the standard value of=0A= `1on1-minibuffer-frame-alist'. Customize that variable, not this one.=0A= If you change this variable, you will need to restart Emacs for it to=0A= take effect.")=0A= =0A= (defvar 1on1-minibuffer-frame-background=0A= (or (cdr (assq 'background-color minibuffer-frame-alist)) "LightBlue")=0A= "Initial color of the `1on1-minibuffer-frame' background.=0A= =0A= Note: This is not used if `1on1-minibuffer-frame-flag' is nil.=0A= =0A= This is used only to define the standard value of=0A= `1on1-minibuffer-frame-alist'. Customize that variable, not this one.=0A= If you change this variable, you will need to restart Emacs for it to=0A= take effect.")=0A= =0A= (defcustom 1on1-active-minibuffer-frame-background "PaleGoldenrod"=0A= "*The color of the `1on1-minibuffer-frame' when it is active.=0A= =0A= Note: This is not used if `1on1-minibuffer-frame-flag' is nil."=0A= :type (if (>=3D emacs-major-version 21) 'color 'string) :group = 'One-On-One)=0A= =0A= (defcustom 1on1-inactive-minibuffer-frame-background = 1on1-minibuffer-frame-background=0A= "*The color of the `1on1-minibuffer-frame' when it is inactive.=0A= =0A= Note: This is not used if `1on1-minibuffer-frame-flag' is nil."=0A= :type (if (>=3D emacs-major-version 21) 'color 'string) :group = 'One-On-One)=0A= =0A= (defcustom 1on1-isearch-minibuffer-frame-background "bisque"=0A= "*Color of the `1on1-minibuffer-frame' when `isearch' is active.=0A= See `1on1-color-isearch-minibuffer-frame'.=0A= =0A= Note: This is not used if `1on1-minibuffer-frame-flag' is nil."=0A= :type (if (>=3D emacs-major-version 21) 'color 'string) :group = 'One-On-One)=0A= =0A= (defcustom 1on1-color-mode-line-flag t=0A= "*Non-nil means use `1on1-(in)active-mode-line-background'.=0A= If you change this variable, you will need to restart Emacs for it to=0A= take effect."=0A= :type 'boolean :group 'One-On-One)=0A= =0A= (defcustom 1on1-color-minibuffer-frame-on-exit-increment 5=0A= "Increment to change minibuffer-frame hue when minibuffer is exited.=0A= This should be opposite in sign to=0A= `1on1-color-minibuffer-frame-on-setup-increment.'"=0A= :type 'integer :group 'One-On-One)=0A= =0A= (defcustom 1on1-color-minibuffer-frame-on-setup-increment -10=0A= "Increment to change minibuffer-frame hue when minibuffer is entered.=0A= This should be opposite in sign to=0A= `1on1-color-minibuffer-frame-on-exit-increment.'"=0A= :type 'integer :group 'One-On-One)=0A= =0A= (defcustom 1on1-active-mode-line-background = 1on1-active-minibuffer-frame-background=0A= "*The color of the mode-line when it is active.=0A= Note: This is not used if `1on1-color-mode-line-flag' is nil."=0A= :type (if (>=3D emacs-major-version 21) 'color 'string) :group = 'One-On-One)=0A= =0A= (defcustom 1on1-inactive-mode-line-background "LightGray"=0A= "*The color of the mode-line when it is inactive.=0A= Note: This is not used if `1on1-color-mode-line-flag' is nil."=0A= :type (if (>=3D emacs-major-version 21) 'color 'string) :group = 'One-On-One)=0A= =0A= (defvar 1on1-minibuffer-frame-font=0A= (if (eq system-type 'windows-nt)=0A= "-*-Lucida Console-normal-r-*-*-14-112-96-96-c-*-iso8859-1"=0A= ;;;;;;;"-*-Lucida Console-normal-r-*-*-15-*-*-*-c-*-*-ansi-"=0A= "-Misc-Fixed-Medium-R-Normal--15-140-75-75-C-90-ISO8859-1")=0A= "Default font for the minibuffer frame.=0A= =0A= Note: This is not used if `1on1-minibuffer-frame-flag' is nil.=0A= =0A= This is used only to define the standard value of=0A= `1on1-minibuffer-frame-alist'. Customize that variable, not this one.=0A= If you change this variable, you will need to restart Emacs for it to=0A= take effect.")=0A= =0A= (defvar 1on1-minibuffer-frame-mouse-color "Black"=0A= "Default mouse color for the minibuffer frame.=0A= =0A= Note: This is not used if `1on1-minibuffer-frame-flag' is nil.=0A= =0A= This is used only to define the standard value of=0A= `1on1-minibuffer-frame-alist'. Customize that variable, not this one.=0A= If you change this variable, you will need to restart Emacs for it to=0A= take effect.")=0A= =0A= (defvar 1on1-minibuffer-frame-cursor-color "Black"=0A= "Default text cursor color for the minibuffer frame.=0A= =0A= Note: This is not used if `1on1-minibuffer-frame-flag' is nil.=0A= =0A= This is used only to define the standard value of=0A= `1on1-minibuffer-frame-alist'. Customize that variable, not this one.=0A= If you change this variable, you will need to restart Emacs for it to=0A= take effect.")=0A= =0A= (defvar 1on1-minibuffer-frame-height 2=0A= "Height of minibuffer frame, in characters.=0A= =0A= Note: This is not used if `1on1-minibuffer-frame-flag' is nil.=0A= =0A= This is used only to define the standard value of=0A= `1on1-minibuffer-frame-alist'. Customize that variable, not this one.=0A= If you change this variable, you will need to restart Emacs for it to=0A= take effect.")=0A= =0A= (defcustom 1on1-minibuffer-frame-left 0=0A= "*Position of left edge of minibuffer frame, in pixels.=0A= An integer. If negative, then the position is that of the frame=0A= bottom relative to the screen right (not left) edge.=0A= =0A= See `default-frame-alist' for an explanation of frame parameters.=0A= =0A= Note: This is not used if `1on1-minibuffer-frame-flag' is nil.=0A= =0A= If you customize this variable, you will need to rerun `1on1-emacs'=0A= for the new value to take effect."=0A= :type 'integer :group 'One-On-One)=0A= =0A= (defcustom 1on1-minibuffer-frame-top/bottom nil=0A= "*Position of top (or bottom) of minibuffer frame, in pixels.=0A= If nil, function `1on1-set-minibuffer-frame-top/bottom' will position=0A= minibuffer at bottom of display.=0A= =0A= An integer. If negative, then the position is that of the frame=0A= bottom relative to the screen bottom.=0A= =0A= See `default-frame-alist' for an explanation of frame parameters.=0A= =0A= Note: This is not used if `1on1-minibuffer-frame-flag' is nil.=0A= =0A= If you customize this variable, you will need to rerun `1on1-emacs'=0A= for the new value to take effect."=0A= :type '(choice (const :tag "Use function = `1on1-set-minibuffer-frame-top/bottom'" nil)=0A= (integer :tag "Pixels from top (>=3D 0) or bottom (< = 0)" :value 0))=0A= :group 'One-On-One)=0A= =0A= (defcustom 1on1-minibuffer-frame-width nil=0A= "Width, in characters, for minibuffer frame.=0A= If nil, then function `1on1-set-minibuffer-frame-width' is used instead.=0A= =0A= Note: This is not used if `1on1-minibuffer-frame-flag' is nil.=0A= =0A= If you customize this variable, you will need to rerun `1on1-emacs'=0A= for the new value to take effect."=0A= :type '(choice (const :tag "Use function = `1on1-set-minibuffer-frame-width'" nil)=0A= (integer :tag "Width, in characters, for minibuffer = frame" :value 0))=0A= :group 'One-On-One)=0A= =0A= (defcustom 1on1-minibuffer-frame-width-percent 100=0A= "Max percent of the total display width to give to minibuffer frame.=0A= See function `1on1-set-minibuffer-frame-width'.=0A= =0A= Note: This is not used if `1on1-minibuffer-frame-flag' is nil.=0A= =0A= If you customize this variable, you will need to rerun `1on1-emacs'=0A= for the new value to take effect."=0A= :type 'integer :group 'One-On-One)=0A= =0A= ;; Use values from the standard list, when available. However, we have = no way of=0A= ;; distinguishing values predefined in vanilla Emacs from user settings.=0A= (defcustom 1on1-minibuffer-frame-alist=0A= (list=0A= (or (assq 'foreground-color minibuffer-frame-alist)=0A= (cons 'foreground-color 1on1-minibuffer-frame-foreground))=0A= (or (assq 'background-color minibuffer-frame-alist)=0A= (cons 'background-color 1on1-minibuffer-frame-background))=0A= (or (assq 'font minibuffer-frame-alist)=0A= (cons 'font 1on1-minibuffer-frame-font))=0A= (or (assq 'mouse-color minibuffer-frame-alist)=0A= (cons 'mouse-color 1on1-minibuffer-frame-mouse-color))=0A= (or (assq 'cursor-color minibuffer-frame-alist)=0A= (cons 'cursor-color 1on1-minibuffer-frame-cursor-color))=0A= (or (assq 'menu-bar-lines minibuffer-frame-alist)=0A= (cons 'menu-bar-lines nil))=0A= (or (assq 'left minibuffer-frame-alist)=0A= (cons 'left 1on1-minibuffer-frame-left))=0A= (or (assq 'height minibuffer-frame-alist)=0A= (cons 'height 1on1-minibuffer-frame-height))=0A= (or (assq 'icon-type minibuffer-frame-alist)=0A= (cons 'icon-type (< emacs-major-version 21))) ; `t' for Emacs 21 = too?=0A= (or (assq 'minibuffer minibuffer-frame-alist)=0A= (cons 'minibuffer 'only))=0A= (or (assq 'user-position minibuffer-frame-alist)=0A= (cons 'user-position t))=0A= (or (assq 'vertical-scroll-bars minibuffer-frame-alist) ; No scroll = bar.=0A= (cons 'vertical-scroll-bars nil))=0A= (or (assq 'name minibuffer-frame-alist)=0A= (cons 'name "Emacs Minibuffer")))=0A= "Frame-parameter alist for the standalone minibuffer frame=0A= `1on1-minibuffer-frame'.=0A= =0A= Note: This is not used if `1on1-minibuffer-frame-flag' is nil.=0A= =0A= If you customize this variable, you will need to rerun `1on1-emacs'=0A= for the new value to take effect."=0A= ;; If we didn't need Emacs 20 compatibility, this could be:=0A= ;; :type '(alist :key-type symbol :value-type sexp)=0A= :type '(repeat (cons :format "%v" (symbol :tag "Frame Parameter") = (sexp :tag "Value")))=0A= :group 'One-On-One)=0A= =0C=0A= =0A= =0A= ;;; *Help* frame: ********************************=0A= ;;; Display of *Help* buffer in custom frame.=0A= ;;; Background, height, cursor and pointer colors.=0A= ;;;=0A= (defcustom 1on1-*Help*-frame-flag t=0A= "*Non-nil means use a special appearance for the *Help* frame.=0A= =0A= If you customize this variable, you will need to rerun `1on1-emacs'=0A= for the new value to take effect."=0A= :type 'boolean :group 'One-On-One)=0A= =0A= (defcustom 1on1-help-frame-background "Thistle"=0A= "Default background color for the *Help* buffer's frame.=0A= =0A= Note: This is not used if `1on1-*Help*-frame-flag' is nil.=0A= =0A= If you customize this variable, you will need to rerun `1on1-emacs'=0A= for the new value to take effect."=0A= :type (if (>=3D emacs-major-version 21) 'color 'string) :group = 'One-On-One)=0A= =0A= (defcustom 1on1-help-frame-mouse+cursor-color "Blue Violet"=0A= "Default color for cursor & pointer of *Help* frame.=0A= =0A= Note: This is not used if `1on1-*Help*-frame-flag' is nil.=0A= =0A= If you customize this variable, you will need to rerun `1on1-emacs'=0A= for the new value to take effect."=0A= :type (if (>=3D emacs-major-version 21) 'color 'string) :group = 'One-On-One)=0A= =0C=0A= =0A= =0A= ;;; *Completions* frame: ********************************=0A= ;;; Display of *Completion* buffer in custom frame.=0A= ;;; Background, height, cursor and pointer colors.=0A= ;;;=0A= (defcustom 1on1-*Completions*-frame-flag t=0A= "*Non-nil means use a special appearance for the *Completions* frame.=0A= =0A= If you customize this variable, you will need to rerun `1on1-emacs'=0A= for the new value to take effect."=0A= :type 'boolean :group 'One-On-One)=0A= =0A= (defcustom 1on1-*Completions*-frame-at-right-flag nil=0A= "*Non-nil means place *Completions* frame at right edge of display.=0A= This can be useful to make *Completions* more visible.=0A= This has no effect if `1on1-*Completions*-frame-flag' is nil."=0A= :type 'boolean :group 'One-On-One)=0A= =0A= (defcustom 1on1-completions-frame-background "LavenderBlush2"=0A= "Default background color for the *Completions* buffer's frame.=0A= =0A= Note: This is not used if `1on1-*Completions*-frame-flag' is nil.=0A= =0A= If you customize this variable, you will need to rerun `1on1-emacs'=0A= for the new value to take effect."=0A= :type (if (>=3D emacs-major-version 21) 'color 'string) :group = 'One-On-One)=0A= =0A= (defcustom 1on1-completions-frame-mouse+cursor-color "VioletRed"=0A= "Default color for cursor & pointer of *Completions* frame.=0A= =0A= Note: This is not used if `1on1-*Completions*-frame-flag' is nil.=0A= =0A= If you customize this variable, you will need to rerun `1on1-emacs'=0A= for the new value to take effect."=0A= :type (if (>=3D emacs-major-version 21) 'color 'string) :group = 'One-On-One)=0A= =0A= (defcustom 1on1-completions-frame-width 100=0A= "Width, in characters, for *Completions* frame.=0A= If this is nil, then the pertinent default frame width is used.=0A= =0A= Note: This is not used if `1on1-*Completions*-frame-flag' is nil.=0A= =0A= If you customize this variable, you will need to rerun `1on1-emacs'=0A= for the new value to take effect."=0A= :type 'integer :group 'One-On-One)=0A= =0C=0A= =0A= =0A= ;;; Default for normal frames: `1on1-default-frame-alist' = **************************=0A= ;;;=0A= (defvar 1on1-default-frame-foreground "Black"=0A= "Default foreground color for non-special frames.=0A= This is used only to define the standard value of=0A= `1on1-default-frame-alist'. Customize that variable, not this one.=0A= If you change this variable, you will need to restart Emacs for it to=0A= take effect.")=0A= =0A= (defvar 1on1-default-frame-background "LightBlue"=0A= "Default background color for non-special frames.=0A= This is used only to define the standard value of=0A= `1on1-default-frame-alist'. Customize that variable, not this one.=0A= If you change this variable, you will need to restart Emacs for it to=0A= take effect.")=0A= =0A= (defvar 1on1-default-frame-font=0A= (if (eq system-type 'windows-nt)=0A= "-*-Lucida Console-normal-r-*-*-14-112-96-96-c-*-iso8859-1"=0A= ;;;;;;"-*-Lucida Console-normal-r-*-*-15-*-*-*-c-*-*-ansi-"=0A= "-Misc-Fixed-Medium-R-Normal--15-140-75-75-C-90-ISO8859-1")=0A= "Default font for non-special frames.=0A= This is used only to define the standard value of=0A= `1on1-default-frame-alist'. Customize that variable, not this one.=0A= If you change this variable, you will need to restart Emacs for it to=0A= take effect.")=0A= =0A= (defvar 1on1-default-frame-mouse-color "Red"=0A= "Default mouse-pointer color for non-special frames.=0A= This is used only to define the standard value of=0A= `1on1-default-frame-alist'. Customize that variable, not this one.=0A= If you change this variable, you will need to restart Emacs for it to=0A= take effect.")=0A= =0A= (defcustom 1on1-change-cursor-on-input-method-flag t=0A= "*Non-nil means to use a different cursor when using an input method.=0A= If you customize this variable, you will need to rerun `1on1-emacs'=0A= for the new value to take effect."=0A= :type 'boolean :group 'One-On-One)=0A= =0A= (defcustom 1on1-default-frame-cursor-color "Red"=0A= "*Default text cursor color for non-special frames.=0A= If you customize this variable, you will need to rerun `1on1-emacs'=0A= for the new value to take effect. Furthermore, if=0A= `1on1-change-cursor-on-input-method-flag' is nil when you rerun=0A= `1on1-emacs', you will need to toggle that variable to non-nil (and=0A= back to nil, if that's the value you want). Otherwise, the new value=0A= will take effect only after you restart Emacs."=0A= :type (if (>=3D emacs-major-version 21) 'color 'string) :group = 'One-On-One)=0A= =0A= (defcustom 1on1-default-frame-cursor-color-input-method "Orange"=0A= "*Default cursor color for non-special frames if using an input method.=0A= This has no effect if `1on1-change-cursor-on-input-method-flag' is nil.=0A= If you customize this variable, you will need to rerun `1on1-emacs'=0A= for the new value to take effect."=0A= :type (if (>=3D emacs-major-version 21) 'color 'string) :group = 'One-On-One)=0A= =0A= (defcustom 1on1-change-cursor-on-overwrite/read-only-flag t=0A= "*Non-nil means use a different cursor when overwrite mode or = read-only.=0A= If you customize this variable, you will need to rerun `1on1-emacs'=0A= for the new value to take effect."=0A= :type 'boolean :group 'One-On-One)=0A= =0A= (defcustom 1on1-default-frame-cursor-type 'bar=0A= "*Default text cursor type for non-special frames.=0A= If you customize this variable, you will need to rerun `1on1-emacs'=0A= for the new value to take effect. Furthermore, if=0A= `1on1-change-cursor-on-overwrite/read-only-flag' is nil when you rerun=0A= `1on1-emacs', you will need to toggle that variable to non-nil (and=0A= back to nil, if that's the value you want). Otherwise, the new value=0A= will take effect only after you restart Emacs."=0A= :type 'symbol :group 'One-On-One)=0A= =0A= (defvar 1on1-last-cursor-type 1on1-default-frame-cursor-type "Saved last = cursor type.")=0A= =0A= (defcustom 1on1-default-frame-cursor-type-overwrite/read-only 'box=0A= "*Default text cursor type for overwrite mode or read-only buffer.=0A= This applies only to non-special frames. This has no effect if=0A= `1on1-change-cursor-on-overwrite/read-only-flag' is nil. If you=0A= customize this variable, you will need to rerun `1on1-emacs' for the=0A= new value to take effect."=0A= :type 'symbol :group 'One-On-One)=0A= =0A= (defvar 1on1-box-cursor-when-idle-p t=0A= "Non-nil means to use a box cursor whenever Emacs is idle.=0A= Do NOT change this yourself; instead, use = `\\[toggle-box-cursor-when-idle]'.")=0A= =0A= (defvar 1on1-box-cursor-when-idle-interval 2=0A= "Number of seconds to wait before changing cursor type to box.=0A= Do NOT change this yourself to change the wait period; instead, use=0A= `\\[1on1-set-box-cursor-when-idle-interval]'.")=0A= =0A= (defvar 1on1-box-cursor-when-idle-timer=0A= (progn ; Cancel to prevent duplication.=0A= (when (boundp '1on1-box-cursor-when-idle-timer)=0A= (cancel-timer 1on1-box-cursor-when-idle-timer))=0A= (run-with-idle-timer 1on1-box-cursor-when-idle-interval t = '1on1-box-cursor-when-idle))=0A= "Timer used to change the cursor to a box cursor when Emacs is idle.")=0A= =0A= ;; Turn it off, by default. You must use `toggle-box-cursor-when-idle' = to turn it on.=0A= (cancel-timer 1on1-box-cursor-when-idle-timer)=0A= =0A= (defvar 1on1-default-frame-menu-bar-lines 1=0A= "Number of lines used for the menu bar in non-special frames.=0A= This is used only to define the standard value of=0A= `1on1-default-frame-alist'. Customize that variable, not this one.=0A= If you change this variable, you will need to restart Emacs for it to=0A= take effect.")=0A= =0A= (defvar 1on1-default-frame-upper-left-corner '(0 . 0)=0A= "Position of upper left frame corner.=0A= A cons whose car is the distance from the top in pixels=0A= and whose cdr is the distance from the left in pixels.=0A= =0A= This is used only to define the standard value of=0A= `1on1-default-frame-alist'. Customize that variable, not this one.=0A= If you change this variable, you will need to restart Emacs for it to=0A= take effect.")=0A= =0A= (defvar 1on1-default-frame-size '(80 . 35)=0A= "Default frame size.=0A= A cons whose car is the frame width in pixels=0A= and whose cdr is the frame height in pixels.=0A= =0A= This is used only to define the standard value of=0A= `1on1-default-frame-alist'. Customize that variable, not this one.=0A= If you change this variable, you will need to restart Emacs for it to=0A= take effect.")=0A= =0A= ;; Use values from the standard list, when available. However, we have = no way of=0A= ;; distinguishing values predefined in vanilla Emacs from user settings.=0A= (defcustom 1on1-default-frame-alist=0A= (list=0A= (or (assq 'foreground-color default-frame-alist)=0A= (cons 'foreground-color 1on1-default-frame-foreground))=0A= (or (assq 'background-color default-frame-alist)=0A= (cons 'background-color 1on1-default-frame-background))=0A= (or (assq 'font default-frame-alist)=0A= (cons 'font 1on1-default-frame-font))=0A= (or (assq 'mouse-color default-frame-alist)=0A= (cons 'mouse-color 1on1-default-frame-mouse-color))=0A= (or (assq 'cursor-color default-frame-alist)=0A= (cons 'cursor-color 1on1-default-frame-cursor-color))=0A= (or (assq 'cursor-type default-frame-alist)=0A= (cons 'cursor-type 1on1-default-frame-cursor-type))=0A= (or (assq 'menu-bar-lines default-frame-alist)=0A= (cons 'menu-bar-lines 1on1-default-frame-menu-bar-lines))=0A= (or (assq 'top default-frame-alist)=0A= (cons 'top (car 1on1-default-frame-upper-left-corner)))=0A= (or (assq 'left default-frame-alist)=0A= (cons 'left (cdr 1on1-default-frame-upper-left-corner)))=0A= (or (assq 'width default-frame-alist)=0A= (cons 'width (car 1on1-default-frame-size)))=0A= (or (assq 'height default-frame-alist)=0A= (cons 'height (cdr 1on1-default-frame-size)))=0A= (or (assq 'minibuffer default-frame-alist)=0A= (cons 'minibuffer (not 1on1-minibuffer-frame-flag)))=0A= (or (assq 'user-position default-frame-alist)=0A= (cons 'user-position t))=0A= (or (assq 'vertical-scroll-bars default-frame-alist)=0A= (cons 'vertical-scroll-bars 'right))=0A= (or (assq 'icon-type default-frame-alist)=0A= (cons 'icon-type (< emacs-major-version 21))) ; `t' for Emacs 21 = too?=0A= (or (assq 'tool-bar-lines default-frame-alist)=0A= (cons 'tool-bar-lines 1)) ; Emacs 21+=0A= (if (cdr (assq 'left-fringe default-frame-alist))=0A= (assq 'left-fringe default-frame-alist)=0A= (cons 'left-fringe 0)) ; Emacs 21+=0A= (if (cdr (assq 'right-fringe default-frame-alist))=0A= (assq 'right-fringe default-frame-alist)=0A= (cons 'right-fringe 0)) ; Emacs 21+=0A= (or (assq 'fringe default-frame-alist)=0A= (cons 'fringe 0))) ; Emacs 21, but not 21.3.50 - = REMOVE after 22.x=0A= "Properties to be used for One-on-One Emacs `default-frame-alist'.=0A= If you customize this variable, you will need to rerun `1on1-emacs'=0A= for the new value to take effect."=0A= ;; If we didn't need Emacs 20 compatibility, this could be:=0A= ;; :type '(alist :key-type symbol :value-type sexp)=0A= :type '(repeat (cons :format "%v" (symbol :tag "Frame Parameter") = (sexp :tag "Value")))=0A= :group 'One-On-One)=0A= =0C=0A= =0A= =0A= ;;; Special-display frames: `1on1-special-display-frame-alist' = ************************=0A= ;;;=0A= (defvar 1on1-default-special-frame-foreground "Black"=0A= "Default foreground color for special display frames.=0A= =0A= This is used only to define the standard value of=0A= `1on1-special-display-frame-alist'. Customize that variable, not this=0A= one. If you change this variable, you will need to restart Emacs for=0A= it to take effect.")=0A= =0A= (defvar 1on1-default-special-frame-background "LightSteelBlue"=0A= "Default background color for special display frames.=0A= =0A= This is used only to define the standard value of=0A= `1on1-special-display-frame-alist'. Customize that variable, not this=0A= one. If you change this variable, you will need to restart Emacs for=0A= it to take effect.")=0A= =0A= (defvar 1on1-default-special-frame-font=0A= (if (eq system-type 'windows-nt)=0A= "-*-Lucida Console-normal-r-*-*-14-112-96-96-c-*-iso8859-1"=0A= ;;;;;;;;"-*-Lucida Console-normal-r-*-*-15-*-*-*-c-*-*-ansi-"=0A= "-Misc-Fixed-Medium-R-Normal--15-140-75-75-C-90-ISO8859-1")=0A= "Default font for special display frames.=0A= =0A= This is used only to define the standard value of=0A= `1on1-special-display-frame-alist'. Customize that variable, not this=0A= one. If you change this variable, you will need to restart Emacs for=0A= it to take effect.")=0A= =0A= (defvar 1on1-default-special-frame-mouse-color "Yellow"=0A= "Default mouse color for special display frames.=0A= =0A= This is used only to define the standard value of=0A= `1on1-special-display-frame-alist'. Customize that variable, not this=0A= one. If you change this variable, you will need to restart Emacs for=0A= it to take effect.")=0A= =0A= (defvar 1on1-default-special-frame-cursor-color "Yellow"=0A= "Default text cursor color for special display frames.=0A= =0A= This is used only to define the standard value of=0A= `1on1-special-display-frame-alist'. Customize that variable, not this=0A= one. If you change this variable, you will need to restart Emacs for=0A= it to take effect.")=0A= =0A= (defvar 1on1-default-special-frame-menu-bar-lines 1=0A= "Number of lines used for the menu bar of special display frames.=0A= =0A= This is used only to define the standard value of=0A= `1on1-special-display-frame-alist'. Customize that variable, not this=0A= one. If you change this variable, you will need to restart Emacs for=0A= it to take effect.")=0A= =0A= (defvar 1on1-default-special-frame-upper-left-corner '(0 . 0)=0A= "Position of upper left corner of special display frames.=0A= A cons whose car is the distance from the top in pixels=0A= and whose cdr is the distance from the left in pixels.=0A= =0A= This is used only to define the standard value of=0A= `1on1-special-display-frame-alist'. Customize that variable, not this=0A= one. If you change this variable, you will need to restart Emacs for=0A= it to take effect.")=0A= =0A= (defvar 1on1-default-special-frame-size '(80 . 20)=0A= "Default size of special display frames.=0A= A cons whose car is the frame width in pixels=0A= and whose cdr is the frame height in pixels.=0A= =0A= This is used only to define the standard value of=0A= `1on1-special-display-frame-alist'. Customize that variable, not this=0A= one. If you change this variable, you will need to restart Emacs for=0A= it to take effect.")=0A= =0A= ;; Use values from the standard list, when available. However, we have = no way of=0A= ;; distinguishing values predefined in vanilla Emacs from user settings.=0A= (defcustom 1on1-special-display-frame-alist=0A= (list=0A= (or (assq 'font special-display-frame-alist)=0A= (cons 'font 1on1-default-special-frame-font))=0A= (or (assq 'width special-display-frame-alist)=0A= (cons 'width (car 1on1-default-special-frame-size)))=0A= (or (assq 'height special-display-frame-alist)=0A= (cons 'height (cdr 1on1-default-special-frame-size)))=0A= (or (assq 'mouse-color special-display-frame-alist)=0A= (cons 'mouse-color 1on1-default-special-frame-mouse-color))=0A= (or (assq 'cursor-color special-display-frame-alist)=0A= (cons 'cursor-color 1on1-default-special-frame-cursor-color))=0A= (or (assq 'menu-bar-lines special-display-frame-alist)=0A= (cons 'menu-bar-lines 1on1-default-special-frame-menu-bar-lines))=0A= (or (assq 'foreground-color special-display-frame-alist)=0A= (cons 'foreground-color 1on1-default-special-frame-foreground))=0A= (or (assq 'background-color special-display-frame-alist)=0A= (cons 'background-color 1on1-default-special-frame-background))=0A= (or (assq 'top special-display-frame-alist)=0A= (cons 'top (car 1on1-default-special-frame-upper-left-corner)))=0A= (or (assq 'left special-display-frame-alist)=0A= (cons 'left (cdr 1on1-default-special-frame-upper-left-corner)))=0A= (or (assq 'unsplittable special-display-frame-alist)=0A= (cons 'unsplittable t))=0A= (or (assq 'user-position special-display-frame-alist)=0A= (cons 'user-position t))=0A= (or (assq 'vertical-scroll-bars special-display-frame-alist)=0A= (cons 'vertical-scroll-bars 'right)))=0A= "Properties to be used for One-on-One `special-display-frame-alist'.=0A= If you customize this variable, you will need to rerun `1on1-emacs'=0A= for the new value to take effect."=0A= ;; If we didn't need Emacs 20 compatibility, this could be:=0A= ;; :type '(alist :key-type symbol :value-type sexp)=0A= :type '(repeat (cons :format "%v" (symbol :tag "Frame Parameter") = (sexp :tag "Value")))=0A= :group 'One-On-One)=0A= =0C=0A= =0A= =0A= ;;; Main command ***************************************=0A= ;;;=0A= ;;;###autoload=0A= (defun 1on1-emacs ()=0A= "One-on-One Emacs setup.=0A= Use `1on1-default-frame-alist' and `1on1-special-display-frame-alist'.=0A= =0A= If `1on1-minibuffer-frame-flag' is non-nil, then create=0A= minibuffer-only frame, `1on1-minibuffer-frame', using=0A= `1on1-minibuffer-frame-alist'.=0A= =0A= If `1on1-separate-minibuffer-*Help*-flag' is non-nil, then use=0A= special frame for *Help* buffer.=0A= =0A= If `1on1-separate-minibuffer-*Completions*-flag' is non-nil, then=0A= use special frame for *Completions* buffer."=0A= (interactive)=0A= (setq default-frame-alist (append 1on1-default-frame-alist = default-frame-alist)=0A= special-display-frame-alist (append = 1on1-special-display-frame-alist=0A= special-display-frame-alist))=0A= =0A= ;; *Help* frame=0A= (if 1on1-*Help*-frame-flag=0A= (add-to-list=0A= 'special-display-buffer-names=0A= (list "*Help*" '1on1-display-*Help*-frame=0A= (list (cons 'background-color 1on1-help-frame-background)=0A= (cons 'mouse-color 1on1-help-frame-mouse+cursor-color)=0A= (cons 'cursor-color = 1on1-help-frame-mouse+cursor-color)=0A= '(height . 40))))=0A= (setq special-display-buffer-names=0A= (remove-if (lambda (elt) (equal "*Help*" (car elt)))=0A= special-display-buffer-names)))=0A= =0A= ;; *Completions* frame=0A= ;; If `1on1-minibuffer-frame-flag' is non-nil, then *Completions* = frame must be treated=0A= ;; specially, so that it gets focus from the minibuffer frame. This = is so, even if=0A= ;; `1on1-*Completions*-frame-flag' is nil.=0A= (if 1on1-minibuffer-frame-flag=0A= (if 1on1-*Completions*-frame-flag=0A= (add-to-list=0A= 'special-display-buffer-names=0A= `("*Completions*" 1on1-display-*Completions*-frame=0A= ((background-color ,@1on1-completions-frame-background)=0A= (mouse-color = ,@1on1-completions-frame-mouse+cursor-color)=0A= (cursor-color = ,@1on1-completions-frame-mouse+cursor-color)=0A= ,@(and 1on1-completions-frame-width=0A= `((width ,@1on1-completions-frame-width))))))=0A= (add-to-list 'special-display-buffer-names=0A= `("*Completions*" = 1on1-display-*Completions*-frame)))=0A= (setq special-display-buffer-names=0A= (remove-if (lambda (elt) (equal "*Completions*" (car elt)))=0A= special-display-buffer-names)))=0A= =0A= ;; Minibuffer frame=0A= (when 1on1-minibuffer-frame-flag=0A= ;; `display-buffer' (& `*-other-window' fns) will use separate = frames.=0A= (setq pop-up-frames t=0A= pop-up-frame-alist (append default-frame-alist = pop-up-frame-alist))=0A= =0A= ;; Set up `1on1-minibuffer-frame'.=0A= (setq minibuffer-frame-alist (append 1on1-minibuffer-frame-alist=0A= minibuffer-frame-alist))=0A= (if 1on1-minibuffer-frame=0A= (modify-frame-parameters 1on1-minibuffer-frame = 1on1-minibuffer-frame-alist)=0A= (setq 1on1-minibuffer-frame=0A= (let ((after-make-frame-functions nil)) ; E.g. inhibit = `fit-frame'.=0A= (make-frame 1on1-minibuffer-frame-alist))))=0A= =0A= ;; Resize and reposition it. If variable = `1on1-minibuffer-frame-width'=0A= ;; or `1on1-minibuffer-frame-top/bottom' is nil, calculate = automatically.=0A= (1on1-set-minibuffer-frame-width)=0A= (1on1-set-minibuffer-frame-top/bottom)=0A= =0A= ;; Rename minibuffer frame. (`rename-frame' is defined in = `frame-cmds.el'.)=0A= (when (fboundp 'rename-frame)=0A= (rename-frame 1on1-minibuffer-frame "Emacs minibuffer = \=0A= show/hide: hold CTRL + click in window"))=0A= (setq minibuffer-auto-raise t)=0A= ;; Background colors of minibuffer frame: 3 states=0A= (add-hook 'isearch-mode-hook '1on1-color-isearch-minibuffer-frame)=0A= (add-hook 'isearch-mode-end-hook = '1on1-color-minibuffer-frame-on-exit)=0A= (add-hook 'minibuffer-setup-hook = '1on1-color-minibuffer-frame-on-setup)=0A= (add-hook 'minibuffer-exit-hook '1on1-color-minibuffer-frame-on-exit)=0A= ;; Redefine built-in fns so they color minibuffer frame.=0A= (1on1-setup-minibuffer-frame-coloring))=0A= =0A= ;; Hooks.=0A= (if 1on1-change-cursor-on-overwrite/read-only-flag=0A= (add-hook 'post-command-hook = '1on1-change-cursor-on-overwrite/read-only)=0A= (1on1-set-cursor-type 1on1-default-frame-cursor-type)=0A= (remove-hook 'post-command-hook = '1on1-change-cursor-on-overwrite/read-only))=0A= (if 1on1-change-cursor-on-input-method-flag=0A= (add-hook 'post-command-hook '1on1-change-cursor-on-input-method)=0A= (setq current-input-method nil)=0A= (1on1-change-cursor-on-input-method)=0A= (remove-hook 'post-command-hook '1on1-change-cursor-on-input-method))=0A= (add-hook 'minibuffer-exit-hook '1on1-reset-minibuffer-frame)=0A= =0A= (setq w32-grab-focus-on-raise nil=0A= win32-grab-focus-on-raise nil) ; older name=0A= (1on1-setup-mode-line))=0A= =0A= ;; This is inspired by code from Juri Linkov .=0A= (defun 1on1-change-cursor-on-input-method ()=0A= "Set cursor type depending on whether an input method is used or not."=0A= (when 1on1-change-cursor-on-input-method-flag=0A= (set-cursor-color=0A= (if current-input-method=0A= 1on1-default-frame-cursor-color-input-method=0A= (let ((bufname (buffer-name (current-buffer))))=0A= (cond=0A= ((string=3D "*Help*" bufname) = 1on1-help-frame-mouse+cursor-color)=0A= ((string=3D "*Completions*" bufname) = 1on1-completions-frame-mouse+cursor-color)=0A= ((eq 1on1-minibuffer-frame (selected-frame))=0A= 1on1-minibuffer-frame-cursor-color)=0A= ((special-display-p bufname) = 1on1-default-special-frame-cursor-color)=0A= (t 1on1-default-frame-cursor-color)))))))=0A= =0A= ;; This is from Juri Linkov , with read-only added.=0A= (defun 1on1-change-cursor-on-overwrite/read-only ()=0A= "Set cursor type differently for overwrite mode and read-only buffer.=0A= That is, use one cursor type for overwrite mode and read-only buffers,=0A= and another cursor type otherwise."=0A= (1on1-set-cursor-type (if (or buffer-read-only overwrite-mode)=0A= = 1on1-default-frame-cursor-type-overwrite/read-only=0A= 1on1-default-frame-cursor-type)))=0A= =0A= (unless (fboundp 'set-cursor-type) (defalias 'set-cursor-type = '1on1-set-cursor-type))=0A= ;; This is essentially from Juri Linkov .=0A= (defun 1on1-set-cursor-type (cursor-type)=0A= "Set the cursor type of the selected frame to CURSOR-TYPE.=0A= When called interactively, prompt for the type to use.=0A= To get the frame's current cursor type, use `frame-parameters'."=0A= (interactive=0A= (list (intern (completing-read "Cursor type: "=0A= (mapcar 'list '("box" "hollow" "bar" = "hbar" nil))))))=0A= (modify-frame-parameters (selected-frame) (list (cons 'cursor-type = cursor-type))))=0A= =0A= (defun 1on1-box-cursor-when-idle ()=0A= "Change the cursor to a box cursor when Emacs is idle."=0A= (let ((type (cdr (assoc 'cursor-type (frame-parameters)))))=0A= (unless (eq type 'box)=0A= (setq 1on1-last-cursor-type type)=0A= (1on1-set-cursor-type 'box)))) =0A= =0A= (defun 1on1-box-cursor-when-idle-off ()=0A= "Turn off changing the cursor to a box cursor when Emacs is idle."=0A= (when 1on1-last-cursor-type (1on1-set-cursor-type = 1on1-last-cursor-type)))=0A= =0A= (defalias 'toggle-box-cursor-when-idle '1on1-toggle-box-cursor-when-idle)=0A= (defun 1on1-toggle-box-cursor-when-idle (&optional arg)=0A= "Turn on or off automatically changing to a box cursor when idle.=0A= When on, the cursor is changed to a box whenever Emacs is idle.=0A= With prefix argument, turn on if ARG > 0; else turn off."=0A= (interactive "P")=0A= (setq 1on1-box-cursor-when-idle-p=0A= (if arg (> (prefix-numeric-value arg) 0) (not = 1on1-box-cursor-when-idle-p)))=0A= (cond (1on1-box-cursor-when-idle-p=0A= (timer-activate-when-idle 1on1-box-cursor-when-idle-timer)=0A= (add-hook 'pre-command-hook '1on1-box-cursor-when-idle-off)=0A= (message "Turned ON making cursor a box when Emacs is idle."))=0A= (t=0A= (cancel-timer 1on1-box-cursor-when-idle-timer)=0A= (remove-hook 'pre-command-hook '1on1-box-cursor-when-idle-off)=0A= (message "Turned OFF making cursor a box when Emacs is = idle."))))=0A= =0A= (defun 1on1-set-box-cursor-when-idle-interval (secs)=0A= "Set wait until automatically change to a box cursor when Emacs is = idle.=0A= Whenever Emacs is idle for this many seconds it will change the cursor=0A= to a box.=0A= =0A= To turn on or off automatically changing to a box cursor when idle,=0A= use `\\[toggle-box-cursor-when-idle]."=0A= (interactive=0A= "nSeconds to idle, before changing to a box cursor: ")=0A= (timer-set-idle-time 1on1-box-cursor-when-idle-timer=0A= (setq 1on1-box-cursor-when-idle-interval secs)=0A= t))=0A= =0A= (defun 1on1-display-*Help*-frame (buf &optional args)=0A= "Display *Help* buffer in its own frame.=0A= `special-display-function' is used to do the actual displaying.=0A= BUF and ARGS are the arguments to `special-display-function'."=0A= (let ((old-ptr-shape x-pointer-shape)=0A= return-window)=0A= (when (boundp 'x-pointer-xterm)=0A= (setq x-pointer-shape x-pointer-xterm))=0A= (setq return-window (select-window (funcall special-display-function = buf args)))=0A= (raise-frame)=0A= (setq x-pointer-shape old-ptr-shape)=0A= return-window))=0A= =0A= (defun 1on1-display-*Completions*-frame (buf &optional args)=0A= "Display *Completions* buffer in its own frame.=0A= `special-display-function' is used to do the actual displaying.=0A= Completion input events are redirected to `1on1-minibuffer-frame'.=0A= BUF and ARGS are the arguments to `special-display-function'."=0A= (let ((old-ptr-shape x-pointer-shape)=0A= return-window)=0A= (when (and 1on1-*Completions*-frame-flag (boundp = 'x-pointer-box-spiral))=0A= (setq x-pointer-shape x-pointer-box-spiral))=0A= (setq return-window (select-window (funcall special-display-function = buf args)))=0A= (when (fboundp 'zoom-frm-out)=0A= (condition-case nil (progn (zoom-frm-out) (zoom-frm-out)) ; In = `zoom-frm.el'.=0A= (error nil)))=0A= =0A= ;; We reposition frame this way, instead of binding = `special-display-frame-alist'=0A= ;; with this value, because `after-make-frame-functions' might = resize frame.=0A= (when 1on1-*Completions*-frame-at-right-flag=0A= (modify-frame-parameters=0A= (selected-frame) ; Hard-code 7 here - what does = it depend on?=0A= `((left . ,(- (x-display-pixel-width) (+ (frame-pixel-width) = 7))))))=0A= (raise-frame)=0A= (when (boundp '1on1-minibuffer-frame)=0A= (redirect-frame-focus (selected-frame) 1on1-minibuffer-frame))=0A= (when (and 1on1-*Completions*-frame-flag (boundp = 'x-pointer-box-spiral))=0A= (setq x-pointer-shape old-ptr-shape))=0A= return-window))=0A= =0A= (defun 1on1-set-minibuffer-frame-top/bottom ()=0A= "Set position of minibuffer frame.=0A= Use `1on1-minibuffer-frame-top/bottom' if non-nil.=0A= Else, place minibuffer at bottom of display."=0A= (when (boundp '1on1-minibuffer-frame)=0A= (modify-frame-parameters=0A= 1on1-minibuffer-frame=0A= `((top ,@ (or 1on1-minibuffer-frame-top/bottom=0A= (- (* 2 (frame-char-height = 1on1-minibuffer-frame)))))))))=0A= =0A= (defun 1on1-set-minibuffer-frame-width ()=0A= "Set width of minibuffer frame, in characters.=0A= Use `1on1-minibuffer-frame-width' if not nil.=0A= Else, set width relative to character size of `1on1-minibuffer-frame'=0A= and display size, and depending on=0A= `1on1-minibuffer-frame-width-percent':=0A= =0A= (/ (* 1on1-minibuffer-frame-width-percent (x-display-pixel-width))=0A= (* 100 (frame-char-width 1on1-minibuffer-frame)))"=0A= (when (boundp '1on1-minibuffer-frame)=0A= (set-frame-width=0A= 1on1-minibuffer-frame=0A= (or 1on1-minibuffer-frame-width=0A= (/ (* 1on1-minibuffer-frame-width-percent = (x-display-pixel-width))=0A= (* 100 (frame-char-width 1on1-minibuffer-frame)))))))=0A= =0A= (defun 1on1-color-minibuffer-frame-on-setup ()=0A= "Change background of minibuffer frame to reflect the minibuffer depth.=0A= Use this when increasing the minibuffer recursion depth."=0A= (when (boundp '1on1-minibuffer-frame)=0A= (save-window-excursion=0A= (select-frame 1on1-minibuffer-frame)=0A= (set-background-color 1on1-active-minibuffer-frame-background)=0A= (let ((count (minibuffer-depth)))=0A= (while (> count 1)=0A= (set-background-color (1on1-increment-color-hue ; Change bg = hue slightly.=0A= (frame-parameter nil 'background-color)=0A= = 1on1-color-minibuffer-frame-on-setup-increment))=0A= (setq count (1- count)))))))=0A= =0A= (defun 1on1-color-minibuffer-frame-on-exit ()=0A= "Change background of minibuffer frame to reflect the minibuffer depth.=0A= Use this when reducing the minibuffer recursion depth."=0A= (when (boundp '1on1-minibuffer-frame)=0A= (save-window-excursion=0A= (select-frame 1on1-minibuffer-frame)=0A= (if (< (minibuffer-depth) 2)=0A= (set-background-color = 1on1-inactive-minibuffer-frame-background)=0A= (set-background-color (1on1-increment-color-hue ; Change bg hue = slightly.=0A= (frame-parameter nil 'background-color)=0A= = 1on1-color-minibuffer-frame-on-exit-increment))))))=0A= =0A= ;; This is essentially a version of `doremi-increment-color-component' = for hue only.=0A= (defun 1on1-increment-color-hue (color increment)=0A= "Increase hue component of COLOR by INCREMENT."=0A= (unless (string-match "#" color) ; Convert color name to #hhh...=0A= (setq color (hexrgb-color-values-to-hex (x-color-values color))))=0A= ;; Convert RGB to HSV=0A= (let* ((rgb (x-color-values color))=0A= (red (/ (float (nth 0 rgb)) 65535.0)) ; Convert from 0-65535 = to 0.0-1.0=0A= (green (/ (float (nth 1 rgb)) 65535.0))=0A= (blue (/ (float (nth 2 rgb)) 65535.0))=0A= (hsv (hexrgb-rgb-to-hsv red green blue))=0A= (hue (nth 0 hsv))=0A= (saturation (nth 1 hsv))=0A= (value (nth 2 hsv)))=0A= (setq hue (+ hue (/ increment 100.0)))=0A= (when (> hue 1.0) (setq hue (1- hue)))=0A= (hexrgb-color-values-to-hex (mapcar (lambda (x) (floor (* x = 65535.0)))=0A= (hexrgb-hsv-to-rgb hue = saturation value)))))=0A= =0A= (defun 1on1-color-isearch-minibuffer-frame ()=0A= "Use `1on1-isearch-minibuffer-frame-background' for minibuffer."=0A= (and (boundp '1on1-minibuffer-frame)=0A= (save-window-excursion=0A= (select-frame 1on1-minibuffer-frame)=0A= (set-background-color=0A= ;; Can also try `x-defined-colors', defined in `x-win.el'.=0A= ;; It contains all colors currently supported by X windows.=0A= (if (x-color-defined-p = 1on1-isearch-minibuffer-frame-background)=0A= 1on1-isearch-minibuffer-frame-background=0A= "white")))))=0A= =0A= (defun 1on1-flash-ding-minibuffer-frame (&optional do-not-terminate)=0A= "Ring bell (`ding'), after flashing minibuffer frame, if relevant.=0A= Terminates any keyboard macro executing, unless arg DO-NOT-TERMINATE = non-nil."=0A= (flash-ding do-not-terminate (and (boundp '1on1-minibuffer-frame)=0A= 1on1-minibuffer-frame)))=0A= =0A= (defun 1on1-setup-minibuffer-frame-coloring ()=0A= "Redefine some built-in functions so they color the minibuffer frame.=0A= Functions redefined: `y-or-n-p', `top-level', `abort-recursive-exit'."=0A= =0A= (or (fboundp 'old-y-or-n-p)=0A= (fset 'old-y-or-n-p (symbol-function 'y-or-n-p)))=0A= =0A= ;; REPLACES ORIGINAL (built-in function):=0A= ;; Temporarily colors minibuffer frame to "active" color.=0A= ;;=0A= (defun y-or-n-p (prompt)=0A= "Ask user a \"y or n\" question. Return t if answer is \"y\".=0A= Takes one argument, which is the string to display to ask the question.=0A= It should end in a space; `y-or-n-p' adds `(y or n) ' to it.=0A= No confirmation of answer is requested; a single character is enough.=0A= Also accepts SPC to mean yes, or DEL to mean no."=0A= (1on1-color-minibuffer-frame-on-setup)=0A= (prog1 (old-y-or-n-p prompt) (1on1-color-minibuffer-frame-on-exit)))=0A= =0A= =0A= (or (fboundp 'old-top-level)=0A= (fset 'old-top-level (symbol-function 'top-level)))=0A= =0A= ;; REPLACES ORIGINAL (built-in function):=0A= ;; Resets color of minibuffer frame to "inactive" color.=0A= ;;=0A= (defun top-level ()=0A= "Exit all recursive editing levels."=0A= (interactive)=0A= (1on1-color-minibuffer-frame-on-exit)=0A= (old-top-level))=0A= =0A= =0A= (or (fboundp 'old-abort-recursive-edit)=0A= (fset 'old-abort-recursive-edit (symbol-function = 'abort-recursive-edit)))=0A= =0A= ;; REPLACES ORIGINAL (built-in function):=0A= ;; Resets color of minibuffer frame to "inactive" color.=0A= ;;=0A= (defun abort-recursive-edit ()=0A= "Abort command that requested this recursive edit or minibuffer = input."=0A= (interactive)=0A= (1on1-color-minibuffer-frame-on-exit)=0A= (old-abort-recursive-edit)))=0A= =0A= (defun 1on1-setup-mode-line ()=0A= "Set up mode-line faces."=0A= (when 1on1-color-mode-line-flag=0A= (set-face-background 'modeline 1on1-active-mode-line-background)=0A= (when (facep 'mode-line-inactive) ; Emacs 22=0A= (set-face-background 'mode-line-inactive = 1on1-inactive-mode-line-background))))=0A= =0A= (defun 1on1-reset-minibuffer-frame ()=0A= (when 1on1-minibuffer-frame=0A= (set-frame-size 1on1-minibuffer-frame=0A= (frame-width 1on1-minibuffer-frame)=0A= 1on1-minibuffer-frame-height)=0A= (1on1-set-minibuffer-frame-top/bottom)))=0A= =0A= ;; Bind this to some key in the minibuffer completion maps. I use `C-o'.=0A= ;;;###autoload=0A= (defun 1on1-fit-minibuffer-frame ()=0A= "Fit the standalone minibuffer frame height to its contents.=0A= Repeat to increase the height by 1.=0A= Bind this in minibuffer keymaps to a key such as `C-o' that you can=0A= use during minibuffer input."=0A= (interactive)=0A= (unless (require 'fit-frame nil t)=0A= (error "You need to load library `fit-frame.el' to use this = command"))=0A= ;; We could assume the minibuffer frame is `1on1-minibuffer-frame', = but we don't.=0A= (when (and (active-minibuffer-window)=0A= (save-selected-window=0A= (select-window (minibuffer-window))=0A= ;; We should be able to use just (one-window-p),=0A= ;; but an Emacs bug means we need this:=0A= (one-window-p nil 'selected-frame)))=0A= (let* ((frame (save-selected-window=0A= (select-window (minibuffer-window)) = (selected-frame)))=0A= (frame-height (frame-height frame)))=0A= (cond ((eq last-command this-command)=0A= (set-frame-height frame (1+ (frame-height frame)))=0A= (1on1-set-minibuffer-frame-top/bottom)=0A= (condition-case nil=0A= (scroll-down (frame-height frame))=0A= (error nil)))=0A= (t=0A= (let* ((beg (1on1-minibuffer-prompt-end))=0A= (frame-width (frame-width frame))=0A= (fit-frame-min-width frame-width)=0A= (window-min-width frame-width)=0A= (fit-frame-max-width frame-width)=0A= (fit-frame-empty-width frame-width)=0A= (fit-frame-empty-special-display-width frame-width)=0A= (fit-frame-min-height frame-height)=0A= (window-min-height frame-height)=0A= (fit-frame-empty-height frame-height)=0A= (fit-frame-empty-special-display-height = frame-height))=0A= (fit-frame frame)=0A= (when (>=3D emacs-major-version 21)=0A= (set-frame-height frame (1+ (frame-height frame)))) ; A = little extra.=0A= (1on1-set-minibuffer-frame-top/bottom)=0A= (condition-case nil (scroll-down (frame-height frame)) = (error nil))))))))=0A= =0A= (defun 1on1-minibuffer-prompt-end ()=0A= "Version of `minibuffer-prompt-end' that works for Emacs 20 and later."=0A= (if (fboundp 'minibuffer-prompt-end) (minibuffer-prompt-end) = (point-min)))=0A= =0A= ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;=0A= ;;; oneonone.el ends here=0A= ------=_NextPart_000_000B_01C8E19D.B15F7F80 Content-Type: application/octet-stream; name="hexrgb.el" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="hexrgb.el" ;;; hexrgb.el --- Functions to manipulate colors, including RGB hex = strings.=0A= ;;=0A= ;; Filename: hexrgb.el=0A= ;; Description: Functions to manipulate colors, including RGB hex = strings.=0A= ;; Author: Drew Adams=0A= ;; Maintainer: Drew Adams=0A= ;; Copyright (C) 2004-2008, Drew Adams, all rights reserved.=0A= ;; Created: Mon Sep 20 22:58:45 2004=0A= ;; Version: 21.0=0A= ;; Last-Updated: Tue Jan 01 13:37:31 2008 (-28800 Pacific Standard Time)=0A= ;; By: dradams=0A= ;; Update #: 540=0A= ;; URL: http://www.emacswiki.org/cgi-bin/wiki/hexrgb.el=0A= ;; Keywords: number, hex, rgb, color, background, frames, display=0A= ;; Compatibility: GNU Emacs 20.x, GNU Emacs 21.x, GNU Emacs 22.x=0A= ;;=0A= ;; Features that might be required by this library:=0A= ;;=0A= ;; None=0A= ;;=0A= ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;=0A= ;;=0A= ;;; Commentary:=0A= ;;=0A= ;; Functions to manipulate colors, including RGB hex strings.=0A= ;;=0A= ;; This library provides functions for converting between RGB (red,=0A= ;; green, blue) color components and HSV (hue, saturation, value)=0A= ;; color components. It helps you convert among Emacs color values=0A= ;; (whole numbers from 0 through 65535), RGB and HSV floating-point=0A= ;; components (0.0 through 1.0), Emacs color-name strings (such as=0A= ;; "blue"), and hex RGB color strings (such as "#FC43A7912").=0A= ;;=0A= ;; An RGB hex string, such as used as a frame `background-color'=0A= ;; property, is a string of 1 + (3 * n) characters, the first of=0A= ;; which is "#". The other characters are hexadecimal digits, in=0A= ;; three groups representing (from the left): red, green, and blue=0A= ;; hex codes.=0A= ;;=0A= ;; Constants defined here:=0A= ;;=0A= ;; `hexrgb-defined-colors', `hexrgb-defined-colors-alist'.=0A= ;;=0A= ;; Commands defined here:=0A= ;;=0A= ;; `hexrgb-blue', `hexrgb-complement', `hexrgb-green',=0A= ;; `hexrgb-hue', `hexrgb-read-color', `hexrgb-red',=0A= ;; `hexrgb-saturation', `hexrgb-value'.=0A= ;;=0A= ;; Non-interactive functions defined here:=0A= ;;=0A= ;; `hexrgb-approx-equal', `hexrgb-color-name-to-hex',=0A= ;; `hexrgb-color-values-to-hex', `hexrgb-color-value-to-float',=0A= ;; `hexrgb-float-to-color-value', `hexrgb-hex-char-to-integer',=0A= ;; `hexrgb-hex-to-color-values', `hexrgb-hex-to-hsv',=0A= ;; `hexrgb-hex-to-rgb', `hexrgb-hsv-to-hex', `hexrgb-hex-to-int',=0A= ;; `hexrgb-hsv-to-rgb', `hexrgb-increment-blue',=0A= ;; `hexrgb-increment-equal-rgb', `hexrgb-increment-green',=0A= ;; `hexrgb-increment-hex', `hexrgb-increment-red',=0A= ;; `hexrgb-int-to-hex', `hexrgb-rgb-hex-string-p',=0A= ;; `hexrgb-rgb-to-hex', `hexrgb-rgb-to-hsv'.=0A= ;;=0A= ;;=0A= ;; Add this to your initialization file (~/.emacs or ~/_emacs):=0A= ;;=0A= ;; (require 'hexrgb)=0A= ;;=0A= ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;=0A= ;;=0A= ;;; Change log:=0A= ;;=0A= ;; 2007/12/30 dadams=0A= ;; Added: hexrgb-hex-to-color-values.=0A= ;; 2007/10/20 dadams=0A= ;; hexrgb-read-color: Treat pseudo colors too (e.g. *point = foreground*).=0A= ;; 2007/01/21 dadams=0A= ;; hexrgb-read-color: Error if empty string (and not = allow-empty-name-p).=0A= ;; 2006/06/06 dadams=0A= ;; Added: hexrgb-defined-colors(-alist). Use instead of = (x-defined-colors).=0A= ;; hexrgb-(red|green|blue): Added interactive specs.=0A= ;; 2006/06/04 dadams=0A= ;; hexrgb-read-color: Added optional arg allow-empty-name-p.=0A= ;; 2006/06/02 dadams=0A= ;; Added: hexrgb-rgb-hex-string-p. Used it.=0A= ;; 2006/05/30 dadams=0A= ;; Added: hexrgb-hex-to-(hsv|rgb), hexrgb-hsv-to-hex, = hexrgb-color-name-to-hex,=0A= ;; hexrgb-complement, hexrgb-read-color, hexrgb-hue, = hexrgb-saturation,=0A= ;; hexrgb-value, hexrgb-red, hexrgb-blue, hexrgb-green.=0A= ;; approx-equal: Add optional fuzz factor arguments. Changed the = algorithm.=0A= ;; Renamed: approx-equal to hexrgb-approx-equal.=0A= ;; hexrgb-rgb-to-hsv: Changed test from < to <=3D: (when (<=3D hue = 0.0)...).=0A= ;; hexrgb-hsv-to-rgb: Treat hue =3D 0.0 (int 0) the same as hue =3D = 1.0 (int 6).=0A= ;; hexrgb-rgb-to-hex, hexrgb-increment-hex: Corrected doc strings.=0A= ;; 2006/05/22 dadams=0A= ;; Added: hexrgb-hsv-to-hex, hexrgb-rgb-to-hex. Require cl.el when = byte-compile.=0A= ;; 2005/08/09 dadams=0A= ;; hexrgb-rgb-to-hsv: Side-stepped Emacs-20 bug in comparing NaN.=0A= ;; hexrgb-increment-*: Added optional arg wrap-p.=0A= ;; hexrgb-increment-hex: Prevent wrap if not wrap-p.=0A= ;; 2005/08/02 dadams=0A= ;; hexrgb-rgb-to-hes: Bug fix: If delta is zero, then so are hue and = saturation.=0A= ;; 2005/06/24 dadams=0A= ;; hexrgb-rgb-to-hsv: Bug fix: test for NaN (e.g. on divide by zero).=0A= ;; 2005/02/08 dadams=0A= ;; hexrgb-hsv-to-rgb: Bug fix (typo: p, q -> pp, qq; added ww).=0A= ;; 2005/01/09 dadams=0A= ;; hexrgb-int-to-hex: Fixed bug in hexrgb-int-to-hex: nb-digits not = respected.=0A= ;; Added: hexrgb-hsv-to-rgb, hexrgb-rgb-to-hsv, approx-equal.=0A= ;; Renamed old hexrgb-increment-value to hexrgb-increment-equal-rgb.=0A= ;; 2005/01/05 dadams=0A= ;; hexrgb-int-to-hex: Used a suggestion from Juri Linkov.=0A= ;;=0A= ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;=0A= ;;=0A= ;; This program is free software; you can redistribute it and/or modify=0A= ;; it under the terms of the GNU General Public License as published by=0A= ;; the Free Software Foundation; either version 2, or (at your option)=0A= ;; any later version.=0A= =0A= ;; This program is distributed in the hope that it will be useful,=0A= ;; but WITHOUT ANY WARRANTY; without even the implied warranty of=0A= ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the=0A= ;; GNU General Public License for more details.=0A= =0A= ;; You should have received a copy of the GNU General Public License=0A= ;; along with this program; see the file COPYING. If not, write to=0A= ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth=0A= ;; Floor, Boston, MA 02110-1301, USA.=0A= ;;=0A= ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;=0A= ;;=0A= ;;; Code:=0A= =0A= (eval-when-compile (require 'cl)) ;; case; plus, for Emacs < 20: when, = unless=0A= =0A= ;;;;;;;;;;;;;;;;;;;;;;;;;;;=0A= =0A= =0A= ;; Not used here, but put here to be available to libraries that use = `hexrgb.el'.=0A= ;;;###autoload=0A= (defconst hexrgb-defined-colors (eval-when-compile (x-defined-colors))=0A= "List of all supported colors.")=0A= =0A= ;;;###autoload=0A= (defconst hexrgb-defined-colors-alist (eval-when-compile (mapcar #'list = (x-defined-colors)))=0A= "Alist of all supported colors, for use in completion.")=0A= =0A= ;;;###autoload=0A= (defun hexrgb-read-color (&optional convert-to-RGB-p allow-empty-name-p = prompt)=0A= "Read a color name or RGB hex value: #RRRRGGGGBBBB.=0A= Completion is available for color names, but not for RGB hex strings.=0A= If you input an RGB hex string, it must have the form #XXXXXXXXXXXX or=0A= XXXXXXXXXXXX, where each X is a hex digit. The number of Xs must be a=0A= multiple of 3, with the same number of Xs for each of red, green, and=0A= blue. The order is red, green, blue.=0A= =0A= In addition to standard color names and RGB hex values, the following=0A= are available as color candidates. In each case, the corresponding=0A= color is used.=0A= =0A= * `*copied foreground*' - last copied foreground, if available=0A= * `*copied background*' - last copied background, if available=0A= * `*mouse-2 foreground*' - foreground where you click `mouse-2'=0A= * `*mouse-2 background*' - background where you click `mouse-2'=0A= * `*point foreground*' - foreground under the cursor=0A= * `*point background*' - background under the cursor=0A= =0A= \(You can copy a color using eyedropper commands such as=0A= `eyedrop-pick-foreground-at-mouse'.)=0A= =0A= Checks input to be sure it represents a valid color. If not, raises=0A= an error (but see exception for empty input with non-nil=0A= ALLOW-EMPTY-NAME-P).=0A= =0A= Interactively, or with optional arg CONVERT-TO-RGB-P non-nil, converts=0A= an input color name to an RGB hex string. Returns the RGB hex string.=0A= =0A= Optional arg ALLOW-EMPTY-NAME-P controls what happens if you enter an=0A= empty color name (that is, you just hit `RET'). If non-nil, then=0A= `hexrgb-read-color' returns an empty color name, \"\". If nil, then=0A= it raises an error. Programs must test for \"\" if ALLOW-EMPTY-NAME-P=0A= is non-nil. They can then perform an appropriate action in case of=0A= empty input.=0A= =0A= Optional arg PROMPT is the prompt. Nil means use a default prompt."=0A= (interactive "p") ; Always convert to RGB = interactively.=0A= (let* ((completion-ignore-case t)=0A= (colors (if (fboundp 'eyedrop-foreground-at-point)=0A= (append (and eyedrop-picked-foreground '(("*copied = foreground*")))=0A= (and eyedrop-picked-background '(("*copied = background*")))=0A= '(("*mouse-2 foreground*") ("*mouse-2 = background*")=0A= ("*point foreground*") ("*point = background*"))=0A= hexrgb-defined-colors-alist)=0A= hexrgb-defined-colors-alist))=0A= (color (completing-read (or prompt "Color (name or #R+G+B+): ") = colors))=0A= hex-string)=0A= (when (fboundp 'eyedrop-foreground-at-point)=0A= (cond ((string=3D "*copied foreground*" color) (setq color = eyedrop-picked-foreground))=0A= ((string=3D "*copied background*" color) (setq color = eyedrop-picked-background))=0A= ((string=3D "*point foreground*" color) (setq color = (eyedrop-foreground-at-point)))=0A= ((string=3D "*point background*" color) (setq color = (eyedrop-background-at-point)))=0A= ((string=3D "*mouse-2 foreground*" color)=0A= (setq color (prog1 (eyedrop-foreground-at-mouse=0A= (read-event "Click `mouse-2' to choose = foreground color - "))=0A= (read-event)))) ; Discard mouse up event.=0A= ((string=3D "*mouse-2 background*" color)=0A= (setq color (prog1 (eyedrop-background-at-mouse=0A= (read-event "Click `mouse-2' to choose = background color - "))=0A= (read-event)))))) ; Discard mouse up event.=0A= (setq hex-string (or (string-match = "^#\\([a-fA-F0-9][a-fA-F0-9][a-fA-F0-9]\\)+$" color)=0A= (and (string-match = "^\\([a-fA-F0-9][a-fA-F0-9][a-fA-F0-9]\\)+$" color)=0A= t)))=0A= (if (and allow-empty-name-p (string=3D "" color))=0A= ""=0A= (when (and hex-string (not (eq 0 hex-string)))=0A= (setq color (concat "#" color))) ; No #; add it.=0A= (unless hex-string=0A= (when (or (string=3D "" color)=0A= (not (if (fboundp 'test-completion) ; Not defined in = Emacs 20.=0A= (test-completion color colors)=0A= (try-completion color colors))))=0A= (error "No such color: %S" color))=0A= (when convert-to-RGB-p (setq color (hexrgb-color-name-to-hex = color))))=0A= (when (interactive-p) (message "Color: `%s'" color))=0A= color)))=0A= =0A= ;;;###autoload=0A= (defun hexrgb-rgb-hex-string-p (color &optional laxp)=0A= "Non-nil if COLOR is an RGB string #XXXXXXXXXXXX.=0A= Each X is a hex digit. The number of Xs must be a multiple of 3, with=0A= the same number of Xs for each of red, green, and blue.=0A= =0A= Non-nil optional arg LAXP means that the initial `#' is optional. In=0A= that case, for a valid string of hex digits: when # is present 0 is=0A= returned; otherwise, t is returned."=0A= (or (string-match "^#\\([a-fA-F0-9][a-fA-F0-9][a-fA-F0-9]\\)+$" color)=0A= (and laxp (string-match = "^\\([a-fA-F0-9][a-fA-F0-9][a-fA-F0-9]\\)+$" color) t)))=0A= =0A= ;;;###autoload=0A= (defun hexrgb-complement (color)=0A= "Return the color that is the complement of COLOR."=0A= (interactive (list (hexrgb-read-color)))=0A= (setq color (hexrgb-color-name-to-hex color))=0A= (let ((red (hexrgb-red color))=0A= (green (hexrgb-green color))=0A= (blue (hexrgb-blue color)))=0A= (setq color (hexrgb-rgb-to-hex (- 1.0 red) (- 1.0 green) (- 1.0 = blue))))=0A= (when (interactive-p) (message "Complement: `%s'" color))=0A= color)=0A= =0A= ;;;###autoload=0A= (defun hexrgb-hue (color)=0A= "Return the hue component of COLOR, in range 0 to 1 inclusive.=0A= COLOR is a color name or hex RGB string that starts with \"#\"."=0A= (interactive (list (hexrgb-read-color)))=0A= (setq color (hexrgb-color-name-to-hex color))=0A= (car (hexrgb-rgb-to-hsv (hexrgb-red color) (hexrgb-green color) = (hexrgb-blue color))))=0A= =0A= ;;;###autoload=0A= (defun hexrgb-saturation (color)=0A= "Return the saturation component of COLOR, in range 0 to 1 inclusive.=0A= COLOR is a color name or hex RGB string that starts with \"#\"."=0A= (interactive (list (hexrgb-read-color)))=0A= (setq color (hexrgb-color-name-to-hex color))=0A= (cadr (hexrgb-rgb-to-hsv (hexrgb-red color) (hexrgb-green color) = (hexrgb-blue color))))=0A= =0A= ;;;###autoload=0A= (defun hexrgb-value (color)=0A= "Return the value component of COLOR, in range 0 to 1 inclusive.=0A= COLOR is a color name or hex RGB string that starts with \"#\"."=0A= (interactive (list (hexrgb-read-color)))=0A= (setq color (hexrgb-color-name-to-hex color))=0A= (caddr (hexrgb-rgb-to-hsv (hexrgb-red color) (hexrgb-green color) = (hexrgb-blue color))))=0A= =0A= ;;;###autoload=0A= (defun hexrgb-red (color)=0A= "Return the red component of COLOR, in range 0 to 1 inclusive.=0A= COLOR is a color name or hex RGB string that starts with \"#\"."=0A= (interactive (list (hexrgb-read-color)))=0A= (setq color (hexrgb-color-name-to-hex color))=0A= (/ (hexrgb-hex-to-int (substring color 1 (1+ (/ (1- (length color)) = 3))))=0A= (expt 16.0 (/ (1- (length color)) 3.0))))=0A= =0A= ;;;###autoload=0A= (defun hexrgb-green (color)=0A= "Return the green component of COLOR, in range 0 to 1 inclusive.=0A= COLOR is a color name or hex RGB string that starts with \"#\"."=0A= (interactive (list (hexrgb-read-color)))=0A= (setq color (hexrgb-color-name-to-hex color))=0A= (let* ((len (/ (1- (length color)) 3))=0A= (start (1+ len)))=0A= (/ (hexrgb-hex-to-int (substring color start (+ start len)))=0A= (expt 16.0 (/ (1- (length color)) 3.0)))))=0A= =0A= ;;;###autoload=0A= (defun hexrgb-blue (color)=0A= "Return the blue component of COLOR, in range 0 to 1 inclusive.=0A= COLOR is a color name or hex RGB string that starts with \"#\"."=0A= (interactive (list (hexrgb-read-color)))=0A= (setq color (hexrgb-color-name-to-hex color))=0A= (let* ((len (/ (1- (length color)) 3))=0A= (start (+ 1 len len)))=0A= (/ (hexrgb-hex-to-int (substring color start (+ start len)))=0A= (expt 16.0 (/ (1- (length color)) 3.0)))))=0A= =0A= ;;;###autoload=0A= (defun hexrgb-rgb-to-hsv (red green blue)=0A= "Convert RED, GREEN, BLUE components to HSV (hue, saturation, value).=0A= Each input component is 0.0 to 1.0, inclusive.=0A= Returns a list of HSV components of value 0.0 to 1.0, inclusive."=0A= (let* ((min (min red green blue))=0A= (max (max red green blue))=0A= (value max)=0A= (delta (- max min))=0A= hue saturation)=0A= (if (hexrgb-approx-equal 0.0 delta)=0A= (setq hue 0.0 saturation 0.0) ; Gray scale - no color; only = value.=0A= (if (and (condition-case nil=0A= (setq saturation (/ delta max))=0A= (arith-error nil))=0A= (or (< emacs-major-version 21) ; Emacs 20 bug makes next = test fail falsely.=0A= (not (equal 0.0e+NaN saturation)))) ; Must be a = number, not NaN.=0A= (if (hexrgb-approx-equal 0.0 saturation)=0A= (setq hue 0.0 saturation 0.0) ; Again, no color; only = value.=0A= ;; Color=0A= (if (hexrgb-approx-equal red max)=0A= (setq hue (/ (- green blue) delta)) ; Between yellow & = magenta.=0A= (if (hexrgb-approx-equal green max)=0A= (setq hue (+ 2.0 (/ (- blue red) delta))) ; Between = cyan & yellow.=0A= (setq hue (+ 4.0 (/ (- red green) delta))))) ; Between = magenta & cyan.=0A= (setq hue (/ hue 6.0))=0A= (when (<=3D hue 0.0)(setq hue (+ hue 1.0))))=0A= (setq saturation 0.0 hue 0.0))) ; Div by zero (max=3D0): H:=3D0, = S:=3D0. (Hue undefined.)=0A= (list hue saturation value)))=0A= =0A= ;;;###autoload=0A= (defun hexrgb-hsv-to-rgb (hue saturation value)=0A= "Convert HUE, SATURATION, VALUE components to RGB (red, green, blue).=0A= Each input component is 0.0 to 1.0, inclusive.=0A= Returns a list of RGB components of value 0.0 to 1.0, inclusive."=0A= (let (red green blue int-hue fract pp qq tt ww)=0A= (if (hexrgb-approx-equal 0.0 saturation)=0A= (setq red value green value blue value) ; Gray=0A= (setq hue (* hue 6.0) ; Sectors: 0 to 5=0A= int-hue (floor hue)=0A= fract (- hue int-hue)=0A= pp (* value (- 1 saturation))=0A= qq (* value (- 1 (* saturation fract)))=0A= ww (* value (- 1 (* saturation (- 1 (- hue int-hue))))))=0A= (case int-hue=0A= ((0 6) (setq red value green ww blue pp))=0A= (1 (setq red qq green value blue pp))=0A= (2 (setq red pp green value blue ww))=0A= (3 (setq red pp green qq blue value))=0A= (4 (setq red ww green pp blue value))=0A= (otherwise (setq red value green pp blue qq))))=0A= (list red green blue)))=0A= =0A= ;;;###autoload=0A= (defun hexrgb-hsv-to-hex (hue saturation value)=0A= "Return the hex RBG color string for inputs HUE, SATURATION, VALUE.=0A= The inputs are each in the range 0 to 1.=0A= The output string is of the form \"#RRRRGGGGBBBB\"."=0A= (hexrgb-color-values-to-hex=0A= (mapcar (lambda (x) (floor (* x 65535.0))) (hexrgb-hsv-to-rgb hue = saturation value))))=0A= =0A= ;;;###autoload=0A= (defun hexrgb-rgb-to-hex (red green blue)=0A= "Return the hex RBG color string for inputs RED, GREEN, BLUE.=0A= The inputs are each in the range 0 to 1.=0A= The output string is of the form \"#RRRRGGGGBBBB\"."=0A= (hexrgb-color-values-to-hex=0A= (mapcar (lambda (x) (floor (* x 65535.0))) (list red green blue))))=0A= =0A= ;;;###autoload=0A= (defun hexrgb-hex-to-hsv (color)=0A= "Return a list of HSV (hue, saturation, value) color components.=0A= Each component is a value from 0.0 to 1.0, inclusive.=0A= COLOR is a color name or a hex RGB string that starts with \"#\" and=0A= is followed by an equal number of hex digits for red, green, and blue=0A= components."=0A= (let ((rgb-components (hexrgb-hex-to-rgb color)))=0A= (apply #'hexrgb-rgb-to-hsv rgb-components)))=0A= =0A= ;;;###autoload=0A= (defun hexrgb-hex-to-rgb (color)=0A= "Return a list of RGB (red, green, blue) color components.=0A= Each component is a value from 0.0 to 1.0, inclusive.=0A= COLOR is a color name or a hex RGB string that starts with \"#\" and=0A= is followed by an equal number of hex digits for red, green, and blue=0A= components."=0A= (unless (hexrgb-rgb-hex-string-p color) (setq color = (hexrgb-color-name-to-hex color)))=0A= (let ((len (/ (1- (length color)) 3)))=0A= (list (/ (hexrgb-hex-to-int (substring color 1 (1+ len))) 65535.0)=0A= (/ (hexrgb-hex-to-int (substring color (1+ len) (+ 1 len = len))) 65535.0)=0A= (/ (hexrgb-hex-to-int (substring color (+ 1 len len))) = 65535.0))))=0A= =0A= ;;;###autoload=0A= (defun hexrgb-color-name-to-hex (color)=0A= "Return the RGB hex string for the COLOR name, starting with \"#\".=0A= If COLOR is already a string starting with \"#\", then just return it."=0A= (let ((components (x-color-values color)))=0A= (unless components (error "No such color: %S" color))=0A= (unless (hexrgb-rgb-hex-string-p color)=0A= (setq color (hexrgb-color-values-to-hex components))))=0A= color)=0A= =0A= ;; Just hard-code 4 as the number of hex digits, since `x-color-values'=0A= ;; seems to produce appropriate integer values for this value.=0A= ;;=0A= ;; Color "components" would be better in the name than color "value"=0A= ;; but this name follows the Emacs tradition (e.g. `x-color-values',=0A= ;; 'ps-color-values', `ps-e-x-color-values').=0A= ;;;###autoload=0A= (defun hexrgb-color-values-to-hex (values)=0A= "Convert list of rgb color VALUES to a hex string, #XXXXXXXXXXXX.=0A= Each X in the string is a hexadecimal digit.=0A= Input VALUES is as for the output of `x-color-values'."=0A= (concat "#"=0A= (hexrgb-int-to-hex (nth 0 values) 4) ; red=0A= (hexrgb-int-to-hex (nth 1 values) 4) ; green=0A= (hexrgb-int-to-hex (nth 2 values) 4))) ; blue=0A= =0A= ;;;###autoload=0A= (defun hexrgb-hex-to-color-values (color)=0A= "Convert hex COLOR to a list of rgb color values.=0A= COLOR is a hex rgb color string, #XXXXXXXXXXXX=0A= Each X in the string is a hexadecimal digit. There are 3N X's, N > 0.=0A= The output list is as for `x-color-values'."=0A= (let* ((hex-strgp (string-match=0A= = "^\\(#\\)?\\(\\([a-fA-F0-9][a-fA-F0-9][a-fA-F0-9]\\)+\\)$"=0A= color))=0A= (ndigits (/ (if (eq (match-beginning 1) (match-end 1))=0A= (length color)=0A= (1- (length color)))=0A= 3))=0A= red green blue)=0A= (unless hex-strgp (error "Invalid RGB color string: %s" color))=0A= (setq color (substring color (match-beginning 2) (match-end 2))=0A= red (hexrgb-hex-to-int (substring color 0 ndigits))=0A= green (hexrgb-hex-to-int (substring color ndigits (* 2 = ndigits)))=0A= blue (hexrgb-hex-to-int (substring color ndigits (* 3 = ndigits))))=0A= (list red green blue)))=0A= =0A= ;;;###autoload=0A= (defun hexrgb-increment-red (hex nb-digits increment &optional wrap-p)=0A= "Increment red value of rgb string HEX by INCREMENT.=0A= String HEX starts with \"#\". Each color is NB-DIGITS hex digits long.=0A= If optional arg WRAP-P is non-nil, then the result wraps around zero.=0A= For example, incrementing \"#FFFFFFFFF\" by 1 will cause it to wrap=0A= around to \"#000000000\"."=0A= (concat "#"=0A= (hexrgb-increment-hex (substring hex 1 (1+ nb-digits)) = increment nb-digits wrap-p)=0A= (substring hex (1+ nb-digits) (1+ (* nb-digits 2)))=0A= (substring hex (1+ (* nb-digits 2)))))=0A= =0A= ;;;###autoload=0A= (defun hexrgb-increment-green (hex nb-digits increment &optional wrap-p)=0A= "Increment green value of rgb string HEX by INCREMENT.=0A= String HEX starts with \"#\". Each color is NB-DIGITS hex digits long.=0A= For example, incrementing \"#FFFFFFFFF\" by 1 will cause it to wrap=0A= around to \"#000000000\"."=0A= (concat=0A= "#" (substring hex 1 (1+ nb-digits))=0A= (hexrgb-increment-hex (substring hex (1+ nb-digits) (1+ (* nb-digits = 2)))=0A= increment=0A= nb-digits=0A= wrap-p)=0A= (substring hex (1+ (* nb-digits 2)))))=0A= =0A= ;;;###autoload=0A= (defun hexrgb-increment-blue (hex nb-digits increment &optional wrap-p)=0A= "Increment blue value of rgb string HEX by INCREMENT.=0A= String HEX starts with \"#\". Each color is NB-DIGITS hex digits long.=0A= For example, incrementing \"#FFFFFFFFF\" by 1 will cause it to wrap=0A= around to \"#000000000\"."=0A= (concat "#" (substring hex 1 (1+ (* nb-digits 2)))=0A= (hexrgb-increment-hex (substring hex (1+ (* nb-digits 2)))=0A= increment=0A= nb-digits=0A= wrap-p)))=0A= =0A= ;;;###autoload=0A= (defun hexrgb-increment-equal-rgb (hex nb-digits increment &optional = wrap-p)=0A= "Increment each color value (r,g,b) of rgb string HEX by INCREMENT.=0A= String HEX starts with \"#\". Each color is NB-DIGITS hex digits long.=0A= For example, incrementing \"#FFFFFFFFF\" by 1 will cause it to wrap=0A= around to \"#000000000\"."=0A= (concat=0A= "#" (hexrgb-increment-hex (substring hex 1 (1+ nb-digits)) increment = nb-digits wrap-p)=0A= (hexrgb-increment-hex (substring hex (1+ nb-digits) (1+ (* nb-digits = 2)))=0A= increment=0A= nb-digits=0A= wrap-p)=0A= (hexrgb-increment-hex (substring hex (1+ (* nb-digits 2))) increment = nb-digits wrap-p)))=0A= =0A= ;;;###autoload=0A= (defun hexrgb-increment-hex (hex increment nb-digits &optional wrap-p)=0A= "Increment HEX number (a string NB-DIGITS long) by INCREMENT.=0A= For example, incrementing \"FFFFFFFFF\" by 1 will cause it to wrap=0A= around to \"000000000\"."=0A= (let* ((int (hexrgb-hex-to-int hex))=0A= (new-int (+ increment int)))=0A= (if (or wrap-p=0A= (and (>=3D int 0) ; Not too large for the = machine.=0A= (>=3D new-int 0) ; For the case where increment = < 0.=0A= (<=3D (length (format (concat "%X") new-int)) = nb-digits))) ; Not too long.=0A= (hexrgb-int-to-hex new-int nb-digits) ; Use incremented number.=0A= hex))) ; Don't increment.=0A= =0A= ;;;###autoload=0A= (defun hexrgb-hex-to-int (hex)=0A= "Convert HEX string argument to an integer.=0A= The characters of HEX must be hex characters."=0A= (let* ((factor 1)=0A= (len (length hex))=0A= (indx (1- len))=0A= (int 0))=0A= (while (>=3D indx 0)=0A= (setq int (+ int (* factor (hexrgb-hex-char-to-integer (aref hex = indx)))))=0A= (setq indx (1- indx))=0A= (setq factor (* 16 factor)))=0A= int))=0A= =0A= ;; From `hexl.el'. This is the same as `hexl-hex-char-to-integer' = defined there.=0A= ;;;###autoload=0A= (defun hexrgb-hex-char-to-integer (character)=0A= "Take a CHARACTER and return its value as if it were a hex digit."=0A= (if (and (>=3D character ?0) (<=3D character ?9))=0A= (- character ?0)=0A= (let ((ch (logior character 32)))=0A= (if (and (>=3D ch ?a) (<=3D ch ?f))=0A= (- ch (- ?a 10))=0A= (error "Invalid hex digit `%c'" ch)))))=0A= =0A= ;; Originally, I used the code from `int-to-hex-string' in `float.el'.=0A= ;; This version is thanks to Juri Linkov .=0A= ;;=0A= ;;;###autoload=0A= (defun hexrgb-int-to-hex (int &optional nb-digits)=0A= "Convert integer argument INT to a #XXXXXXXXXXXX format hex string.=0A= Each X in the output string is a hexadecimal digit.=0A= NB-DIGITS is the number of hex digits. If INT is too large to be=0A= represented with NB-DIGITS, then the result is truncated from the=0A= left. So, for example, INT=3D256 and NB-DIGITS=3D2 returns \"00\", since=0A= the hex equivalent of 256 decimal is 100, which is more than 2 digits."=0A= (setq nb-digits (or nb-digits 4))=0A= (substring (format (concat "%0" (int-to-string nb-digits) "X") int) (- = nb-digits)))=0A= =0A= ;; Inspired by Elisp Info manual, node "Comparison of Numbers".=0A= ;;;###autoload=0A= (defun hexrgb-approx-equal (x y &optional rfuzz afuzz)=0A= "Return non-nil if numbers X and Y are approximately equal.=0A= RFUZZ is a relative fuzz factor. AFUZZ is an absolute fuzz factor.=0A= RFUZZ defaults to 1.0e-8. AFUZZ defaults to (/ RFUZZ 10).=0A= The algorithm is:=0A= (< (abs (- X Y)) (+ AFUZZ (* RFUZZ (+ (abs X) (abs Y)))))."=0A= (setq rfuzz (or rfuzz 1.0e-8) afuzz (or afuzz (/ rfuzz 10)))=0A= (< (abs (- x y)) (+ afuzz (* rfuzz (+ (abs x) (abs y))))))=0A= =0A= ;;;###autoload=0A= (defun hexrgb-color-value-to-float (n)=0A= "Return the floating-point equivalent of color value N.=0A= N must be an integer between 0 and 65535, or else an error is raised."=0A= (unless (and (wholenump n) (<=3D n 65535))=0A= (error "Not a whole number less than 65536"))=0A= (/ (float n) 65535.0))=0A= =0A= ;;;###autoload=0A= (defun hexrgb-float-to-color-value (x)=0A= "Return the color value equivalent of floating-point number X.=0A= X must be between 0.0 and 1.0, or else an error is raised."=0A= (unless (and (numberp x) (<=3D 0.0 x) (<=3D x 1.0))=0A= (error "Not a floating-point number between 0.0 and 1.0"))=0A= (floor (* x 65535.0)))=0A= =0A= ;;;;;;;;;;;;;;;;;;;;;;;;;;;=0A= =0A= (provide 'hexrgb)=0A= =0A= ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;=0A= ;;; hexrgb.el ends here=0A= ------=_NextPart_000_000B_01C8E19D.B15F7F80--