1 (defun org-agenda-switch-to (&optional delete-other-windows
)
2 "Go to the Org-mode file which contains the item at point."
4 (let ((cb (current-buffer))
5 (line (org-current-line))
9 (with-current-buffer (get-buffer-create "OrgAgendaGotoLog")
10 (goto-char (point-max))
11 (insert "--------------------------------------------------------\n")
12 (insert (format "This command: %s\n" this-command
))
13 (insert (format "Last command: %s\n" last-command
))
14 (insert (format "Line/Column/Point: %d/%d/%d\n" line col pos
))))
15 (orglog-describe-char (point))
16 (let* ((marker (or (get-text-property (point) 'org-marker
)
18 (buffer (marker-buffer marker
))
19 (pos (marker-position marker
)))
20 (switch-to-buffer buffer
)
21 (and delete-other-windows
(delete-other-windows))
24 (when (eq major-mode
'org-mode
)
25 (org-show-context 'agenda
)
27 (and (outline-next-heading)
28 (org-flag-heading nil
))))
29 (let ((cb (current-buffer))
31 (with-current-buffer (get-buffer-create "OrgAgendaGotoLog")
32 (goto-char (point-max))
33 (insert (format "Arrived: %s %d\n" cb pos
))))))
35 (defun org-agenda-goto (&optional highlight
)
36 "Go to the Org-mode file which contains the item at point."
38 (let ((cb (current-buffer))
39 (line (org-current-line))
40 (col (current-column))
41 (buf (current-buffer))
43 (with-current-buffer (get-buffer-create "OrgAgendaGotoLog")
44 (goto-char (point-max))
45 (insert "--------------------------------------------------------\n")
46 (insert (format "This command: %s\n" this-command
))
47 (insert (format "Last command: %s\n" last-command
))
48 (insert (format "Line/Column/Point: %d/%d/%d\n" line col pos
))))
49 (orglog-describe-char (point))
50 (let* ((marker (or (get-text-property (point) 'org-marker
)
52 (buffer (marker-buffer marker
))
53 (pos (marker-position marker
)))
54 (switch-to-buffer-other-window buffer
)
57 (when (eq major-mode
'org-mode
)
58 (org-show-context 'agenda
)
60 (and (outline-next-heading)
61 (org-flag-heading nil
)))) ; show the next heading
62 (run-hooks 'org-agenda-after-show-hook
)
63 (and highlight
(org-highlight (point-at-bol) (point-at-eol)))
64 (let ((cb (current-buffer))
66 (with-current-buffer (get-buffer-create "OrgAgendaGotoLog")
67 (goto-char (point-max))
68 (insert (format "Arrived: %s %d\n" cb pos
))))))
71 (defun orglog-describe-char (pos)
72 "Describe the character after POS (interactively, the character after point).
73 The information includes character code, charset and code points in it,
74 syntax, category, how the character is encoded in a file,
75 character composition information (if relevant),
76 as well as widgets, buttons, overlays, and text properties."
78 (if (>= pos
(point-max))
79 (error "No character follows specified position"))
80 (let* ((char (char-after pos
))
81 (charset (char-charset char
))
82 (composition (find-composition pos nil nil t
))
84 (display-table (or (window-display-table)
86 standard-display-table
))
87 (disp-vector (and display-table
(aref display-table char
)))
88 (multibyte-p enable-multibyte-characters
)
89 (overlays (mapcar #'(lambda (o) (overlay-properties o
))
91 (char-description (if (not multibyte-p
)
92 (single-key-description char
)
94 (single-key-description char
)
96 (char-to-string char
)))))
98 (let ((tmp-buf (generate-new-buffer " *text-props*")))
101 (describe-text-properties pos tmp-buf
)
102 (with-current-buffer tmp-buf
(buffer-string)))
103 (kill-buffer tmp-buf
))))
104 item-list max-width unicode
)
107 (memq 'mule-utf-8
(find-coding-systems-region pos
(1+ pos
)))
108 (get-char-property pos
'untranslated-utf-8
))
109 (setq unicode
(or (get-char-property pos
'untranslated-utf-8
)
110 (encode-char char
'ucs
))))
113 ,(format "%s (%d, #o%o, #x%x%s)"
114 (apply 'propertize char-description
115 (text-properties-at pos
))
118 (format ", U+%04X" unicode
)
121 ,`(insert-text-button
122 ,(symbol-name charset
)
123 'type
'help-character-set
'help-args
'(,charset
))
124 ,(format "(%s)" (charset-description charset
)))
126 ,(let ((split (split-char char
)))
128 ,(if (= (charset-dimension charset
) 1)
129 (format "#x%02X" (nth 1 split
))
130 (format "#x%02X #x%02X" (nth 1 split
)
132 'action
(lambda (&rest ignore
)
133 (list-charset-chars ',charset
)
134 (with-selected-window
135 (get-buffer-window "*Character List*" 0)
136 (goto-char (point-min))
137 (forward-line 2) ;Skip the header.
138 (let ((case-fold-search nil
))
139 (search-forward ,(char-to-string char
)
142 "mouse-2, RET: show this character in its character set")))
144 ,(let ((syntax (syntax-after pos
)))
146 (internal-describe-syntax-value syntax
)
149 ,@(let ((category-set (char-category-set char
)))
150 (if (not category-set
)
152 (mapcar #'(lambda (x) (format "%c:%s"
153 x
(category-docstring x
)))
154 (category-set-mnemonics category-set
)))))
155 ,@(let ((props (aref char-code-property-table char
))
159 (push (format "%s:" (pop props
)) ps
)
160 (push (format "%s;" (pop props
)) ps
))
161 (list (cons "Properties" (nreverse ps
)))))
163 ,@(let ((key-list (and (eq input-method-function
165 (quail-find-key char
))))
168 (mapconcat #'(lambda (x) (concat "\"" x
"\""))
172 ,current-input-method
173 'type
'help-input-method
174 'help-args
'(,current-input-method
))))))
176 ,(encoded-string-description
177 (string-as-unibyte (char-to-string char
)) nil
))
179 ,@(let* ((coding buffer-file-coding-system
)
180 (encoded (encode-coding-char char coding
)))
182 (list (encoded-string-description encoded coding
)
183 (format "(encoded by coding system %S)" coding
))
184 (list "not encodable by coding system"
185 (symbol-name coding
)))))
189 (setq disp-vector
(copy-sequence disp-vector
))
190 (dotimes (i (length disp-vector
))
191 (setq char
(aref disp-vector i
))
193 (cons char
(describe-char-display
194 pos
(glyph-char char
)))))
195 (format "by display table entry [%s] (see below)"
198 (format "?%c" (glyph-char (car x
))))
201 (let ((from (car composition
))
202 (to (nth 1 composition
))
204 (components (nth 2 composition
))
207 (and (< from pos
) (buffer-substring from pos
)))
208 (setcar (cdr composition
)
209 (and (< next to
) (buffer-substring next to
)))
210 (dotimes (i (length components
))
211 (if (integerp (setq ch
(aref components i
)))
212 (push (cons ch
(describe-char-display pos ch
))
214 (setq component-chars
(nreverse component-chars
))
215 (format "composed to form \"%s\" (see below)"
216 (buffer-substring from to
))))
218 (let ((display (describe-char-display pos char
)))
219 (if (display-graphic-p (selected-frame))
222 "by this font (glyph code)\n"
223 (format " %s (#x%02X)"
224 (car display
) (cdr display
)))
227 (format "terminal code %s" display
)
228 "not encodable for terminal"))))))
230 (if (not (or disp-vector composition
))
232 ((and show-trailing-whitespace
233 (save-excursion (goto-char pos
)
234 (looking-at "[ \t]+$")))
235 'trailing-whitespace
)
236 ((and nobreak-char-display unicode
(eq unicode
'#xa0
))
238 ((and nobreak-char-display unicode
(eq unicode
'#xad
))
240 ((and (< char
32) (not (memq char
'(9 10))))
242 (if face
(list (list "hardcoded face"
245 'type
'help-face
'help-args
'(,face
))))))
246 ,@(let ((unicodedata (and unicode
247 (describe-char-unicode-data unicode
))))
249 (cons (list "Unicode data" " ") unicodedata
)))))
250 (setq max-width
(apply #'max
(mapcar #'(lambda (x)
251 (if (cadr x
) (length (car x
)) 0))
253 (with-current-buffer (get-buffer-create "OrgAgendaGotoLog")
254 (goto-char (point-max))
255 (set-buffer-multibyte multibyte-p
)
256 (let ((formatter (format "%%%ds:" max-width
)))
257 (dolist (elt item-list
)
259 (insert (format formatter
(car elt
)))
260 (dolist (clm (cdr elt
))
261 (if (eq (car-safe clm
) 'insert-text-button
)
262 (progn (insert " ") (eval clm
))
263 (when (>= (+ (current-column)
264 (or (string-match "\n" clm
)
269 (indent-to (1+ max-width
)))
275 (goto-char (point-min))
276 (re-search-forward "character:[ \t\n]+")
277 (let* ((end (+ (point) (length char-description
))))
278 (mapc #'(lambda (props)
279 (let ((o (make-overlay (point) end
)))
281 (overlay-put o
(car props
) (nth 1 props
))
282 (setq props
(cddr props
)))))
287 "\nThe display table entry is displayed by ")
288 (if (display-graphic-p (selected-frame))
290 (insert "these fonts (glyph codes):\n")
291 (dotimes (i (length disp-vector
))
292 (insert (glyph-char (car (aref disp-vector i
))) ?
:
293 (propertize " " 'display
'(space :align-to
5))
294 (if (cdr (aref disp-vector i
))
295 (format "%s (#x%02X)" (cadr (aref disp-vector i
))
296 (cddr (aref disp-vector i
)))
299 (let ((face (glyph-face (car (aref disp-vector i
)))))
301 (insert (propertize " " 'display
'(space :align-to
5))
303 (insert (concat "`" (symbol-name face
) "'"))
305 (insert "these terminal codes:\n")
306 (dotimes (i (length disp-vector
))
307 (insert (car (aref disp-vector i
))
308 (propertize " " 'display
'(space :align-to
5))
309 (or (cdr (aref disp-vector i
)) "-- not encodable --")
313 (insert "\nComposed")
314 (if (car composition
)
315 (if (cadr composition
)
316 (insert " with the surrounding characters \""
317 (car composition
) "\" and \""
318 (cadr composition
) "\"")
319 (insert " with the preceding character(s) \""
320 (car composition
) "\""))
321 (if (cadr composition
)
322 (insert " with the following character(s) \""
323 (cadr composition
) "\"")))
324 (insert " by the rule:\n\t("
325 (mapconcat (lambda (x)
326 (format (if (consp x
) "%S" "?%c") x
))
330 (insert "\nThe component character(s) are displayed by ")
331 (if (display-graphic-p (selected-frame))
333 (insert "these fonts (glyph codes):")
334 (dolist (elt component-chars
)
335 (insert "\n " (car elt
) ?
:
336 (propertize " " 'display
'(space :align-to
5))
338 (format "%s (#x%02X)" (cadr elt
) (cddr elt
))
340 (insert "these terminal codes:")
341 (dolist (elt component-chars
)
342 (insert "\n " (car elt
) ":"
343 (propertize " " 'display
'(space :align-to
5))
344 (or (cdr elt
) "-- not encodable --"))))
345 (insert "\nSee the variable `reference-point-alist' for "
346 "the meaning of the rule.\n"))
348 (if text-props-desc
(insert text-props-desc
)))))