[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[AUCTeX] Small optimizations / was: Problem with latex2e style hook ---
From: |
Vincent Belaïche |
Subject: |
[AUCTeX] Small optimizations / was: Problem with latex2e style hook --- LaTeX/Texinfo collision |
Date: |
Fri, 15 Aug 2014 23:13:16 +0200 |
Hello Tassilo et alii,
Just to take things one by one, I amended the small optimization
contribution in the first place after your comment that assoc-string is
not XEmacs-compatible
[...]
> > Sorry for that, but I could not retain myself for doing other
> > changes --- beautifying and optimizing a few things --- attached to
> > this email as <auctex-optimizations.diff>.
> >
> > auctex-optimizations.diff patch isn't related with the latex2e style
> > hook problem, so I did it as a first change as I naively think that
> > it should not be contentious, and then
> > auctex-texinfo-style-hooks.diff is a second patch over that first
> > one.
>
> The patch is backwards. ;-)
>
> Oh, and at least `assoc-string' doesn't seem to be available in
> XEmacs, neither in the stable nor the beta release.
>
> Bye,
> Tassilo
I used a defalias to fallback to assoc in the case of XEmacs. Hopefully
defalias exists in XEmacs ... Use of a defalias means no overhead in the
byte-compiled package --- I think, but not being an EMACS lisp expert
this is just my speculation.
With this, do you think that the contribution is useful ?
Vincent.
diff --git a/ChangeLog b/ChangeLog
index 4da30d5..7140ec2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2014-08-15 Vincent Belaïche <address@hidden>
+
+ * tex-info.el (TeX-texinfo-mode): Code optimization: use
+ '(set (make-local-variable (quote foo)) some-value)' instead of
+ '(make-local-variable (quote foo)) (setq foo some-value)' wherever
+ possible. Add in style Texinfo standard macros '@acronym' and '@tie'.
+
+ * tex.el (TeX-assoc-string) new defalias to work-around missing
+ assoc-string in XEmacs. (TeX-unload-style): Code optimization: use
+ 'assoc-string' instead of 'assoc' to search style in
+ 'TeX-style-hook-list', and use delq on returned value of
+ assoc-string for removing the style --- on the one hand delq will
+ go through the whole list rather than stop after the first match
+ like in original code, but on the other hand comparison are faster
+ because eq instead of equal is used and we are working on assoc
+ cell rather than on key, so less indirection, furthermore delq is
+ C code. Anyway that make the code much smaller and easier to
+ understand.
+ (TeX-file-extensions): Add txi amongst extension of
+ texinfo files, for consistency with info node '(texinfo) Minimum'
+ (TeX-run-style-hooks): Code optimization: use 'assoc-string'
+ instead of 'assoc' to search style in 'TeX-style-hook-list'.
+
2014-01-06 Vincent Belaïche <address@hidden>
* tex-info.el (Texinfo-reftex-hook): Replace use of
diff --git a/tex-info.el b/tex-info.el
index a42884d..849e94f 100644
--- a/tex-info.el
+++ b/tex-info.el
@@ -544,38 +544,28 @@ value of `Texinfo-mode-hook'."
(setq major-mode 'texinfo-mode)
(use-local-map Texinfo-mode-map)
(set-syntax-table texinfo-mode-syntax-table)
- (make-local-variable 'page-delimiter)
- (setq page-delimiter
- (concat
- "address@hidden [ \t]*[Tt]op\\|address@hidden("
- texinfo-chapter-level-regexp
- "\\)"))
- (make-local-variable 'require-final-newline)
- (setq require-final-newline t)
- (make-local-variable 'indent-tabs-mode)
- (setq indent-tabs-mode nil)
- (make-local-variable 'paragraph-separate)
- (setq paragraph-separate
- (concat "\b\\|address@hidden \n]\\|" paragraph-separate))
- (make-local-variable 'paragraph-start)
- (setq paragraph-start
- (concat "\b\\|address@hidden \n]\\|" paragraph-start))
- (make-local-variable 'fill-column)
- (setq fill-column 72)
- (make-local-variable 'comment-start)
- (setq comment-start "@c ")
- (make-local-variable 'comment-start-skip)
- (setq comment-start-skip "@c +\\|@comment +")
+
+ (set (make-local-variable 'page-delimiter)
+ (concat
+ "address@hidden [ \t]*[Tt]op\\|address@hidden("
+ texinfo-chapter-level-regexp
+ "\\)"))
+ (set (make-local-variable 'require-final-newline) t)
+ (set (make-local-variable 'indent-tabs-mode) nil)
+ (set (make-local-variable 'paragraph-separate)
+ (concat "\b\\|address@hidden \n]\\|" paragraph-separate))
+ (set (make-local-variable 'paragraph-start)
+ (concat "\b\\|address@hidden \n]\\|" paragraph-start))
+ (set (make-local-variable 'fill-column) 72)
+ (set (make-local-variable 'comment-start) "@c ")
+ (set (make-local-variable 'comment-start-skip) "@c +\\|@comment +")
(set (make-local-variable 'comment-use-syntax) nil)
- (make-local-variable 'words-include-escapes)
- (setq words-include-escapes t)
- (if (not (boundp 'texinfo-imenu-generic-expression))
+ (set (make-local-variable 'words-include-escapes) t)
+ (if (boundp 'texinfo-imenu-generic-expression)
;; This was introduced in 19.30.
- ()
- (make-local-variable 'imenu-generic-expression)
- (setq imenu-generic-expression texinfo-imenu-generic-expression))
- (make-local-variable 'font-lock-defaults)
- (setq font-lock-defaults
+ (set (make-local-variable 'imenu-generic-expression)
texinfo-imenu-generic-expression))
+
+ (set (make-local-variable 'font-lock-defaults)
;; COMPATIBILITY for Emacs 20
(if (boundp 'texinfo-font-lock-syntactic-keywords)
'(texinfo-font-lock-keywords
@@ -586,48 +576,41 @@ value of `Texinfo-mode-hook'."
(if (not (boundp 'texinfo-section-list))
;; This was included in 19.31.
()
- (make-local-variable 'outline-regexp)
- (setq outline-regexp
- (concat "@\\("
- (mapconcat 'car texinfo-section-list "\\>\\|")
- "\\>\\)"))
- (make-local-variable 'outline-level)
- (setq outline-level 'texinfo-outline-level))
+ (set (make-local-variable 'outline-regexp)
+ (concat "@\\("
+ (mapconcat 'car texinfo-section-list "\\>\\|")
+ "\\>\\)"))
+ (set (make-local-variable 'outline-level) 'texinfo-outline-level))
;; Mostly AUCTeX stuff
(easy-menu-add Texinfo-mode-menu Texinfo-mode-map)
(easy-menu-add Texinfo-command-menu Texinfo-mode-map)
- (make-local-variable 'TeX-command-current)
- (setq TeX-command-current 'TeX-command-master)
+ (set (make-local-variable 'TeX-command-current) 'TeX-command-master)
(setq TeX-default-extension "texi")
- (make-local-variable 'TeX-esc)
- (setq TeX-esc "@")
- (make-local-variable 'TeX-auto-regexp-list)
- (setq TeX-auto-regexp-list 'TeX-auto-empty-regexp-list)
- (make-local-variable 'TeX-auto-update)
- (setq TeX-auto-update t)
+ (set (make-local-variable 'TeX-esc) "@")
+
+ (set (make-local-variable 'TeX-auto-regexp-list) 'TeX-auto-empty-regexp-list)
+ (set (make-local-variable 'TeX-auto-update) t)
(setq TeX-command-default "TeX")
(setq TeX-header-end "%*end")
(setq TeX-trailer-start (regexp-quote (concat TeX-esc "bye")))
-
- (make-local-variable 'TeX-complete-list)
- (setq TeX-complete-list
+
+ (set (make-local-variable 'TeX-complete-list)
(list (list "@\\([a-zA-Z]*\\)" 1 'TeX-symbol-list-filtered nil)
(list "" TeX-complete-word)))
- (make-local-variable 'TeX-font-list)
- (setq TeX-font-list Texinfo-font-list)
- (make-local-variable 'TeX-font-replace-function)
- (setq TeX-font-replace-function 'TeX-font-replace-macro)
+ (set (make-local-variable 'TeX-font-list) Texinfo-font-list)
+ (set (make-local-variable 'TeX-font-replace-function)
'TeX-font-replace-macro)
(add-hook 'find-file-hooks (lambda ()
(unless (file-exists-p (buffer-file-name))
(TeX-master-file nil nil t))) nil t)
(TeX-add-symbols
+ '("acronym" "Acronym")
'("appendix" (TeX-arg-literal " ") (TeX-arg-free "Title"))
'("appendixsec" (TeX-arg-literal " ") (TeX-arg-free "Title"))
'("appendixsection" (TeX-arg-literal " ") (TeX-arg-free "Title"))
@@ -735,6 +718,7 @@ value of `Texinfo-mode-hook'."
'("thischaptername")
'("thisfile")
'("thispage")
+ '("tie")
'("tindex" (TeX-arg-literal " ") (TeX-arg-free "Entry"))
'("title" (TeX-arg-literal " ") (TeX-arg-free "Title"))
'("titlefont" "Text")
diff --git a/tex.el b/tex.el
index 07c452e..281dd06 100644
--- a/tex.el
+++ b/tex.el
@@ -580,6 +580,13 @@ but does nothing in Emacs."
Also does other stuff."
(TeX-maybe-remove-help menu)))
+;;;###autoload
+(defalias 'TeX-assoc-string
+ (symbol-function (if (featurep 'xemacs) 'assoc 'assoc-string))
+ (concat "Compatibility alias that points to
+ function `assoc' with XEMACS and to function `assoc-string'
+ with GNU EMACS. See function `"
+ (if (featurep 'xemacs) "assoc" "assoc-string") "'." ))
;;; Documentation for Info-goto-emacs-command-node and similar
@@ -2389,14 +2396,9 @@ active.")
(defun TeX-unload-style (style)
"Forget that we once loaded STYLE."
- (cond ((null (assoc style TeX-style-hook-list)))
- ((equal (car (car TeX-style-hook-list)) style)
- (setq TeX-style-hook-list (cdr TeX-style-hook-list)))
- (t
- (let ((entry TeX-style-hook-list))
- (while (not (equal (car (car (cdr entry))) style))
- (setq entry (cdr entry)))
- (setcdr entry (cdr (cdr entry)))))))
+ (let ((style-data (TeX-assoc-string style TeX-style-hook-list)))
+ (if style-data
+ (setq TeX-style-hook-list (delq style-data TeX-style-hook-list)))))
(defcustom TeX-virgin-style (if (and TeX-auto-global
(file-directory-p TeX-auto-global))
@@ -2430,7 +2432,7 @@ active.")
(match-beginning 2) (match-end 2))))
(condition-case err
(mapcar 'funcall
- (cdr-safe (assoc style TeX-style-hook-list)))
+ (cdr-safe (TeX-assoc-string style
TeX-style-hook-list)))
;; This happens in case some style added a new parser, and
;; now the style isn't used anymore (user deleted
;; \usepackage{style}). Then we're left over with, e.g.,
@@ -3716,7 +3718,7 @@ Check for potential LaTeX environments."
"File extensions recognized by AUCTeX."
:group 'TeX-file)
-(defcustom TeX-file-extensions '("tex" "sty" "cls" "ltx" "texi" "texinfo"
"dtx")
+(defcustom TeX-file-extensions '("tex" "sty" "cls" "ltx" "texi" "txi"
"texinfo" "dtx")
"*File extensions used by manually generated TeX files."
:group 'TeX-file-extension
:type '(repeat (string :format "%v")))
- [AUCTeX] Small optimizations / was: Problem with latex2e style hook --- LaTeX/Texinfo collision,
Vincent Belaïche <=