predictive-latex-graphicx.el 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. ;;; predictive-latex-graphicx.el --- predictive mode LaTeX graphicx
  2. ;;; package support
  3. ;; Copyright (C) 2004-2006, 2008, 2013 Toby Cubitt
  4. ;; Author: Toby Cubitt <toby-predictive@dr-qubit.org>
  5. ;; Version: 0.2.2
  6. ;; Keywords: predictive, latex, package, graphicx
  7. ;; URL: http://www.dr-qubit.org/emacs.php
  8. ;; This file is NOT part of Emacs.
  9. ;;
  10. ;; This file is free software: you can redistribute it and/or modify it under
  11. ;; the terms of the GNU General Public License as published by the Free
  12. ;; Software Foundation, either version 3 of the License, or (at your option)
  13. ;; any later version.
  14. ;;
  15. ;; This program is distributed in the hope that it will be useful, but WITHOUT
  16. ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  17. ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  18. ;; more details.
  19. ;;
  20. ;; You should have received a copy of the GNU General Public License along
  21. ;; with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  22. ;;; Code:
  23. (require 'predictive-latex)
  24. ;; register package setup function
  25. (predictive-assoc-delete-all "graphicx" predictive-latex-usepackage-functions)
  26. (push '("graphicx" . predictive-latex-setup-graphicx)
  27. predictive-latex-usepackage-functions)
  28. (defun predictive-latex-setup-graphicx (arg)
  29. ;; With positive ARG, load graphicx package support. With negative ARG,
  30. ;; unload it.
  31. (cond
  32. ;; --- load graphicx support ---
  33. ((> arg 0)
  34. ;; add completion source regexps
  35. (make-local-variable 'auto-completion-source-regexps)
  36. (nconc
  37. auto-completion-source-regexps
  38. ;; label with optarg
  39. `((,(concat predictive-latex-odd-backslash-regexp
  40. "includegraphics\\(?:\\[.*?\\]\\)"
  41. predictive-latex-brace-group-regexp)
  42. nil looking-at 1))
  43. ))
  44. ;; --- unload graphicx support ---
  45. ((< arg 0)
  46. ;; remove completion source regexps
  47. (setq auto-completion-source-regexps
  48. (predictive-assoc-delete-all
  49. (concat predictive-latex-odd-backslash-regexp
  50. "includegraphics\\(?:\\[.*?\\]\\)"
  51. predictive-latex-brace-group-regexp)
  52. auto-completion-source-regexps)))
  53. ))
  54. (provide 'predictive-latex-graphicx)
  55. ;;; predictive-latex-graphicx ends here