[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Patching graphicx.el
From: |
Arash Esbati |
Subject: |
Patching graphicx.el |
Date: |
Fri, 16 Oct 2020 12:07:23 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 |
Hi all,
it occurred to me that when inserting the macro `\includegraphics' with
`C-c C-m includegraphics RET', the final result looks like this:
\includegraphics{foo*}
where foo is the name of the graphic and * the point, i.e., the point is
left inside the argument.
The way I see it is due to how `LaTeX-arg-includegraphics' inserts the
name of the graphic. This way, it is not possible to use
`LaTeX-arg-includegraphics' in other styles and the result is also odd.
I suppose the following patch to graphicx.el and AUCTeX-ify
`LaTeX-arg-includegraphics'. Any comment welcome.
--8<---------------cut here---------------start------------->8---
diff --git a/style/graphicx.el b/style/graphicx.el
index c24ee214..be918bd6 100644
--- a/style/graphicx.el
+++ b/style/graphicx.el
@@ -171,7 +171,7 @@ Optional argument LIST if non-nil is used as list of
regexps of
extensions to be matched."
(unless list
(setq list (LaTeX-includegraphics-extensions-list)))
- (concat "\\." (mapconcat #'identity list "$\\|\\.") "$"))
+ (concat "\\." (mapconcat #'identity list "\\'\\|\\.") "\\'"))
(defvar LaTeX-includegraphics-global-files nil
"List of the non-local graphic files to include in LaTeX documents.
@@ -213,21 +213,16 @@ subdirectories and inserts the relative file name. See
(string-match (LaTeX-includegraphics-extensions) fname))))
(TeX-master-directory)))
-(defun LaTeX-arg-includegraphics (_prefix)
+(defun LaTeX-arg-includegraphics (optional)
"Ask for mandantory argument for the \\includegraphics command."
- (let* ((image-file (funcall LaTeX-includegraphics-read-file)))
- (TeX-insert-braces 0)
- (insert
+ (let ((image-file (funcall LaTeX-includegraphics-read-file)))
+ (TeX-argument-insert
(if LaTeX-includegraphics-strip-extension-flag
- ;; We don't have `replace-regexp-in-string' in all (X)Emacs versions:
- (with-temp-buffer
- (insert image-file)
- (goto-char (point-max))
- (when (search-backward-regexp (LaTeX-includegraphics-extensions)
- nil t 1)
- (replace-match ""))
- (buffer-string))
- image-file))))
+ (replace-regexp-in-string (LaTeX-includegraphics-extensions)
+ ""
+ image-file)
+ image-file)
+ optional)))
(TeX-add-style-hook
"graphicx"
--8<---------------cut here---------------end--------------->8---
Best, Arash
- Patching graphicx.el,
Arash Esbati <=