unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Xah Lee <xah@xahlee.org>
To: help-gnu-emacs@gnu.org
Subject: Re: weird font-lock / coding interaction
Date: Mon, 29 Oct 2007 04:31:15 -0700	[thread overview]
Message-ID: <1193657475.556169.94660@q3g2000prf.googlegroups.com> (raw)
In-Reply-To: <o2fhckoze9f.fsf@hasgksssven.desy.de>

On Oct 18, 7:30 am, Sven Utcke <utcke+n...@informatik.uni-hamburg.de>
wrote:
> Hi,
>
> I like to use 10x20 as my font in Emacs, and never had any problem so
> far.  However, here at my new employee I see weird interactions
> between font-lock and what might be a coding issue.  If, e.g., I use
> "\bf" in a LaTeX-mode file (deprecated, I know :-) I instead see what
> looks roughtly like "¥bf" (it's actually a differently looking
> Yen-symbol, presumably from a different font).
>
> Any idea what could be the reason and how to debug this?  I never
> before had any problem like this!


As Tim said, in emacs 22 you can just use “Ctrl+u Ctrl+x =”. (invokes
what-cursor-position)
If you don't have 22, prob better to just upgrade. Might solve your
prob too.

I was trying to write a code to print the font used anyway, not
successful but migth give you a start.

here's the doc:
http://xahlee.org/elisp/Text-Properties.html

here the code i started with
(defun xx ()
(interactive)
(insert
;(get-char-property (point) "face")
(text-properties-at (point))
)
)

as a after thought, pasted below is the
what-cursor-position source code from emacs 22.

  Xah
  xah@xahlee.org
∑ http://xahlee.org/

(defun what-cursor-position (&optional detail)
  "Print info on cursor position (on screen and within buffer).
Also describe the character after point, and give its character code
in octal, decimal and hex.

For a non-ASCII multibyte character, also give its encoding in the
buffer's selected coding system if the coding system encodes the
character safely.  If the character is encoded into one byte, that
code is shown in hex.  If the character is encoded into more than one
byte, just \"...\" is shown.

In addition, with prefix argument, show details about that character
in *Help* buffer.  See also the command `describe-char'."
  (interactive "P")
  (let* ((char (following-char))
	 (beg (point-min))
	 (end (point-max))
         (pos (point))
	 (total (buffer-size))
	 (percent (if (> total 50000)
		      ;; Avoid overflow from multiplying by 100!
		      (/ (+ (/ total 200) (1- pos)) (max (/ total 100) 1))
		    (/ (+ (/ total 2) (* 100 (1- pos))) (max total 1))))
	 (hscroll (if (= (window-hscroll) 0)
		      ""
		    (format " Hscroll=%d" (window-hscroll))))
	 (col (current-column)))
    (if (= pos end)
	(if (or (/= beg 1) (/= end (1+ total)))
	    (message "point=%d of %d (%d%%) <%d-%d> column=%d%s"
		     pos total percent beg end col hscroll)
	  (message "point=%d of %d (EOB) column=%d%s"
		   pos total col hscroll))
      (let ((coding buffer-file-coding-system)
	    encoded encoding-msg display-prop under-display)
	(if (or (not coding)
		(eq (coding-system-type coding) t))
	    (setq coding default-buffer-file-coding-system))
	(if (not (char-valid-p char))
	    (setq encoding-msg
		  (format "(%d, #o%o, #x%x, invalid)" char char char))
	  ;; Check if the character is displayed with some `display'
	  ;; text property.  In that case, set under-display to the
	  ;; buffer substring covered by that property.
	  (setq display-prop (get-text-property pos 'display))
	  (if display-prop
	      (let ((to (or (next-single-property-change pos 'display)
			    (point-max))))
		(if (< to (+ pos 4))
		    (setq under-display "")
		  (setq under-display "..."
			to (+ pos 4)))
		(setq under-display
		      (concat (buffer-substring-no-properties pos to)
			      under-display)))
	    (setq encoded (and (>= char 128) (encode-coding-char char
coding))))
	  (setq encoding-msg
		(if display-prop
		    (if (not (stringp display-prop))
			(format "(%d, #o%o, #x%x, part of display \"%s\")"
				char char char under-display)
		      (format "(%d, #o%o, #x%x, part of display \"%s\"->\"%s\")"
			      char char char under-display display-prop))
		  (if encoded
		      (format "(%d, #o%o, #x%x, file %s)"
			      char char char
			      (if (> (length encoded) 1)
				  "..."
				(encoded-string-description encoded coding)))
		    (format "(%d, #o%o, #x%x)" char char char)))))
	(if detail
	    ;; We show the detailed information about CHAR.
	    (describe-char (point)))
	(if (or (/= beg 1) (/= end (1+ total)))
	    (message "Char: %s %s point=%d of %d (%d%%) <%d-%d> column=%d%s"
		     (if (< char 256)
			 (single-key-description char)
		       (buffer-substring-no-properties (point) (1+ (point))))
		     encoding-msg pos total percent beg end col hscroll)
	  (message "Char: %s %s point=%d of %d (%d%%) column=%d%s"
		   (if enable-multibyte-characters
		       (if (< char 128)
			   (single-key-description char)
			 (buffer-substring-no-properties (point) (1+ (point))))
		     (single-key-description char))
		   encoding-msg pos total percent col hscroll))))))

      parent reply	other threads:[~2007-10-29 11:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-18 14:30 weird font-lock / coding interaction Sven Utcke
2007-10-22  9:38 ` What font is this symbol in (was: weird font-lock / coding interaction) Sven Utcke
2007-10-24  0:47   ` What font is this symbol in Tim X
2007-10-29  9:40     ` Sven Utcke
2007-10-29 11:31 ` Xah Lee [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1193657475.556169.94660@q3g2000prf.googlegroups.com \
    --to=xah@xahlee.org \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).