-
-
Notifications
You must be signed in to change notification settings - Fork 100
/
Copy pathdoremi-frm.el
2455 lines (2283 loc) · 120 KB
/
doremi-frm.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;;; doremi-frm.el --- Incrementally adjust face attributes and frame parameters.
;;
;; Filename: doremi-frm.el
;; Description: Incrementally adjust face attributes and frame parameters.
;; Author: Drew Adams
;; Maintainer: Drew Adams (concat "drew.adams" "@" "oracle" ".com")
;; Copyright (C) 2004-2022, Drew Adams, all rights reserved.
;; Created: Sat Sep 11 10:40:32 2004
;; Version: 0
;; Package-Requires: ((doremi "0") (faces+ "0") (frame-fns "0") (hexrgb "0"))
;; Last-Updated: Sat Mar 26 09:00:07 2022 (-0700)
;; By: dradams
;; Update #: 3080
;; URL: https://www.emacswiki.org/emacs/download/doremi-frm.el
;; Doc URL: https://www.emacswiki.org/emacs/DoReMi
;; Keywords: frames, extensions, convenience, keys, repeat, cycle
;; Compatibility: GNU Emacs: 20.x, 21.x, 22.x, 23.x, 24.x, 25.x, 26.x
;;
;; Features that might be required by this library:
;;
;; `avoid', `backquote', `bytecomp', `cconv', `cl-lib',
;; `col-highlight', `crosshairs', `custom', `doremi', `faces',
;; `faces+', `frame-cmds', `frame-fns', `hexrgb', `hl-line',
;; `hl-line+', `macroexp', `misc-cmds', `misc-fns', `mwheel',
;; `palette', `rect', `ring', `strings', `thingatpt', `thingatpt+',
;; `timer', `vline', `widget'.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Commentary:
;;
;; Do Re Mi commands to incrementally adjust face attributes and
;; frame parameters using arrow keys or mouse wheel.
;;
;; When you invoke the Do Re Mi iterative commands defined here, you
;; can press and hold an up/down arrow key, or rotate the mouse
;; wheel, to change face attributes or frame parameters. For more
;; information, see file `doremi.el', in particular the doc-string
;; for function `doremi'.
;;
;; NOTE: Functions and variables in this library have the prefix
;; `doremi-'. In order to more easily distinguish commands
;; that iterate in Do Re Mi fashion from other functions in the
;; library, the iterative commands are suffixed with `+'.
;;
;; Note about saving changes made with the commands defined here:
;;
;; Some of the commands defined here change face parameters. User
;; option `doremi-customization-status' controls whether, and if so
;; how, Customize is to be informed about these changes. In any
;; case, the commands do not save any changes they make. If you
;; want to save the changes then you will need to tell Customize to
;; do that.
;;
;; The default value of option `doremi-customization-status' is
;; `customized', which means to tell Customize that the changes
;; were made by Customize itself, that is, just as if you had set
;; the new values using the Customize UI. In this case, you can
;; use command `customize-unsaved' (aka `customize-customized') to
;; open Customize for all of the changed faces. You can then save
;; any of them individualy (using its `State' menu, item `Save for
;; Future Sessions') or click the button (`Apply and Save') to save
;; all of them at once.
;;
;; If the value of option `doremi-customization-status' is
;; `outside' then changes made by the commands here are considered
;; by Customize to have been made outside Customize, that is, as
;; so-called "rogue" changes. This is how Customize considers
;; changes made by command `set-face-foreground', for example. In
;; this case, if you want to save the changes then you can use
;; command `customize-rogue' to open Customize for them.
;;
;; If the value of option `doremi-customization-status' is anything
;; else then Customize is not informed of the changes made by
;; commands defined here. You see the changes in the current Emacs
;; session, but Customize does not recognize them. In this case
;; there is no way to know what the changes were, and hence no way
;; to save them except by noting the current color values (e.g.,
;; using `C-u C-x =') and then explicitly setting them in a way
;; that Customize will recognize, such as using the Customize UI or
;; a command such as `set-face-foreground'.
;;
;; Frame parameter changes, such as background color, are different
;; from face changes (though the background color of face `default'
;; is used as the default value for frame parameter
;; `background-color'). When you change the background or
;; foreground color of a given frame, this change is not associated
;; with any particular persistent setting in the same way that a
;; face change is associated with a face, whose customization can
;; be saved. That is, there is no single variable for saving
;; changes to parameters of the current frame.
;;
;; Instead, the frame settings that are persistent are the alist
;; options that determine the default characteristics of certain
;; *kinds* of frame, not individual frames. These include:
;; `default-frame-alist', `initial-frame-alist',
;; `special-display-frame-alist', and `minibuffer-frame-alist' (if
;; you use a standalone minibuffer frame). The complete list of
;; such frame alist variables is available using function
;; `frame-alist-var-names', defined in library `frame-cmds.el'.
;;
;; After you use Do Re Mi commands that change a frame background
;; or foreground color, if you want to save that new appearance in
;; one of the frame alist variables then you need to obtain the
;; current color and use it to customize the alist variable.
;;
;; Example: Suppose you change the background color of a frame, and
;; you want to make it the default background color for new frames
;; in the future. You will need to update the value of variable
;; `default-frame-alist', so that it uses the `background-color'
;; parameter setting of the changed frame.
;;
;; You can easily copy one or all parameter values from any given
;; frame to any frame alist variable (such as
;; `default-frame-alist'), by using the commands
;; `set-frame-alist-parameter-from-frame' and
;; `set-all-frame-alist-parameters-from-frame'. Those commands are
;; defined in library `frame-cmds.el'. Alternatively, you can use
;; `M-: (frame-parameters)' to show all of the current parameter
;; values for the selected frame, and then customize the alist
;; variable to use any of them you like.
;;
;; Note on available color names:
;;
;; Color names supported by your Emacs release and platform are
;; those returned by function `x-color-names'. This often includes
;; names that are essentially the same as duplicates, e.g.,
;; "LightBlue" and "light blue". By default, Do Re Mi
;; canonicalizes these names by lowercasing them and removing
;; whitespace. Then it removes the duplicates. This behavior is
;; governed by option `hexrgb-canonicalize-defined-colors-flag'.
;; Customize that option to nil if you need the original names.
;;
;;
;; User options defined here:
;;
;; `doremi-customization-status', `doremi-frame-config-ring-size',
;; `doremi-move-frame-wrap-within-display-flag',
;; `doremi-push-frame-config-for-cmds-flag',
;; `doremi-RGB-increment-factor', `doremi-wrap-color-flag'.
;;
;;
;; Commands defined here:
;;
;; `doremi-all-faces-bg+', `doremi-all-faces-fg+',
;; `doremi-all-frames-bg+', `doremi-all-frames-fg+', `doremi-bg+',
;; `doremi-bg-blue+', `doremi-bg-brightness+',
;; `doremi-bg-color-name+', `doremi-bg-cyan+', `doremi-bg-green+',
;; `doremi-bg-hue+', `doremi-bg-hue-stepping-saturation+',
;; `doremi-bg-magenta+', `doremi-bg-purity+', `doremi-bg-red+',
;; `doremi-bg-saturation+', `doremi-bg-value+',
;; `doremi-bg-yellow+', `doremi-buffer-font-size+',
;; `doremi-face-bg+', `doremi-face-bg-color-name+',
;; `doremi-face-bg-hue-stepping-saturation+', `doremi-face-fg+',
;; `doremi-face-fg-color-name+',
;; `doremi-face-fg-hue-stepping-saturation+', `doremi-fg+',
;; `doremi-fg-blue+', `doremi-fg-brightness+',
;; `doremi-fg-color-name+', `doremi-fg-cyan+', `doremi-fg-green+',
;; `doremi-fg-hue+', `doremi-fg-hue-stepping-saturation+',
;; `doremi-fg-magenta+', `doremi-fg-purity+', `doremi-fg-red+',
;; `doremi-fg-saturation+', `doremi-fg-value+',
;; `doremi-fg-yellow+', `doremi-font+', `doremi-font-size+',
;; `doremi-frame-configs+', `doremi-frame-font-size+',
;; `doremi-frame-height+', `doremi-frame-horizontally+',
;; `doremi-frame-vertically+', `doremi-frame-width+',
;; `doremi-increment-background-color',
;; `doremi-increment-color-component',
;; `doremi-increment-face-bg-color',
;; `doremi-increment-face-fg-color',
;; `doremi-increment-foreground-color',
;; `doremi-set-background-color', `doremi-set-foreground-color',
;; `doremi-toggle-wrap-color', `doremi-undo-last-face-change',
;; `doremi-undo-last-frame-color-change',
;; `toggle-doremi-wrap-color'.
;;
;;
;; Non-interactive functions defined here:
;;
;; `doremi-adjust-increment-for-color-component',
;; `doremi-all-faces-bg/fg-1', `doremi-all-frames-bg/fg-1',
;; `doremi-bg-1', `doremi-bg/fg-color-name-1', `doremi-delete-if',
;; `doremi-face-bg/fg-1', `doremi-face-bg/fg-color-name-1',
;; `doremi-face-color-component',
;; `doremi-face-hue-stepping-saturation', `doremi-face-set',
;; `doremi-fg-1', `doremi-frame-color-component',
;; `doremi-frame-config-wo-parameters',
;; `doremi-frame-hue-stepping-saturation',
;; `doremi-frame-new-position',
;; `doremi-increment-background-color-1', `doremi-increment-color',
;; `doremi-increment-face-color',
;; `doremi-increment-face-color-read-args', `doremi-face-default',
;; `doremi-increment-blue', `doremi-increment-foreground-color-1',
;; `doremi-increment-frame-color', `doremi-increment-green',
;; `doremi-increment-red', `doremi-push-current-frame-config',
;; `doremi-push-frame-config-for-command', `doremi-read-component',
;; `doremi-read-increment-arg', `doremi-set-frame-color',
;; `doremi-update-face-customization-status',
;; `doremi-wrap-or-limit-color-component'.
;;
;;
;; Internal variables defined here:
;;
;; `doremi-current-increment', `doremi-frame-config-ring',
;; `doremi-last-face-value', `doremi-last-frame-color'.
;;
;;
;; See also these related Do Re Mi libraries:
;;
;; `doremi-mac.el' - Macro to define Do Re Mi commands and
;; automatically add them to a Do Re Mi menu.
;; `doremi-cmd.el' - Do Re Mi commands not dealing with frames.
;;
;; See also these files for other frame commands:
;;
;; `autofit-frame.el' - Automatically fit each frame to its
;; selected window. Uses `fit-frame.el'.
;;
;; `fit-frame.el' - 1) Fit a frame to its selected window.
;; 2) Incrementally resize a frame.
;;
;; `frame-cmds.el' - Various frame and window commands.
;;
;; `thumb-frm.el' - Shrink frames to a thumbnail size and
;; restore them again.
;;
;; `zoom-frm.el' - Zoom a frame, so that its font becomes
;; larger or smaller.
;;
;;
;; Put this in your init file (`~/.emacs'): (require 'doremi-frm)
;;
;; Suggested key bindings:
;;
;; (defalias 'doremi-prefix (make-sparse-keymap))
;; (defvar doremi-map (symbol-function 'doremi-prefix)
;; "Keymap for Do Re Mi commands.")
;; (define-key global-map "\C-xt" 'doremi-prefix)
;; (define-key doremi-map "a" 'doremi-all-faces-fg+) ; "All"
;; (define-key doremi-map "c" 'doremi-bg+) ; "Color"
;; (define-key doremi-map "f" 'doremi-face-fg+) ; Face"
;; (define-key doremi-map "h" 'doremi-frame-height+)
;; (define-key doremi-map "t" 'doremi-font+) ; "Typeface"
;; (define-key doremi-map "u" 'doremi-frame-configs+) ; "Undo"
;; (define-key doremi-map "x" 'doremi-frame-horizontally+)
;; (define-key doremi-map "y" 'doremi-frame-vertically+)
;; (define-key doremi-map "z" 'doremi-font-size+)) ; "Zoom"
;;
;; Customize the menu. Uncomment this to try it out.
;;
;; (defvar menu-bar-doremi-menu (make-sparse-keymap "Do Re Mi"))
;; (define-key global-map [menu-bar doremi]
;; (cons "Do Re Mi" menu-bar-doremi-menu))
;; (define-key menu-bar-doremi-menu [doremi-frame-configs+]
;; '(menu-item "Frame Configurations" doremi-frame-configs+
;; :help "Cycle among frame configurations recorded: `up'/`down'"))
;; (define-key menu-bar-doremi-menu [doremi-font+]
;; '(menu-item "Font" doremi-font+
;; :help "Successively cycle among fonts, choosing by name: `up'/`down'"))
;; (when (fboundp 'text-scale-increase) ; Emacs 23+.
;; (define-key menu-bar-doremi-menu [doremi-buffer-font-size+]
;; '(menu-item "Buffer Text Size (Zoom)" doremi-buffer-font-size+
;; :help "Change text size for buffer incrementally: `up'/`down'")))
;; (define-key menu-bar-doremi-menu [doremi-frame-font-size+]
;; '(menu-item "Frame Font Size (Zoom)" doremi-frame-font-size+
;; :help "Change font size for frame incrementally: `up'/`down'"))
;; (define-key menu-bar-doremi-menu [doremi-all-frames-fg+]
;; '(menu-item "All Frame Foregrounds..." doremi-all-frames-fg+
;; :help "Change foreground of all frames incrementally: `up'/`down'"))
;; (define-key menu-bar-doremi-menu [doremi-all-frames-bg+]
;; '(menu-item "All Frame Backgrounds..." doremi-all-frames-bg+
;; :help "Change background of all frames incrementally: `up'/`down'"))
;; (define-key menu-bar-doremi-menu [doremi-undo-last-frame-color-change]
;; '(menu-item "Undo Frame Color Change" doremi-undo-last-frame-color-change
;; :enable doremi-last-frame-color
;; :help "Undo the last frame color change by `doremi-fg+' or `doremi-bg+'"))
;; (define-key menu-bar-doremi-menu [doremi-fg-color-name+]
;; '(menu-item "Frame Foreground Name..." doremi-fg-color-name+
;; :help "Change frame foreground color incrementally: `up'/`down'"))
;; (define-key menu-bar-doremi-menu [doremi-fg+]
;; '(menu-item "Frame Foreground..." doremi-fg+
;; :help "Change frame foreground color incrementally: `up'/`down'"))
;; (define-key menu-bar-doremi-menu [doremi-bg-color-name+]
;; '(menu-item "Frame Background Name..." doremi-bg-color-name+
;; :help "Change frame background color incrementally: `up'/`down'"))
;; (define-key menu-bar-doremi-menu [doremi-bg+]
;; '(menu-item "Frame Background..." doremi-bg+
;; :help "Change frame background color incrementally: `up'/`down'"))
;; (define-key menu-bar-doremi-menu [doremi-all-faces-fg+]
;; '(menu-item "All Faces - Foreground..." doremi-all-faces-fg+
;; :help "Change foreground color of all faces incrementally: `up'/`down'"))
;; (define-key menu-bar-doremi-menu [doremi-all-faces-bg+]
;; '(menu-item "All Faces - Background..." doremi-all-faces-bg+
;; :help "Change background color of all faces incrementally: `up'/`down'"))
;; (define-key menu-bar-doremi-menu [doremi-undo-last-face-change]
;; '(menu-item "Undo Face Color Change" doremi-undo-last-face-change
;; :enable (facep 'doremi-last-face) ; Actually, it's always non-nil.
;; :help "Undo the last face color change by Do Re Mi"))
;; (define-key menu-bar-doremi-menu [doremi-face-fg-color-name+]
;; '(menu-item "Face Foreground Name..." doremi-face-fg-color-name+
;; :help "Change foreground color name of a face incrementally: `up'/`down'"))
;; (define-key menu-bar-doremi-menu [doremi-face-fg+]
;; '(menu-item "Face Foreground..." doremi-face-fg+
;; :help "Change foreground color of a face incrementally: `up'/`down'"))
;; (define-key menu-bar-doremi-menu [doremi-face-bg-color-name+]
;; '(menu-item "Face Background Name..." doremi-face-bg-color-name+
;; :help "Change background color name of a face incrementally: `up'/`down'"))
;; (define-key menu-bar-doremi-menu [doremi-face-bg+]
;; '(menu-item "Face Background..." doremi-face-bg+
;; :help "Change background color of a face incrementally: `up'/`down'"))
;; (define-key menu-bar-doremi-menu [doremi-frame-vertically+]
;; '(menu-item "Move Frame" doremi-frame-vertically+
;; :help "Move frame incrementally: `up'/`down'/`left'/`right'"))
;; (define-key menu-bar-doremi-menu [doremi-frame-height+]
;; '(menu-item "Frame Size" doremi-frame-height+
;; :help "Resize frame incrementally: `up'/`down'/`left'/`right'"))
;;
;;
;; TO DO?
;;
;; 1. Factor out more common stuff between foreground and background.
;; 2. Make it easy to turn on and off doremi-push-frame-config stuff.
;; 3. Integrate more with Customize.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Change Log:
;;
;; 2022/03/26 dadams
;; doremi-push-frame-config-for-command, doremi-frame-configs+: Removed condion that ring+.el be loaded.
;; 2020/11/05 dadams
;; Wrap soft-require of palette.el with condition-case to ignore error if error hard-requiring vline.el.
;; 2015/07/26 dadams
;; Added: doremi-customization-status, doremi-update-face-customization-status.
;; doremi-increment-color, doremi-face-(bg|fg)-hue-stepping-saturation+,
;; doremi-face-(bg|fg)+:
;; Use doremi-update-face-customization-status.
;; doremi-face-bg/fg-1:
;; Removed put of properties customized-face and face-modified onto FACE.
;; 2015/07/08 dadams
;; doremi-increment-color:
;; Raise error if x-color-values returns nil (probably from "unspecified-[bf]g").
;; Everywhere: Use %S, not %s in error messages for unknown values.
;; 2013/06/06 dadams
;; Do not require ring+.el unless prior to Emacs 23.
;; 2012/03/02 dadams
;; Added doremi-delete-if: to avoid runtime load of cl.el.
;; doremi-frame-config-wo-parameters: Use doremi-delete-if.
;; 2011/01/04 dadams
;; Removed autoload cookies from non def* sexps and non-interactive functions.
;; Added missing autoload cookies for defgroup, defcustom, defalias, commands.
;; 2010/10/19 dadams
;; doremi-frame-color-component, doremi-bg/fg-color-name-1, doremi-set-frame-color:
;; Replace frame-update-face-colors with frame-set-background-mode for > Emacs 20.
;; 2009/11/14 dadams
;; Added: doremi(-face)-(bg|fg)-hue-stepping-saturation+,
;; doremi-(face|frame)-hue-stepping-saturation. (No keys bound.) Thx to Ahei.
;; 2009/11/10 dadams
;; Added: doremi(-face)-bg/fg-color-name-1. Thx to Ahei.
;; doremi(-face)-(bg|fg)-color-name+: Use doremi(-face)-bg/fg-color-name-1. Add args.
;; 2009/11/07 dadams
;; Added: doremi-adjust-increment-for-color-component, doremi-face-bg/fg-1,
;; doremi-face-color-component, doremi-increment-face-color
;; doremi-face-default, doremi-increment-(blue|green|red),
;; doremi-all-(frames|faces)-bg/fg-1,
;; doremi-all-frames-(bg|fg)+: Use *-all-frames-bg/fg-1, *-read-component.
;; Set increment to 1 if nil. Use only visible frames.
;; doremi-face-(bg|fg)+:
;; Added interactive-p arg. Use *-face-bg/fg-1. Set *-last-face-value only when
;; interactive. Wrap in condition-case for C-g. Handle R, H, and list of
;; increments, via *-face-bg/fg-1 and *-face-color-component.
;; doremi-all-faces-(bg|fg)+: Use *-all-faces-bg/fg-1 (handles R, H, increment list).
;; doremi-all-(frames|faces)-bg/fg-1 (new), doremi-(frame|face)-color-component:
;; Use *-adjust-increment-for-color-component.
;; doremi-increment-color: Use doremi-increment-(blue|green|red).
;; 2009/11/05 dadams
;; Renamed all Do Re Mi iterative commands by appending +.
;; 2009/11/04 dadams
;; Added: doremi-(bg|fg)-1, doremi-current-increment, doremi-frame-color-component,
;; doremi-increment-(back|fore)ground-color-1,
;; doremi-increment-frame-color, doremi-read-component, doremi-set-frame-color.
;; doremi-read-increment-arg: Redefined - allow list of numbers, added LENGTH arg.
;; doremi-increment-color: Allow a list value for increment.
;; Use doremi-read-increment-arg everywhere, with args 3 and 1.
;; doremi-(bg|fg), doremi-increment-(back|fore)ground-color:
;; Added interactive-p arg. Use doremi-read-component.
;; Set *-last-frame-color only when interactive.
;; Use *-1 helper fn. Wrap in condition-case for C-g.
;; doremi-(bg|fg): Handle R, H, and a list of increments, via *-(bg|fg)-1 and
;; *-frame-color-component.
;; doremi-set-(back|fore)ground-color: Use doremi-set-frame-color.
;; 2009/11/03 dadams
;; Renamed: doremi-number-arg to doremi-read-increment-arg.
;; 2009/11/02 dadams
;; Added: doremi-face-(bg|fg)-color-name, doremi-fg-color-name. Thx to Ahei.
;; doremi-face-(bg|fg): Added unwind-protect, to delete sample buffer & window.
;; Inhibit frame fitting.
;; doremi-(bg|fg)-color-name, doremi-increment-color-component:
;; Use the function hexrgb-defined-colors(-alist), not the constant.
;; doremi-face-set: Don't define it for Emacs 20.
;; 2009/08/05 dadams
;; doremi-RGB-increment-factor: Changed default value to 1.
;; doremi-increment-*ground-color: Back up doremi-last-frame-color if interactive.
;; 2009/08/04 dadams
;; Added: doremi-RGB-increment-factor.
;; doremi(-all-(frames|faces)|-face)-(bg|fg):
;; Use doremi-RGB-increment-factor, not 256.
;; doremi-all-faces-(bg|fg): Scale by doremi-RGB-increment-factor (forgot to scale).
;; Thx to Stefan Guath.
;; 2009/06/26 dadams
;; doremi-frame-width, doremi-frame-horizontally:
;; Use new key-list options, doremi-...-keys (not -key).
;; 2008/01/03 dadams
;; doremi(-face)-(bg|fg), doremi-all-frames-(bg|fg):
;; Scale increment arg by 256 for RGB.
;; doremi-increment-color(-component): Do not scale INCREMENT arg by 256 for RGB.
;; doremi-increment-color: Limit INCREMENT from -100 to 100 for HSV only.
;; 2007/12/31 dadams
;; doremi-last-face-value: Use copy-face instead of internal-find-face.
;; 2007/12/30 dadams
;; doremi-all-(faces|frames)-(bg|fg): Bound doremi-wrap-color-flag to nil.
;; 2007/11/01 dadams
;; doremi-frame-(horizontally|vertically): Don't use doremi-number-arg.
;; Lowercased all :groups.
;; 2007/10/26 dadams
;; doremi-last-frame-color: Initial value is nil now.
;; doremi-undo-last-frame-color-change: Added error message if no last frame color.
;; 2007/10/21 dadams
;; Renamed: doremi-wrap-or-limit to doremi-wrap-or-limit-color-component.
;; Redefined it using doremi-limit and doremi-wrap.
;; 2007/10/08 dadams
;; Use lowercase for defgroup group.
;; 2007/09/30 dadams
;; doremi-face-set: (setq attrs (cdr attrs)) -> (setq attrs (cddr attrs)).
;; 2006/06/23 dadams
;; picked-(back|fore)ground -> eyedrop-picked-(back|fore)ground
;; Require eyedropper.el or palette.el, depending on the Emacs version.
;; doremi(-face)-(bg|fg):
;; Added pickup-p arg. Use picked color if pickup-p arg or C-u (not <0).
;; doremi-(bg|fg)-*: Call doremi-(bg|fg) with pickup-p arg.
;; Bug fix, doremi(-face)-(bg|fg):
;; Only pick up picked bg or fg on first call (interactive).
;; Tolerate no load of pick-up code.
;; 2006/06/06 dadams
;; Use hexrgb-defined-colors(-alist) instead of x-defined-colors.
;; 2006/05/30 dadams
;; doremi-increment-color-component: Use hexrgb-color-name-to-hex.
;; Removed: doremi-color-name-to-RGB.
;; 2006/01/07 dadams
;; Added :link.
;; 2005/12/26: dadams
;; Updated group and parent groups.
;; 2005/12/13 dadams
;; doremi-increment-face-(b|f)g-color:
;; Bug fix: Only update doremi-last-face(-value) when interactive.
;; 2005/08/09 dadams
;; Added: doremi-wrap-color-flag, doremi-wrap-or-limit, doremi-toggle-wrap-color,
;; toggle-doremi-wrap-color.
;; doremi-increment-color: Take doremi-wrap-color-flag into account.
;; Use doremi-wrap-or-limit.
;; 2005/08/02 dadams
;; Added: doremi-all-faces-(b|f)g, doremi-all-frames-(b|f)g,
;; doremi-set-(back|fore)ground-color.
;; doremi-(b|f)g, doremi-increment-(back|fore)ground-color,
;; doremi-undo-last-frame-color-change, doremi-increment-color: Added frame arg.
;; doremi-increment-color: Updated doc string. Lower bound of increment is -100.
;; doremi-increment-face-(b|f)g-color: Use nil frame arg to doremi-increment-color.
;; Save face arg as last face.
;; doremi-increment-(back|fore)ground-color: Use doremi-number-arg.
;; doremi-(b|f)g, doremi-increment-(back|fore)ground-color:
;; Use doremi-set-(back|fore)ground-color instead of set-(back|fore)ground-color.
;; doremi-color-name-to-RGB: Use facemenu-read-color, instead of completing-read.
;; doremi-last-face-value, doremi-last-frame-color: Better default values.
;; doremi-undo-last-face-change: Error if no last face.
;; Only require strings.el if read-number is not fboundp.
;; 2005/07/31 dadams
;; Added: doremi-color-name-to-RGB, doremi-number-arg.
;; doremi-frame-(horizontally|vertically), doremi-(bg|fg),
;; doremi-increment-face-color-read-args, doremi-increment-color-component:
;; Use doremi-number-arg.
;; doremi-increment-color-component: Made into a command.
;; doremi-face-(fg|bg): Use doremi-increment-face-color-read-args.
;; 2005/07/29 dadams
;; Added: doremi-increment-color-component.
;; 2005/07/25 dadams
;; Added: :prefix to defgroup.
;; 2005/07/17 dadams
;; doremi-increment-color: Limit increment to 100 max.
;; Mention in doc strings that increment max is 100.
;; 2005/07/02 dadams
;; Added: doremi-fg*, doremi-increment-foreground-color,
;; doremi-undo-last-frame-color-change, doremi-last-frame-color.
;; 2005/07/01 dadams
;; doremi-face-[fb]g: Added treatment of negative prefix arg (use picked color).
;; doremi-face-[fb]g-1: Use increment arg, already normalized by caller.
;; doremi-undo-last-face-change: Use doremi-last-face directly.
;; 2005/06/30 dadams
;; doremi-face-[fb]g:
;; Also display sample of face before changes.
;; Save face before changes, for doremi-undo-last-face-change.
;; Error if face arg doesn't name a face.
;; Added: doremi-last-face-value, doremi-undo-last-face-change.
;; Removed: doremi-face-(fore|back)ground (to faces+.el as face-(fore|back)ground-20+.
;; Hard require faces+.el.
;; 2005/06/28 dadams
;; doremi-face-[fb]g: Pop up a sample.
;; Added: doremi-face-[fb]g-1.
;; 2005/06/26 dadams
;; doremi-increment-color: Fixed bug when face was a symbol, not a variable - use
;; apply instead of eval funcall.
;; 2005/06/24 dadams
;; doremi-face-[bf]g:
;; 1) No longer convert face to internal-get-face form.
;; 2) Use face, instead of face-name.
;; 3) No longer use doremi-face-set. Use set-face-attribute or modify-face.
;; doremi-increment-face-[bf]g-color: ensure face via facep, not internal-get-face.
;; doremi-face-set: No longer use face-spec-set. This should be OK for Emacs 22,
;; but it is not used, for now.
;; 2005/05/29 dadams
;; Renamed: doremi-frame-move-wrap-within-display ->
;; doremi-move-frame-wrap-within-display-flag.
;; 2005/01/25 dadams
;; doremi-face-bg, doremi-face-fg (bug fix):
;; 1) Use internal-get-face, not facemenu-get-face.
;; 2) Use face-name for face arg to doremi-face-set.
;; doremi-increment-face-fg-color (and -bg-) (bug fix): Use internal-get-face.
;; doremi-frame-move-wrap-within-display: defvar -> defcustom.
;; 2005/01/18 dadams
;; Added Note on saving changes.
;; 2005/01/16 dadams
;; 1. Added: doremi-face-set, doremi-face-foreground, doremi-face-background.
;; 2. doremi-face-fg, doremi-face-bg, doremi-increment-face-fg-color,
;; doremi-increment-face-bg-color: Use doremi-face-set and doremi-face-foreground
;; or doremi-face-background.
;; 2005/01/15 dadams
;; doremi-increment-color and functions that call it: default is hue.
;; Added: doremi-bg-cyan, doremi-bg-magenta, doremi-bg-yellow.
;; 2005/01/09 dadams
;; Renamed: doremi-bg-rgb to doremi-bg, doremi-increment-face-bg-hex to
;; doremi-increment-face-bg-color, doremi-increment-face-fg-hex to
;; doremi-increment-face-fg-color, doremi-face-bg-rgb to doremi-face-bg,
;; doremi-face-fg-rgb to doremi-face-fg, doremi-increment-background-hex to
;; doremi-increment-background-color.
;; Treat HSV now too: doremi-bg, doremi-increment-background-color, doremi-face-fg,
;; doremi-increment-face-fg-color, doremi-face-bg,
;; doremi-increment-face-bg-color, doremi-bg-value.
;; Added: doremi-bg-hue, doremi-bg-saturation, doremi-bg-value (HSV version),
;; doremi-bg-brightness, doremi-bg-purity, doremi-push-frame-config-for-cmds-flag,
;; doremi-increment-color, doremi-increment-face-color-read-args.
;; doremi-increment-background-color, doremi-increment-face-bg-color,
;; doremi-increment-face-fg-color: Factored out common parts to create
;; doremi-increment-color and doremi-increment-face-color-read-args.
;; Fixed to use characters, not symbols: doremi-bg-red, doremi-bg-green,
;; doremi-bg-blue, doremi-bg-hue, doremi-bg-saturation, doremi-bg-value,
;; doremi-bg-brightness, doremi-bg-purity.
;; Do not do doremi-push-frame-config-for-command by default
;; (doremi-push-frame-config-for-cmds-flag is nil).
;; 2005/01/08 dadams
;; Moved doremi-grow-font to frame-cmds.el, and renamed it to enlarge-font.
;; 2005/01/07 dadams
;; doremi-grow-font: Treat error when new size is too small.
;; 2005/01/01 dadams
;; defvar -> defcustom. Added (defgroup doremi-frm).
;; 2004/12/28 dadams
;; doremi-bg-rgb:
;; You can now chain from changing one parameter to another.
;; Color parameter (r,g,b,v) is now character type, not symbol type.
;; Changed arg order.
;; doremi-increment-background-hex:
;; COMPONENT is a character, not symbol.
;; Changed arg order.
;; Added: doremi-face-bg-rgb, doremi-face-fg-rgb, doremi-increment-face-bg-hex,
;; doremi-increment-face-fg-hex.
;; 2004/11/28 dadams
;; Rewrote doremi-frame-horizontally and doremi-frame-vertically to:
;; 1) move frame off the display
;; 2) wrap frame around display
;; Added: doremi-frame-new-position, doremi-frame-move-wrap-within-display.
;; Require frame-fns.el[c]. Hard require ring+.el[c].
;; 2004/10/17 dadams
;; doremi-grow-font: Fixed for Emacs 21: set point size and width to "*"
;; 2004/10/11 dadams
;; doremi-frame-(horizontally|vertically):
;; 1. If start off screen, move frame back on screen (no error).
;; 2. Use modify-frame-parameters, not set-frame-position, bc unchanging
;; value could be a cons.
;; 3. Chain each off of the other, so can use all four arrows.
;; 2004/09/26 dadams
;; Renamed do-re-mi* to doremi*.
;; Prefixed everything here with doremi-.
;; Removed "adjust", "cycle", and "move" from names.
;; 2004/09/23 dadams
;; doremi-grow-font: Removed font-info stuff (unused).
;; doremi-frame-width, doremi-frame-horizontally:
;; Changed key sequences to events.
;; 2004/09/21 dadams
;; doremi-push-frame-config-for-command: Message only if interactive-p.
;; 2004/09/20 dadams
;; Added: doremi-bg-blue, doremi-bg-brightness,
;; doremi-bg-green, doremi-bg-red,
;; doremi-bg-rgb, doremi-increment-background-hex.
;; Renamed doremi-adjust-bg-color to doremi-bg-color-name.
;; Changed suggested binding C-xtc to doremi-bg-rgb.
;; Apply doremi-push-frame-config-for-command to new commands.
;; 2004/09/19 dadams
;; Corrected interactive spec for doremi-font-size
;; 2004/09/17 dadams
;; Added non-nil allow-new-p to doremi-adjust-bg-color
;; 2004/09/11 dadams
;; Created this from stuff in doremi.el and frame-cmds.el
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
;; Floor, Boston, MA 02110-1301, USA.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Code:
(require 'doremi) ;; doremi, doremi-limit, doremi-wrap
(require 'hexrgb) ;; hexrgb-color-name-to-hex, hexrgb-color-values-to-hex,
;; hexrgb-defined-colors, hexrgb-defined-colors-alist,
;; hexrgb-increment-blue, hexrgb-increment-green, hexrgb-increment-red,
;; hexrgb-hsv-to-rgb, hexrgb-rgb-to-hsv
(require 'ring) ;; ring-insert, ring-member, ring-next (Emacs 23)
(unless (fboundp 'ring-member) ; < Emacs 23
(require 'ring+)) ;; ring-insert, ring-member, ring-next
(require 'frame-fns) ;; frame-geom-spec-cons, frame-geom-value-cons, get-a-frame
(require 'faces+) ;; face-background-20+, face-foreground-20+, Emacs 20: read-face-name
;; eyedrop-picked-background, eyedrop-picked-foreground
(if (fboundp 'defvaralias) ;; Emacs 22
(condition-case nil (require 'palette nil t) (error nil)) ; Requires `vline.el'.
(require 'eyedropper nil t))
(require 'frame-cmds nil t) ;; (no error if not found):
;; frame-configuration-to-register, enlarge-font
;; jump-to-frame-config-register
(unless (fboundp 'read-number)
(require 'strings nil t)) ;; (no error if not found): read-number (std in Emacs 22)
(eval-when-compile (require 'cl)) ;; case (plus, for Emacs 20: pop)
;; Quiet the byte-compiler
(defvar text-scale-mode) ; In `face-remap.el' (Emacs 23+)
(defvar text-scale-mode-amount) ; In `face-remap.el' (Emacs 23+)
;;;;;;;;;;;;;;;;;;;;;;;;
;;; User Options (Variables)
;;;###autoload
(defgroup doremi-frame-commands nil
"Commands to incrementally adjust face attributes and frame parameters."
:prefix "doremi-" :group 'doremi :group 'frames :group 'faces
:link `(url-link :tag "Send Bug Report"
,(concat "mailto:" "drew.adams" "@" "oracle" ".com?subject=\
doremi-frm.el bug: \
&body=Describe bug here, starting with `emacs -q'. \
Don't forget to mention your Emacs and library versions."))
:link '(url-link :tag "Other Libraries by Drew"
"https://www.emacswiki.org/emacs/DrewsElispLibraries")
:link '(url-link :tag "Download"
"https://www.emacswiki.org/emacs/download/doremi-frm.el")
:link '(url-link :tag "Description"
"https://www.emacswiki.org/emacs/Doremi")
:link '(emacs-commentary-link :tag "Commentary" "doremi-frm")
)
;;;###autoload
(defcustom doremi-customization-status 'customized
"How Customize is to treat Do Re Mi face changes.
Value determines whether Customize is aware of the changes and, if so,
how it views them. If the value is `customized' or `outside' then you
can check what has changed by using command `customize-unsaved' or
`customize-rogue', respectively. If the value is anything else then
there is no way to know what has changed, because you have effectively
told Customize that nothing has changed. The default value is
`customize', which means that you can use `customize-unsaved' to show
all changes and optionally save some or all of them.
Value What Customize Thinks Command to Check
--------------- ------------------------------ ----------------
`customized' Changes made using Customize `customize-unsaved'
`outside' Changes made outside Customize `customize-rogue'
anything else No changes made (no command)"
:type '(choice
(const :tag "Changes were made by Customize (set, not saved)" 'customized)
(const :tag "Changes were made outside Customize" 'outside)
(const :tag "No changes were made" 'ignore))
:group 'Doremi-Frame-Commands)
;;;###autoload
(defcustom doremi-frame-config-ring-size 20
"*Maximum number of stored frame configurations."
:type 'integer :group 'Doremi-Frame-Commands)
;;;###autoload
(defcustom doremi-move-frame-wrap-within-display-flag t
"*Non-nil means wrap frame movements within the display.
Commands `doremi-frame-horizontally+' and `doremi-frame-vertically+'
then move the frame back onto the display when it moves off of it.
If nil, you can move the frame as far off the display as you like."
:type 'boolean :group 'doremi-frame-commands)
;;;###autoload
(defcustom doremi-push-frame-config-for-cmds-flag nil
"*Non-nil means commands that change frame config save it first.
This is done by advising all commands that change frame configuration
when library `doremi-frm.el' is loaded."
:type 'boolean :group 'Doremi-Frame-Commands)
;;;###autoload
(defcustom doremi-RGB-increment-factor 1
"*Factor to scale up RGB incrementing for some Do Re Mi functions.
Because RGB incrementing is by nature finer scale than HSV
incrementing, some Do Re Mi commands automatically scale up the
incrementing by this factor, so you need not iterate (cycle) so many
times to see an appreciable change. When this is the case, it is
noted for the individual function.
The scale factor to use depends on how many hex digits there are in
your color representations. A scale factor of 16 (and an input
increment of 1) means that, for each RGB component, it is the second
component digit from the right, not the rightmost, that is incremented
with each key press. A factor of 256 means that the third digit from
the right cycles. The default value is 1: no scaling.
If the digit that would be cycled is greater than the length of your
color components, then no incrementation occurs. For example, if the
colors you use have the format #RRGGBB, so that each component has two
hex digits, then a factor of 256 is not appropriate, since it leaves
the component value unchanged (wraparound). In that case, change the
value.
In general, 256 is good for colors represented as #RRRRGGGGBBBB, 16 is
good for #RRRGGGBBB, and 1 (no scaling) is appropriate for #RRGGBB.
What counts is the color representation you use, not what Emacs can
actually display for your screen. On most platforms, Emacs can really
only display 8-bit color components, so #RRGGBB is the best it can do.
But you might well have defined your colors using the format
#RRRRGGGGBBBB. That's OK, and it lets you see information reflecting
a more precise correspondance between RGB codes and color names, but
that extra precision is in fact ignored by Emacs and your display.
Personally, I use the longer format, ##RRRRGGGGBBBB, because I like to
see more info about the colors I use, even though my display cannot
really distinguish that many. I also use libraries `hexrgb.el' and
`palette.el', and I convert color information between various formats
\(RGB, HSV, color names). So I prefer to use the finer-grained
format, even though I can't see all the differences it provides.
Thus, I customize this option to 256.
The commands that use this option to scale up incrementing do so for
convenience. You can always use other commands that perform no such
scaling. For example, `doremi-bg+' scales RGB, but you can use
`doremi-increment-background-color' instead, for finer tuning."
:type 'integer :group 'doremi-frame-commands)
;;;###autoload
(defcustom doremi-wrap-color-flag t
"*Non-nil means wrap color changes around past the max and min.
For example, if non-nil, a current color value has FFFF as the red
component, and the red component is incremented by 1, then the result
has a red component of 0000. If nil, the same example yields FFFF,
because the red component is already at its maximum."
:type 'boolean :group 'doremi-frame-commands)
;;; Internal Variables
(defvar doremi-frame-config-ring (make-ring doremi-frame-config-ring-size)
"Frame configuration ring.")
;; An Emacs 22 bug doesn't let us add t as a third arg here for `copy-face'.
(defvar doremi-last-face-value (cons 'doremi-last-face
(copy-face 'default 'doremi-last-face))
"Previous value of the last face changed by Do Re Mi.
That is, changed by `doremi-face-*' or `doremi-undo-last-face-change',
but not by `doremi-all-faces-*'.
A cons with the face name as `car' and the face value as `cdr'. The
face named `doremi-last-face' is a copy of the face before the change.
Command `doremi-undo-last-face-change' swaps the `cdr' with the
current value of the face named by the `car', so it toggles between
the last two values of the face.")
(defvar doremi-last-frame-color nil
"Previous value of last frame color changed by Do Re Mi.
That is, changed by `doremi-fg+' or `doremi-bg+' (or
`doremi-undo-last-frame-color-change' or
`doremi-increment-*ground-color' when used interactively), but not by
`doremi-all-frames-fg+' or `doremi-all-frames-bg+'.
A cons with `foreground-color' or `background-color' as `car' and the
color as `cdr'.
Command `doremi-undo-last-frame-color-change' swaps this with the
current color, so it toggles between the last two values.")
(defvar doremi-current-increment 0
"Increment input by user for current Do Re Mi command.")
;;; Miscellaneous Do Re Mi Frame Commands
;; This command uses an incremental growth function, `enlarge-font',
;; which is defined in `frame-cmds.el'.
;;;###autoload
(defalias 'doremi-font-size+ 'doremi-frame-font-size+)
;;;###autoload
(defun doremi-frame-font-size+ (&optional increment frame)
"Change font size for FRAME by INCREMENT.
Interactively, INCREMENT is given by the prefix argument.
Optional FRAME parameter defaults to current frame."
(interactive "p")
(doremi (lambda (inc) (enlarge-font inc frame)
(cdr (assq 'font (frame-parameters frame))))
(cdr (assq 'font (frame-parameters frame)))
increment
t))
;; This command uses an incremental growth function, `text-scale-increase',
;; which is defined in `face-remap.el' or (enhanced) in `face-remap+.el'.
(when (fboundp 'text-scale-increase) ; Emacs 23+.
(defun doremi-buffer-font-size+ (&optional increment)
"Change font size for current buffer by INCREMENT steps.
Interactively, INCREMENT is given by the prefix argument."
(interactive "p")
(unless (require 'face-remap nil t)
(error "This command requires library `face-remap.el'"))
(doremi (lambda (inc)
(let ((text-scale-mode-step 1.1)) (text-scale-increase inc))
(if text-scale-mode text-scale-mode-amount 0))
(if text-scale-mode text-scale-mode-amount 0)
increment
t)))
;; You can replace the enumeration list (x-list-fonts "*") with a list
;; of fonts you have. A short list is easier to work with, but you
;; can use long lists like these too:
;; (x-list-fonts "*")
;; (append w32-fixed-font-alist (list (generate-fontset-menu)))
;;
;; For example, you can use a short list like this:
;;
;; ("-*-Garamond-normal-i-*-*-*-*-96-96-p-*-iso8859-2"
;; "-*-*-normal-r-*-*-15-112-96-96-c-*-fontset-iso8859_1_15"
;; "-*-Arial-bold-i-*-*-*-*-96-96-p-*-iso8859-1"
;; "-*-Century Gothic-bold-i-*-*-*-*-96-96-p-*-iso8859-5"
;; "-*-Microsoft Sans Serif-normal-r-*-*-*-*-96-96-p-*-iso8859-4")
;;
;;;###autoload
(defun doremi-font+ ()
"Successively cycle among fonts, choosing by name.
Operates on the current frame. Cycled font list is (x-list-fonts \"*\")."
(interactive)
(doremi (lambda (newval) (set-frame-font newval) newval)
(frame-parameter (selected-frame) 'font)
nil ; ignored
nil ; ignored
(x-list-fonts "*")
'extend))
;; This command uses an absolute setting function. It rebinds `doremi-up-keys'
;; and `doremi-down-keys' so they are more intuitive for width.
;;;###autoload
(defun doremi-frame-width+ (&optional increment frame)
"Change width of current frame incrementally.
Width of frame FRAME is increased in increments of amount INCREMENT."
(interactive "p")
(let ((doremi-up-keys '(left)) ; More intuitive keys for width.
(doremi-boost-up-keys '(M-left))
(doremi-down-keys '(right))
(doremi-boost-down-keys '(M-right)))
(doremi (lambda (new-val) (set-frame-width frame new-val) new-val)
(frame-width frame)
(- increment))) ; Reverse, so arrows correspond.
(when (member (car unread-command-events)
(append doremi-up-keys doremi-boost-up-keys
doremi-down-keys doremi-boost-down-keys))
(doremi-frame-height+ increment frame)))
;; This command uses an absolute setting function.
;;;###autoload
(defun doremi-frame-height+ (&optional increment frame)
"Change height of current frame incrementally.
Height of frame FRAME is increased in increments of amount INCREMENT."
(interactive "p")
(doremi (lambda (new-val) (set-frame-height frame new-val) new-val)
(frame-height frame)
(- increment)) ; Reverse, so arrows correspond.
(when (member (car unread-command-events) '(left right M-left M-right))
(doremi-frame-width+ increment frame)))
;; ;; This does the same thing as `doremi-frame-height+'.
;; ;; Example command that uses an incrementing function, `enlarge-frame',
;; ;; defined in `frame-cmds.el'.
;; ;;;###autoload
;; (defun doremi-frame-height-bis+ (&optional increment frame)
;; "Change frame height incrementally."
;; (interactive "p")
;; (doremi (lambda (inc) (enlarge-frame inc frame) (frame-height frame))
;; (frame-height frame)
;; (- increment) ; Reverse, so arrows correspond.
;; t))
;; Move frame left/right incrementally.
;; This command uses an incremental growth function.
;; Rebinds `doremi-up-keys' and `doremi-down-keys': more intuitive for horizontal.
;; Uses default increment value of 10.
;;;###autoload
(defun doremi-frame-horizontally+ (&optional increment frame)
"Move frame left/right incrementally.
Prefix arg is the INCREMENT to move (default value interactively: 10).
FRAME defaults to the selected frame.
Variable `doremi-move-frame-wrap-within-display-flag' controls whether
or not you can move the frame completely off the display. The default
behavior (value `t') is to wrap frame movement around the display."
(interactive
(list (if current-prefix-arg (prefix-numeric-value current-prefix-arg) 10)))
(setq increment (or increment 10) ; 1 is too small
frame (or frame (selected-frame)))
(let ((doremi-up-keys '(left)) ; More intuitive keys for width.
(doremi-boost-up-keys '(M-left))
(doremi-down-keys '(right))
(doremi-boost-down-keys '(M-right)))
(doremi (lambda (incr)
(modify-frame-parameters
frame
(list (list 'left '+ (doremi-frame-new-position frame 'left incr))))
(frame-geom-spec-cons (assq 'left (frame-parameters frame)) frame))
(frame-geom-spec-cons (assq 'left (frame-parameters frame)) frame)
(- increment) ; Reverse, so arrows correspond.
t))
(when (member (car unread-command-events)
(append doremi-up-keys doremi-boost-up-keys
doremi-down-keys doremi-boost-down-keys))
(doremi-frame-vertically+ increment frame)))
;; Move frame up/down incrementally.
;; This command uses an incremental growth function.
;; Uses default increment value of 10.
;;;###autoload
(defun doremi-frame-vertically+ (&optional increment frame)
"Move frame up/down incrementally.
Prefix arg is the INCREMENT to move (default value interactively: 10).
FRAME defaults to the selected frame.
Variable `doremi-move-frame-wrap-within-display-flag' controls whether or
not you can move the frame completely off the display. The default
behavior (value `t') is to wrap frame movement around the display."
(interactive
(list (if current-prefix-arg (prefix-numeric-value current-prefix-arg) 10)))
(setq increment (or increment 10) ; 1 is too small
frame (or frame (selected-frame)))
(doremi (lambda (incr)
(modify-frame-parameters
frame
(list (list 'top '+ (doremi-frame-new-position frame 'top incr))))
(frame-geom-spec-cons (assq 'top (frame-parameters frame)) frame))
(frame-geom-spec-cons (assq 'top (frame-parameters frame)) frame)
(- increment) ; Reverse, so arrows correspond.
t)
(when (member (car unread-command-events) '(left right M-left M-right))
(doremi-frame-horizontally+ increment frame)))
(defun doremi-frame-new-position (frame type incr)
"Return the new TYPE position of FRAME, incremented by INCR.
TYPE is `left' or `top'.
INCR is the increment to use when changing the position."
(let ((new-pos
(+ incr (cadr (frame-geom-value-cons
type (cdr (assq type (frame-parameters frame)))))))
(display-dimension
(if (eq 'left type) (x-display-pixel-width) (x-display-pixel-height)))
(frame-dimension
(if (eq 'left type) (frame-pixel-width frame) (frame-pixel-height frame))))
(if (not doremi-move-frame-wrap-within-display-flag)
new-pos
(when (< new-pos (- frame-dimension)) (setq new-pos display-dimension))
(when (> new-pos display-dimension) (setq new-pos (- frame-dimension)))
new-pos)))
(defun doremi-push-current-frame-config ()
"Push the current frame configuration to `doremi-frame-config-ring'
after removing frame parameters `buffer-list' and `minibuffer'."