I'm working on an assignment that used the unicode subscript k ("\_k"). However, instead of getting the subscripted k, I get this:
![][1]
The can still use subscripts with numbers and some letters, but not with 'k'.
I initially had the issue with emacs 24.3, and then was told to update to 24.4. The issue still persisted.
Has anyone else had this issue and found a solution?
I'm running on a Mac with Emacs v.24.4.1
Thanks in advance
EDIT
Here is my .emacs file:
(load-file (let ((coding-system-for-read 'utf-8))
(shell-command-to-string "agda-mode locate")))
(set-default-font "-apple-DejaVu_Sans-medium-normal-normal-*-*-*-*-*-p-0-iso10646-1")
; Change Control-c Control-, and Control-c Control-. in Agda mode
; so they show the normalized rather than the "simplified" goals
(defun agda2-normalized-goal-and-context ()
(interactive)
(agda2-goal-and-context '(3)))
(defun agda2-normalized-goal-and-context-and-inferred ()
(interactive)
(agda2-goal-and-context-and-inferred '(3)))
(eval-after-load "agda2-mode"
'(progn
(define-key agda2-mode-map (kbd "C-c C-,")
'agda2-normalized-goal-and-context)
(define-key agda2-mode-map (kbd "C-c C-.")
'agda2-normalized-goal-and-context-and-inferred)))
; This defines backslash commands for some extra symbols.
(eval-after-load "quail/latin-ltx"
'(mapc (lambda (pair)
(quail-defrule (car pair) (cadr pair) "TeX"))
'( ("\\bb" "𝔹") ("\\bl" "𝕃") ("\\bs" "𝕊")
("\\bt" "𝕋") ("\\bv" "𝕍") ("\\cv" "⋎")
("\\comp" "∘") ("\\m" "↦") ("\\om" "ω"))))
; This sets the Control-c Control-k shortcut to
; describe the character under your cursor.
(global-set-key "\C-c\C-k" 'describe-char)
(custom-set-variables
'(agda2-include-dirs
(quote ("." "/Users/dylanthiemann/Dropbox/University of Iowa/2nd Senior Year/Spring 2015/PLC/ial")))
)
And the bit of code is from Agda:
module bool-kleene-thms where
open import bool
open import bool-kleene
open import eq
&&ₖ-idem : ∀ (b : 𝔹ₖ) → b &&ₖ b ≡ b
&&ₖ-idem b = {!!}
tt-&&ₖ : ∀ (b : 𝔹ₖ) → tt &&ₖ b ≡ b
tt-&&ₖ b = {!!}
||ₖ-idem : ∀ (b : 𝔹ₖ) → b ||ₖ b ≡ b
||ₖ-idem b = {!!}
||ₖ-tt : ∀ (b : 𝔹ₖ) → b ||ₖ tt ≡ tt
||ₖ-tt b = {!!}
||ₖ-ff : ∀ (b : 𝔹ₖ) → b ||ₖ ff ≡ b
||ₖ-ff b = {!!}
Edit 2
Results of Ctrl-u Ctrl-x = on affected character:
position: 91 of 830 (11%), column: 2
character: ₖ (displayed as ₖ) (codepoint 8342, #o20226, #x2096)
preferred charset: unicode (Unicode (ISO10646))
code point in charset: 0x2096
script: symbol
syntax: w which means: word
category: .:Base, L:Left-to-right (strong)
to input: type "\_k" with Agda input method
buffer code: #xE2 #x82 #x96
file code: #xE2 #x82 #x96 (encoded by coding system utf-8-unix)
display: terminal code #xE2 #x82 #x96
I needed to install new fonts... I used this http://dejavu-fonts.org/wiki/Download and then installed using Font Books. The issue was then resolved!
Related
In emacs lisp (but answers relating to common lisp are also welcome) I have a library that uses a macro and I want to hijack one of the macro's arguments only when executed in a certain context. Essentially what I want is a macro:
; My macro. This is a sketch of what I want that doesn't work.
(defmacro hijack-f (body)
`(macrolet ((f (x) `(f (+ 1 ,x))))
,#body))
; Defined in the library, I don't want to deal with these
(defmacro f (x) x)
(defun g (x) (f x))
So that
(g 1) ; => 1
(hijack-f (g 1)) ; => 2
(hijack-f (hijack-f (g 1))) ; => 3
EDIT: #melpomene and #reiner-joswig correctly point out that f is expanded in g before hijack-f. As a followup is there a hijack-f such that:
(f 1) ; => 1
(hijack-f (f 1)) ; => 2
(hijack-f (hijack-f (f 1))) ; => 3
As far as I know, what you want is not possible because g does not contain an invocation of f. Instead f runs first and expands to (part of) the definition of g.
That is:
(defun g (x) (f x))
immediately turns into
(defun g (x) x)
Which then defines g as a function (whose value is (lambda (x) x)).
Messing with f at runtime doesn't affect anything because its invocation is long gone by the time you call g.
If you are happy for your f to be a function and not a macro, and to use CL not elisp, then you are after flet and a macro like this:
(defmacro hijack-f (&body body)
`(flet ((f (x)
(f (1+ x))))
,#body))
Given a global defintion of f:
(defun f (x)
x)
Then
> (hijack-f (f 1))
2
> (hijack-f (hijack-f (f 1)))
3
And so on.
(As others have pointed out, you can't hijack code that has already been compiled with a macro like this: you would need to do it by having f cooperate in the hijacking.)
Just switched to emacs today, was using the ccl app you get via apple store.
I'm getting the following when I try to load a file via C-c C-l:
While compiling UPDATE_BACK :
Bad lambda list : (SELECTOR &KEY |ȦÅ| |ȦǨ®| |ìÃë|
|ǵɨŤ| |È¡ÅÅ| |ÆÅ·ÇÆ|
|ŽĸÅ| |Ç«Å| ...)
[Condition of type CCL::COMPILE-TIME-PROGRAM-ERROR]
It seems to be an encoding issue since ccl reads it perfectly fine when I copy paste.
I've already set my ~/.emacs to include:
(set-language-environment "utf-8")
What am I doing wrong?
p.s. the original text was in Japanese (both kanji and kana); not sure if i'm using the wrong language environment?
edit: the original code:
(defun update_back
(
selector &key
a b c
...
)
(setf *db*
(mapcar
#'(lambda (row)
(when (funcall selector row)
(if a (setf (getf row :a) a))
(if b (setf (getf row :b) b))
(if c (setf (getf row :c) c))
...
)
row) *db*
)
)
)
where a b c are replaced by kanji/kana characters.
Hello I am following the quick introduction to racket. In chapter 5 they propose that this code (which worked fine):
(define (four p)
(define two-p (hc-append p p))
(vc-append two-p two-p))
would tipically be written by using let, so I wrote my code:
#lang slideshow
(define (square n)
(filled-rectangle n n))
(define (four p)
(let ([two-p (hc-apppend p p)])
(vc-append two-p two-p)))
but it doesn't work.
The error message is:
expand: unbound identifier in module in: hc-apppend
Just checking: Did you remember
#lang slideshow
as the first line?
Also, count the number of p characters! It is hc-append. The error mentions hc-apppend: it should be hc-append.
When I query the current value of the keymap, eg with M-: (current-local-map), it shows me something along these lines:
Value:
(keymap
(S-mouse-2 . muse-follow-name-at-mouse-other-window)
(mouse-2 . muse-follow-name-at-mouse)
(33554445 . muse-follow-name-at-point-other-window)
(S-return . muse-follow-name-at-point-other-window)
(13 . muse-follow-name-at-point)
(return . muse-follow-name-at-point)
keymap
(67108924 . muse-decrease-list-item-indentation)
(67108926 . muse-increase-list-item-indentation)
(M-return . muse-insert-list-item)
(33554441 . muse-previous-reference)
(S-iso-lefttab . muse-previous-reference)
(S-tab . muse-previous-reference)
(S-mouse-2 . muse-follow-name-at-mouse-other-window)
(mouse-2 . muse-follow-name-at-mouse)
(33554445 . muse-follow-name-at-point-other-window)
(9 . muse-next-reference)
(tab . muse-next-reference)
(3 keymap
(19 . muse-search)
(2 . muse-find-backlinks)
(tab . muse-insert-thing)
(9 . muse-insert-thing)
(16 . muse-project-publish)
(6 . muse-project-find-file)
(61 . muse-what-changed)
(22 . muse-browse-result)
(27 keymap
(20 . muse-publish-this-file))
(33554452 . muse-publish-this-file)
(20 . muse-project-publish-this-file)
(12 . font-lock-mode)
(5 . muse-edit-link-at-point)
(1 . muse-index))
keymap
(27 keymap
(9 . ispell-complete-word)))
I want instead of numbers see something more meaningful like (control ?c) return for example. How do I do that ?
Did you know the command C-h m (describe-mode), which usually shows a description of the current major and minor modes, usually with their keymaps?
(substitute-command-keys "\\{foo-map}") is what describe-mode uses internally to generate the user-friendly description of the keymap foo-map.
If you'd like to have something closer to the keymap structure, the API is documented in "Classifying Events" in the Emacs Lisp manual. For example,
(event-modifiers 33554445) ==> (shift control)
(format "%c" (event-basic-type 33554445)) ==> "m"
This is what you need: library help-fns+.el.
http://www.emacswiki.org/emacs/HelpPlus
http://www.emacswiki.org/emacs/download/help-fns%2b.el
That gives you, as C-h M-k, command describe-keymap, which gives you a human-readable description of any keymap bound to a variable. E.g.:
C-h M-k dired-mode-map
dired-mode-map
--------------
For more information check the manuals.
Local keymap for `dired-mode' buffers.
key binding
--- -------
e .. f dired-find-file
RET dired-find-file
C-o dired-display-file
C-t Prefix Command
ESC Prefix Command
SPC dired-next-line
! dired-do-shell-command
# dired-flag-auto-save-files
$ dired-hide-subdir
% Prefix Command
& dired-do-async-shell-command
* Prefix Command
+ dired-create-directory
- negative-argument
. dired-clean-directory
0 .. 9 digit-argument
: Prefix Command
dired-next-dirline
? dired-summary
A dired-do-search
B dired-do-byte-compile
C dired-do-copy
D dired-do-delete
G dired-do-chgrp
H dired-do-hardlink
L dired-do-load
M dired-do-chmod
O dired-do-chown
P dired-do-print
Q dired-do-query-replace-regexp
R dired-do-rename
S dired-do-symlink
T dired-do-touch
U dired-unmark-all-marks
X dired-do-shell-command
Z dired-do-compress
^ dired-up-directory
a dired-find-alternate-file
d dired-flag-file-deletion
g revert-buffer
h describe-mode
i dired-maybe-insert-subdir
j dired-goto-file
k dired-do-kill-lines
l dired-do-redisplay
m dired-mark
n dired-next-line
o dired-find-file-other-window
p dired-previous-line
q quit-window
s dired-sort-toggle-or-edit
t dired-toggle-marks
u dired-unmark
v dired-view-file
w dired-copy-filename-as-kill
x dired-do-flagged-delete
y dired-show-file-type
z kill-this-buffer
~ dired-flag-backup-files
DEL dired-unmark-backward
mouse-face
dired-mouse-find-file-other-window
??
C-t C-t image-dired-dired-toggle-marked-thumbs
C-t . image-dired-display-thumb
C-t a image-dired-display-thumbs-append
C-t c image-dired-dired-comment-files
C-t d image-dired-display-thumbs
C-t e image-dired-dired-edit-comment-and-tags
C-t f image-dired-mark-tagged-files
C-t i image-dired-dired-display-image
C-t j image-dired-jump-thumbnail-buffer
C-t r image-dired-delete-tag
C-t t image-dired-tag-files
C-t x image-dired-dired-display-external
C-M-d dired-tree-down
C-M-n dired-next-subdir
C-M-p dired-prev-subdir
C-M-u dired-tree-up
M-$ dired-hide-all
M-= dired-backup-diff
M-s Prefix Command
M-{ dired-prev-marked-file
M-} dired-next-marked-file
M-DEL dired-unmark-all-files
M-s a Prefix Command
M-s f Prefix Command
% & dired-flag-garbage-files
% C dired-do-copy-regexp
% H dired-do-hardlink-regexp
% R dired-do-rename-regexp
% S dired-do-symlink-regexp
% d dired-flag-files-regexp
% g dired-mark-files-containing-regexp
% l dired-downcase
% m dired-mark-files-regexp
% r dired-do-rename-regexp
% u dired-upcase
* C-n dired-next-marked-file
* C-p dired-prev-marked-file
* ! dired-unmark-all-marks
* % dired-mark-files-regexp
* * dired-mark-executables
* / dired-mark-directories
* ? dired-unmark-all-files
* # dired-mark-symlinks
* c dired-change-marks
* m dired-mark
* s dired-mark-subdir-files
* t dired-toggle-marks
* u dired-unmark
* DEL dired-unmark-backward
: d epa-dired-do-decrypt
: e epa-dired-do-encrypt
: s epa-dired-do-sign
: v epa-dired-do-verify
dired-undo
dired-next-line
dired-previous-line
dired-toggle-read-only
dired-undo
M-s f C-s dired-isearch-filenames
M-s f ESC Prefix Command
M-s a C-s dired-do-isearch
M-s a ESC Prefix Command
M-s f C-M-s dired-isearch-filenames-regexp
M-s a C-M-s dired-do-isearch-regexp
I just wrote the following based on Gilles' answer, so I figured I'd post it.
I see that Drew's describe-keymap has a very similar basis, but also covers various other use-cases, so offhand I'm inclined to suggest using that one as a more complete solution; but FWIW:
(defun my-describe-keymap (keymap)
"Describe a keymap using `substitute-command-keys'."
(interactive
(list (completing-read
"Keymap: " (let (maps)
(mapatoms (lambda (sym)
(and (boundp sym)
(keymapp (symbol-value sym))
(push sym maps))))
maps)
nil t)))
(with-output-to-temp-buffer (format "*keymap: %s*" keymap)
(princ (format "%s\n\n" keymap))
(princ (substitute-command-keys (format "\\{%s}" keymap)))
(with-current-buffer standard-output ;; temp buffer
(setq help-xref-stack-item (list #'my-describe-keymap keymap)))))
Here's a poor-man's implementation what describe-bindings (C-h b) gives you, but restricted to a particular keymap. The formatting isn't great, but should get you started:
(defun describe-keymap (keymap &optional prefix)
(pop-to-buffer "Keymap description")
(erase-buffer)
(describe-keymap-impl keymap prefix))
(defun describe-keymap-impl (keymap &optional prefix)
"show a description of keymap"
(let (keymaps-to-process)
(mapc (lambda (partofkeymap)
(when prefix
(insert (concat prefix " ")))
(insert (key-description (list partofkeymap)))
(insert " ")
(cond ((atom partofkeymap))
((listp (cdr partofkeymap))
(insert "prefix-key")
(if (eq 'keymap (cadr partofkeymap))
(setq keymaps-to-process (cons partofkeymap keymaps-to-process))))
(t
(insert (symbol-name (cdr partofkeymap)))))
(insert "\n"))
(if (and (symbolp keymap) (boundp keymap))
(symbol-value keymap)
keymap))
(while keymaps-to-process
(insert "\n\n")
(describe-keymap-impl (cddar keymaps-to-process) (concat prefix (key-description (list (caar keymaps-to-process)))))
(setq keymaps-to-process (cdr keymaps-to-process))))
nil)
I tested by evaluating both:
(describe-keymap emacs-lisp-mode-map)
(describe-keymap 'emacs-lisp-mode-map)
For a more modern approach, use the which-key-show-full-keymap command from the which-key package. It will ask you for a keymap and then show you all the bindings from that keymap, exactly like it would if you press a prefix key (if which-key-mode is enabled). That is, in the minibuffer, nice and clean.
From the documentation:
which-key-show-full-keymap is an interactive autoloaded compiled Lisp
function in ‘which-key.el’.
(which-key-show-full-keymap KEYMAP)
Show all bindings in KEYMAP using which-key. KEYMAP is selected
interactively from all available keymaps.
You can also use helpful-variable function from helpful package available in Melpa.
Here is sample output:
projectile-command-map is a variable defined in projectile.el.
Value
! projectile-run-shell-command-in-root
& projectile-run-async-shell-command-in-root
4 C-o projectile-display-buffer
4 D projectile-dired-other-window
4 a projectile-find-other-file-other-window
....
vs. standard output:
projectile-command-map is a variable defined in ‘projectile.el’.
Its value is shown below.
Keymap for Projectile commands after ‘projectile-keymap-prefix’.
This variable may be risky if used as a file-local variable.
Value:
(keymap
(33 . projectile-run-shell-command-in-root)
(38 . projectile-run-async-shell-command-in-root)
(53 keymap
(68 . projectile-dired-other-window)
(15 . projectile-display-buffer)
...
How can I write the following code quickly in emacs?
\newcommand{\cA}{\mathcal A}
\newcommand{\cB}{\mathcal B}
\newcommand{\cC}{\mathcal C}
...
...
\newcommand{\cY}{\mathcal Y}
\newcommand{\cZ}{\mathcal Z}
Is there a way faster than writing
A
B
C
D
.
.
.
Y
Z
and then doing macro on each line? (changing A to \newcommand{\cA}{\mathcal A})
I agree that a keyboard macro will get the result the quickest.
More fun is a programmatic approach:
(loop
for n from (string-to-char "A") to (string-to-char "Z")
for c = (char-to-string n)
do (insert (concat "\\newcommand{\\c" c "}{\\mathcal " c "}\n")))
In general, the first time you are confronted with this kind of problem, you'd use keyboard macros, as JB already said.
The second time, check out this very very interesting article by Steve Yegge: http://steve-yegge.blogspot.com/2006/06/shiny-and-new-emacs-22.html, which contains solutions for problems exactly like yours.
For your convenience, and my own illumination, I actually went ahead and tested it:
I would start with
A
...
A
26 times
and do a
M-x replace-regexp
A
\\newcommand{\\c\,(string (+ ?A \#))}{\\mathcal \,(string (+ ?A \#))}
A to Z is only 26 lines. You'd waste more time automating generation than just naturally using keyboard macros, imho.
It depends on your background. I'd just type M-! and:
perl -e"print map {q(\newcommand{\c).$_.q(}{\mathcal ).qq($_}\n)} A..Z
Do you know the rectangle selection ?
There's also string-rectangle:
place point (the cursor) at the beginning of the text, mark (C-SPC)
place point at the beginning of the last line
type M-x string-rectangle
type a string (\newcommand{\c)
This will insert that string before each line since the mark.
I don't have enough karma or whatever to comment, but I wanted to improve HD's style a bit.
Here is the original:
(loop
for n from (string-to-char "A") to (string-to-char "Z")
for c = (char-to-string n)
do (insert (concat "\\newcommand{\\c" c "}{\\mathcal " c "}\n")))
First off, Emacs Lisp has reader syntax for chars. Instead of (string-to-char "X"), you can just write ?X. Then, you can use the printf-style format instead of char-to-string and concat to produce the final result:
(loop for n from ?A to ?Z
do (insert (format "\\newcommand{\\c%s}{\\mathcal %s}\n" n n)))
Now it's concise enough to type without thinking into the M-: prompt.
I will also point out that TeX has macros too, if this is indeed TeX.
Edit: Another bit of style advice for Joe Casadonte; (incf foo) is much easier to type than (setq foo (+ foo 1)).
Or the interactive way if you want to do them one at a time
(defun somefun(inputval)
(interactive "sInputVal: ")
(insert ( format "\\newcommand{\\c%s}{\\mathcal %s}" inputval inputval) )
)
just eval and M-x somefun every time you want the text
Not exactly an answer.
For people who don't use emacs or vim, I'd like to add that you can open Excel and use its autofill feature and text concatenation function to generate such code.
I like HD's loop a little better than mine, but here's an alternate, more generalized approach:
(defun my-append (str)
"Substitute A-Z in STR and insert into current buffer.
Looks for '--HERE--' (without quotes) in string STR, substitutes the
letters A-Z in the string and then inserts the resulting string into
the current buffer."
(interactive "sInput String: ")
(let ((lcv 0)
letter newstr)
(while (< lcv 26)
(setq letter (+ ?A lcv))
(insert (replace-regexp-in-string "--HERE--" (char-to-string letter) str t t) "\n")
(setq lcv (+ lcv 1)))))
Shouldn't be too hard to combine the two.