[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [AUCTeX-devel] patch for exam class
From: |
Arash Esbati |
Subject: |
Re: [AUCTeX-devel] patch for exam class |
Date: |
Sun, 13 Nov 2016 14:20:00 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.1 |
Uwe Brauer <address@hidden> writes:
> Hi it seems that I sent this patch to the wrong list.
I'm not an exam user, but I think it would be nice if you add some code
in order to get "question" and "part" et al. inserted as an item while
you are in the respective environment.
You need to define a function like `LaTeX-exam-insert-item' and hook it
into AUCTeX. Some other comments are below:
--8<---------------cut here---------------start------------->8---
;;; Code:
(defvar LaTeX-exam-class-options '("answers" "addpoints")
"Class options for the exam class.")
(defun LaTeX-exam-insert-item ()
"Insert a new item in an environment from exam class.
Item inserted depends on the environment."
(TeX-insert-macro
(cond ((string= environment "questions")
"question")
((string= environment "parts")
"part")
((string= environment "subparts")
"subpart")
((string= environment "subsubparts")
"subsubpart")
;; Fallback
(t "item"))))
(TeX-add-style-hook
"exam"
(lambda ()
(LaTeX-add-environments "solution"
"solutionorbox"
'("questions" LaTeX-env-item)
'("parts" LaTeX-env-item)
'("subparts" LaTeX-env-item)
'("subsubparts" LaTeX-env-item))
;; Tell AUCTeX about special environments:
(let ((envs '("questions" "parts" "subparts" "subsubparts")))
(dolist (env envs)
(add-to-list 'LaTeX-item-list
(cons env 'LaTeX-exam-insert-item))))
;; Append us only once:
(unless (and (string-match "question" LaTeX-item-regexp)
(string-match "subsub" LaTeX-item-regexp))
(set (make-local-variable 'LaTeX-item-regexp)
(concat
LaTeX-item-regexp
"\\|"
"question\\b"
"\\|"
"\\(sub\\|subsub\\)?part\\b")))
(TeX-add-symbols
'("part" [ "Points" ] (TeX-arg-literal " "))
'("subpart" [ "Points" ] (TeX-arg-literal " "))
'("subsubpart" [ "Points" ] (TeX-arg-literal " "))
'("question" ["Points"] (TeX-arg-literal " "))
'("titledquestion" "Title" ["Points"])
'("droptotalpoints" 0)
'("droppoints" 0))
;; Fontification
(when (and (featurep 'font-latex)
(eq TeX-install-font-lock 'font-latex-setup))
(font-latex-add-keywords '(("question" "[")
("subpart" "[")
("subsubquestion" "["))
'textual)))
LaTeX-dialect)
;;; exam.el ends here
--8<---------------cut here---------------end--------------->8---
> + (TeX-add-symbols
> + '("part" TeX-arg-examn-points 0)
You don't need `TeX-arg-examn-points'. Adding ["Points"] suffices.
> + '("subpart" TeX-arg-examn-points 0)
> + '("subsubpart" TeX-arg-examn-points 0)
> + '("question" ["Points"] reftex-label)
Please don't use `reftex-label'. Non Reftex-user will get an error.
`TeX-arg-ref' does the right thing here.
> + '("titledquestion" "Title" ["Points"] reftex-label)
> + '("question" TeX-arg-examn-points 0)
> + '("droptotalpoints" 0)
> + '("droppoints" 0)
> + ))
> + LaTeX-dialect)
> +
> +(defun TeX-arg-examn-points (optional &optional prompt)
> + "Prompt for overlay specification and optional argument."
> + (let ((options (read-input "Points: ")))
,----[ C-h f read-input RET ]
| read-input is an alias for ‘read-string’ in ‘subr.el’.
|
| (read-input PROMPT &optional INITIAL-INPUT HISTORY DEFAULT-VALUE
| INHERIT-INPUT-METHOD)
|
| This function is obsolete since 22.1;
| use ‘read-string’ instead.
`----
AUCTeX has a compat function `TeX-read-string'. You should use that
one.
Best, Arash
- [AUCTeX-devel] patch for exam class, Uwe Brauer, 2016/11/11
- Re: [AUCTeX-devel] patch for exam class,
Arash Esbati <=
- [AUCTeX-devel] [problems with TeX-arg-ref] (was: patch for exam class), Uwe Brauer, 2016/11/14
- Re: [AUCTeX-devel] [problems with TeX-arg-ref] (was: patch for exam class), Mosè Giordano, 2016/11/14
- Re: [AUCTeX-devel] [problems with TeX-arg-ref], Uwe Brauer, 2016/11/14
- Re: [AUCTeX-devel] [problems with TeX-arg-ref], Mosè Giordano, 2016/11/15
- Re: [AUCTeX-devel] [problems with TeX-arg-ref], Uwe Brauer, 2016/11/15
- Re: [AUCTeX-devel] [problems with TeX-arg-ref], Arash Esbati, 2016/11/16