all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Extending the concept of pretty-greek with icons/images
@ 2007-09-05 11:30 Nordlöw
  2007-10-05 13:39 ` Johan Bockgård
  0 siblings, 1 reply; 3+ messages in thread
From: Nordlöw @ 2007-09-05 11:30 UTC (permalink / raw)
  To: help-gnu-emacs

We humans are very good at recognizing content based on images and
shapes, often more efficiently than we recognize words, at least when
the words are long. For this reason a text written in chinese and/or
japanese can more efficiently ("with a higher bandwidth") explain a
concept to to the reader than is possible with (western) alphabets.

When reading source code, especially C code, we are often confronted
by quite long function names, especially in C environments such as
GNOME. These function names are however built up of smaller words or
acronyms often separated by underline or capitalization. After having
seen the clever Emacs extensions pretty-lamda and pretty-greek (given
below) I have gotten a feeling that this concept of "visual
abbreviations" could be applied also to these contexts of long C
identifiers. I believe this would make reading such C source code
easier and more visually attractive. Wanting to try out my idea I
thought I could start simple by overlay/change all the gtk_ prefix
with a miniturized version of the GTK's main icon seen www.gtk.org
(http://www.gtk.org/images/gtk-logo-rgb.gif). Is this possible to do
easily in Emacs or do I have to change the internals (C code) of
Emacs?

Thanks in advance for any reflections or/and help,
Nordlöw

Emacs Lisp Sources for pretty-greek follows. Just add to .emacs,
evaluate and restart emacs or do M-x emacs-lisp-mode to activate the
hook:

;; Pretty Greek
;; This is BenignoUria modification to Pretty Lambda. Substitutes all
;; greek letter names with its character. Very nice if you use greek
;; letters as parameters in parts of your code.
(defun pretty-greek ()
  (let ((greek '("alpha" "beta" "gamma" "delta" "epsilon" "zeta" "eta"
"theta" "iota" "kappa" "lambda" "mu" "nu" "xi" "omicron" "pi" "rho"
"sigma_final" "sigma" "tau" "upsilon" "phi" "chi" "psi" "omega")))
    (loop for word in greek
	  for code = 97 then (+ 1 code)
	  do (let ((greek-char (make-char 'greek-iso8859-7 code)))
	       (font-lock-add-keywords
		nil
		`((,(concatenate
		     'string "\\(^\\|[^a-zA-Z0-9]\\)\\(" word "\\)[a-zA-Z]")
		   (0 (progn
			(decompose-region (match-beginning 2) (match-end 2))
			nil)))))
	       (font-lock-add-keywords
		nil
		`((,(concatenate
		     'string "\\(^\\|[^a-zA-Z0-9]\\)\\(" word "\\)[^a-zA-Z]")
		   (0 (progn (compose-region (match-beginning 2) (match-end 2)
					     ,greek-char)
			     nil)))))))))
(add-hook 'lisp-mode-hook 'pretty-greek)
(add-hook 'emacs-lisp-mode-hook 'pretty-greek)
;; (add-hook 'c-mode-common-hook 'pretty-greek)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Extending the concept of pretty-greek with icons/images
  2007-09-05 11:30 Extending the concept of pretty-greek with icons/images Nordlöw
@ 2007-10-05 13:39 ` Johan Bockgård
  2007-10-09  8:55   ` Nordlöw
  0 siblings, 1 reply; 3+ messages in thread
From: Johan Bockgård @ 2007-10-05 13:39 UTC (permalink / raw)
  To: help-gnu-emacs

Nordlöw <per.nordlow@gmail.com> writes:

> Wanting to try out my idea I thought I could start simple by
> overlay/change all the gtk_ prefix with a miniturized version of the
> GTK's main icon seen www.gtk.org
> (http://www.gtk.org/images/gtk-logo-rgb.gif). Is this possible to do
> easily in Emacs or do I have to change the internals (C code) of
> Emacs?

Something like

    (defun pretty-icons ()
      (add-to-list 'char-property-alias-alist '(display pretty))
      (add-to-list 'font-lock-extra-managed-props 'pretty)

      (font-lock-add-keywords
       nil
       `(("\\_<\\(foo\\)-"
          (1 '(face nil pretty ,(create-image "lock.xpm")))))))


http://i23.tinypic.com/2l93yuu.png

-- 
Johan Bockgård

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Extending the concept of pretty-greek with icons/images
  2007-10-05 13:39 ` Johan Bockgård
@ 2007-10-09  8:55   ` Nordlöw
  0 siblings, 0 replies; 3+ messages in thread
From: Nordlöw @ 2007-10-09  8:55 UTC (permalink / raw)
  To: help-gnu-emacs

On 5 Okt, 15:39, bojohan+n...@dd.chalmers.se (Johan Bockgård) wrote:
> Nordlöw <per.nord...@gmail.com> writes:
> > Wanting to try out my idea I thought I could start simple by
> > overlay/change all the gtk_ prefix with a miniturized version of the
> > GTK's main icon seenwww.gtk.org
> > (http://www.gtk.org/images/gtk-logo-rgb.gif). Is this possible to do
> > easily in Emacs or do I have to change the internals (C code) of
> > Emacs?
>
> Something like
>
>     (defun pretty-icons ()
>       (add-to-list 'char-property-alias-alist '(display pretty))
>       (add-to-list 'font-lock-extra-managed-props 'pretty)
>
>       (font-lock-add-keywords
>        nil
>        `(("\\_<\\(foo\\)-"
>           (1 '(face nil pretty ,(create-image "lock.xpm")))))))
>
> http://i23.tinypic.com/2l93yuu.png
>
> --
> Johan Bockgård

Superb, I'll try it!

Thanks,
Nordlöw

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-10-09  8:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-05 11:30 Extending the concept of pretty-greek with icons/images Nordlöw
2007-10-05 13:39 ` Johan Bockgård
2007-10-09  8:55   ` Nordlöw

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.