Re: [AUCTeX-devel] patch for the exam class.
> Uwe Brauerwrites: > I mean in (partial)gradtable. In part, you have (TeX-arg-literal " ") > which adds a space, i.e. `\part[100] ' to mimic an \item. > In (partial)gradtable, you have (TeX-arg-literal "") which actually does > nothing. I was wondering why it is necessary. You are absolutely right, that was from some other old code to add space which was not necessary here. Uwe ___ auctex-devel mailing list auctex-devel@gnu.org https://lists.gnu.org/mailman/listinfo/auctex-devel
Re: [AUCTeX-devel] patch for the exam class.
Uwe Brauerwrites: "Arash" == Arash Esbati writes: > >>> + (TeX-add-symbols >>> +'("part" [ "Points" ] (TeX-arg-literal " ")) >>> +'("subpart" [ "Points" ] (TeX-arg-literal " ")) > >>> +'("gradetable" [ "1. Option" ](TeX-arg-literal "")[ "2. Option" > ](TeX-arg-literal "")) >>> +'("partialgradetable" 1 [ "1. Option" ](TeX-arg-literal "")[ "2. > Option" ](TeX-arg-literal "")) > >> What's the rationale behind the (TeX-arg-literal "") here? You could >> write something like: > > You mean in (partial)gradtable or also in part? I mean in (partial)gradtable. In part, you have (TeX-arg-literal " ") which adds a space, i.e. `\part[100] ' to mimic an \item. > As for (partial)gradtable > > When I use Tex-insert-macro > RET > gradtable > Optional 1. Option: h > RET > Optional 2. Option: question > RET > > I obtain what I want, namely > > \gradetable[h][question] > > Are you saying this is a ugly hack. Fine I take your code, but my > «solution» works In (partial)gradtable, you have (TeX-arg-literal "") which actually does nothing. I was wondering why it is necessary. > Thanks again, I will take your suggestions, but I am bit curious about > my ugly hack solutions > '("extrafootheight" ["Measure"](TeX-arg-literal "")1) > '("gradetable" [ "1. Option" ](TeX-arg-literal "")[ "2. Option" > ](TeX-arg-literal "")) Same here, I'm asking why (TeX-arg-literal "") is necessary at all? I don't see the added value. Best, Arash ___ auctex-devel mailing list auctex-devel@gnu.org https://lists.gnu.org/mailman/listinfo/auctex-devel
Re: [AUCTeX-devel] patch for the exam class.
>>> "Arash" == Arash Esbatiwrites: > Hi Uwe, > Uwe Brauer writes: > You're welcome. I keep on giving some comments, I hope it's ok :-) Definitely ;-) >> +;;; Code: >> + >> +;;; Code: > You have a dupe here. ok >> +(defcustom LaTeX-exam-reftex-quick-id-key ?x >> + "Unique letter identifying exam class macros in RefTeX. >> + >> +A character argument for quick identification when RefTeX inserts >> +new labels with `reftex-label'. It must be unique. It is >> +initialized to ?x." >> + :group 'LaTeX-style >> + :type 'character) >> + >> +(defcustom LaTeX-exam-label "exm:" >> + "Default prefix to labels in environments of exam class." >> + :group 'LaTeX-style >> + :type 'string) > You should move these 2 variables into `tex-style.el' -- it contains > customizable variables for AUCTeX style files. ok >> + (TeX-add-symbols >> +'("part" [ "Points" ] (TeX-arg-literal " ")) >> +'("subpart" [ "Points" ] (TeX-arg-literal " ")) >> +'("gradetable" [ "1. Option" ](TeX-arg-literal "")[ "2. Option" ](TeX-arg-literal "")) >> +'("partialgradetable" 1 [ "1. Option" ](TeX-arg-literal "")[ "2. Option" ](TeX-arg-literal "")) > What's the rationale behind the (TeX-arg-literal "") here? You could > write something like: You mean in (partial)gradtable or also in part? As for (partial)gradtable When I use Tex-insert-macro RET gradtable Optional 1. Option: h RET Optional 2. Option: question RET I obtain what I want, namely \gradetable[h][question] Are you saying this is a ugly hack. Fine I take your code, but my «solution» works > '("gradetable" > [ TeX-arg-eval completing-read > (TeX-argument-prompt optional nil "Orientation") > '("v" "h") ] > [ TeX-arg-eval completing-read > (TeX-argument-prompt optional nil "Table index") > '("questions" "pages") ] ) >> +'("subsubpart" [ "Points" ] (TeX-arg-literal " ")) >> +'("question" ["Points"] (TeX-arg-literal " ")) >> +'("subpart" ["Points"] (TeX-arg-literal " ")) >> +'("subsubpart" ["Points"] (TeX-arg-literal " ")) > These 2 are also dupes. thanks >> +'("extrafootheight" ["Measure"] (TeX-arg-literal " ")) > I'm not an exam user, but I think this defintion is wrong. examdoc.pdf > page 99 says a usage like \extrafootheight[.5in]{.25in}. I would then > suggest something like You are right But the ugly hack '("extrafootheight" ["Measure"](TeX-arg-literal "")1) Would also work, however I will take your solution :-D >'("extrafootheight" [ TeX-arg-length "Extra height 1. page footer" ] > (TeX-arg-length "Extra height footers")) >> +'("Alph" 0) ;ok >> +'("Roman" 0);ok >> +'("alph" 0) ;ok >> +'("arabic" 0) ;ok > These are already in latex.el. You don't need them. Oops >> +'("answerlinelength" 1) ;ok >> +'("answerskip" 1) ;ok > These are set with \setlength in document? If so, you should move them > out of (TeX-add-symbols ...) and set them with (LaTeX-add-lengths): > (LaTeX-add-lengths "answerlinelength" "answerskip") >> +'("colorbox" 0) ;ok ok > You should drop this. \colorbox is defined in color.el and xcolor.el. > Depending on which package used by the user, this command will become > available. And while we're at it: page 70 says that the command > \shadedsolutions can be used if \usepackage{color} is in the preamble. > Then I suggest you move this line: >> +'("shadedsolutions" 0) ;ok ok > out of TeX-add-symbols and do something like this in the style hook: > (when (or (member "xcolor" (TeX-style-list)) > (member "color" (TeX-style-list))) > (TeX-add-symbols '("shadedsolutions" 0))) ok > Best, Arash Thanks again, I will take your suggestions, but I am bit curious about my ugly hack solutions '("extrafootheight" ["Measure"](TeX-arg-literal "")1) '("gradetable" [ "1. Option" ](TeX-arg-literal "")[ "2. Option" ](TeX-arg-literal "")) Uwe ___ auctex-devel mailing list auctex-devel@gnu.org https://lists.gnu.org/mailman/listinfo/auctex-devel
Re: [AUCTeX-devel] patch for the exam class.
Hi Uwe, Uwe Brauerwrites: > I send a patch (in 2 formats since I am not 100 % sure) which provides > support for the exam class. Thanks very much to essential contributions > from Arash. You're welcome. I keep on giving some comments, I hope it's ok :-) > +;;; Code: > + > +;;; Code: You have a dupe here. > +(defcustom LaTeX-exam-reftex-quick-id-key ?x > + "Unique letter identifying exam class macros in RefTeX. > + > +A character argument for quick identification when RefTeX inserts > +new labels with `reftex-label'. It must be unique. It is > +initialized to ?x." > + :group 'LaTeX-style > + :type 'character) > + > +(defcustom LaTeX-exam-label "exm:" > + "Default prefix to labels in environments of exam class." > + :group 'LaTeX-style > + :type 'string) You should move these 2 variables into `tex-style.el' -- it contains customizable variables for AUCTeX style files. > + (TeX-add-symbols > +'("part" [ "Points" ] (TeX-arg-literal " ")) > +'("subpart" [ "Points" ] (TeX-arg-literal " ")) > +'("gradetable" [ "1. Option" ](TeX-arg-literal "")[ "2. Option" > ](TeX-arg-literal "")) > +'("partialgradetable" 1 [ "1. Option" ](TeX-arg-literal "")[ "2. Option" > ](TeX-arg-literal "")) What's the rationale behind the (TeX-arg-literal "") here? You could write something like: '("gradetable" [ TeX-arg-eval completing-read (TeX-argument-prompt optional nil "Orientation") '("v" "h") ] [ TeX-arg-eval completing-read (TeX-argument-prompt optional nil "Table index") '("questions" "pages") ] ) > +'("subsubpart" [ "Points" ] (TeX-arg-literal " ")) > +'("question" ["Points"] (TeX-arg-literal " ")) > +'("subpart" ["Points"] (TeX-arg-literal " ")) > +'("subsubpart" ["Points"] (TeX-arg-literal " ")) These 2 are also dupes. > +'("extrafootheight" ["Measure"] (TeX-arg-literal " ")) I'm not an exam user, but I think this defintion is wrong. examdoc.pdf page 99 says a usage like \extrafootheight[.5in]{.25in}. I would then suggest something like '("extrafootheight" [ TeX-arg-length "Extra height 1. page footer" ] (TeX-arg-length "Extra height footers")) > +'("Alph" 0) ;ok > +'("Roman" 0);ok > +'("alph" 0) ;ok > +'("arabic" 0) ;ok These are already in latex.el. You don't need them. > +'("answerlinelength" 1) ;ok > +'("answerskip" 1) ;ok These are set with \setlength in document? If so, you should move them out of (TeX-add-symbols ...) and set them with (LaTeX-add-lengths): (LaTeX-add-lengths "answerlinelength" "answerskip") > +'("colorbox" 0) ;ok You should drop this. \colorbox is defined in color.el and xcolor.el. Depending on which package used by the user, this command will become available. And while we're at it: page 70 says that the command \shadedsolutions can be used if \usepackage{color} is in the preamble. Then I suggest you move this line: > +'("shadedsolutions" 0) ;ok out of TeX-add-symbols and do something like this in the style hook: (when (or (member "xcolor" (TeX-style-list)) (member "color" (TeX-style-list))) (TeX-add-symbols '("shadedsolutions" 0))) Best, Arash ___ auctex-devel mailing list auctex-devel@gnu.org https://lists.gnu.org/mailman/listinfo/auctex-devel
[AUCTeX-devel] patch for the exam class.
Hi I send a patch (in 2 formats since I am not 100 % sure) which provides support for the exam class. Thanks very much to essential contributions from Arash. Please tell me which form of the patch is more appropriate. Regards Uwe Brauer diff -r 021a78034fbd -r 05d2ddc50cef Makefile.in --- a/Makefile.in Thu Dec 22 15:19:11 2016 +0100 +++ b/Makefile.in Thu Dec 22 16:43:26 2016 + @@ -159,7 +159,7 @@ style/framed.elstyle/paracol.el style/menukeys.el \ style/bidi.el style/FiraMono.el style/FiraSans.el \ style/bicaption.el style/amsfonts.el style/subfiles.el \ - style/dcolumn.el + style/dcolumn.el style/exam.el STYLEELC = $(STYLESRC:.el=.elc) diff -r 021a78034fbd -r 05d2ddc50cef style/exam.el --- /dev/null Thu Jan 01 00:00:00 1970 + +++ b/style/exam.el Thu Dec 22 16:43:26 2016 + @@ -0,0 +1,338 @@ +;;; exam.el --- AUCTeX style for the (LaTeX) exam class + + +;; Copyright (C) 2016 Free Software Foundation, Inc. + +;; Author: Uwe Brauer+;; Created: 2016-03-06 +;; Keywords: tex + +;; This file is part of AUCTeX. + +;; AUCTeX is free software; you can redistribute it and/or modify it +;; under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 3, or (at your option) +;; any later version. + +;; AUCTeX is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with AUCTeX; see the file COPYING. If not, write to the Free +;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +;; 02110-1301, USA. + +;;; Commentary: + +;; This file adds support for the exam class. + +;; Acknowledgements +;; Arash Esbati for a almost complete rewrite. + +;;; Code: + +;;; Code: + +(defcustom LaTeX-exam-reftex-quick-id-key ?x + "Unique letter identifying exam class macros in RefTeX. + +A character argument for quick identification when RefTeX inserts +new labels with `reftex-label'. It must be unique. It is +initialized to ?x." + :group 'LaTeX-style + :type 'character) + +(defcustom LaTeX-exam-label "exm:" + "Default prefix to labels in environments of exam class." + :group 'LaTeX-style + :type 'string) + +(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" + +(defun LaTeX-exam-insert-label (_optional name type) + "Indent the line and query/insert a label incl. the \"\\label\" macro. +Arguments NAME and TYPE are the same as for the function +`LaTeX-label'. OPTIONAL is ignored." + (indent-according-to-mode) + (let ((currenv (LaTeX-current-environment))) +(LaTeX-label (or name currenv) (or type 'environment + +(TeX-add-style-hook + "exam" + (lambda () + + ;; Make our label prefix available ... + (let ((envs '("questions"))) + (dolist (env envs) + ;; to AUCTeX + (add-to-list 'LaTeX-label-alist + (cons env 'LaTeX-exam-label)) + ;; to RefTeX with `reftex-add-label-environments' + (when (fboundp 'reftex-add-label-environments) + (reftex-add-label-environments + `((,env ,LaTeX-exam-reftex-quick-id-key ,LaTeX-exam-label + "~\\ref{%s}" nil + (regexp "[Qq]uestions?" "[Nn]umbers?"))) + + (LaTeX-add-environments "solution" + "solutionorbox" + "solutionorlines" + "solutionordottedlines" + '("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 + "\\|" + "\\(titled\\)?question\\b" + "\\|" + "\\(sub\\|subsub\\)?part\\b")) + (LaTeX-set-paragraph-start)) + + (TeX-add-symbols +'("part" [ "Points" ] (TeX-arg-literal " ")) +'("subpart" [ "Points" ] (TeX-arg-literal " ")) +'("gradetable" [ "1. Option" ](TeX-arg-literal "")[ "2. Option" ](TeX-arg-literal "")) +'("partialgradetable" 1 [ "1.