help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: weird font-lock / coding interaction


From: Xah Lee
Subject: Re: weird font-lock / coding interaction
Date: Mon, 29 Oct 2007 04:31:15 -0700
User-agent: G2/1.0

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))))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]