emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] 19/39: Markdown support added.


From: Phillip Lord
Subject: [elpa] 19/39: Markdown support added.
Date: Mon, 20 Oct 2014 08:22:37 +0000

phillord pushed a commit to branch externals/pabbrev
in repository elpa.

commit c2cf0bf853199b76ed8e29112c6ab21a438d9512
Author: Phillip Lord <address@hidden>
Date:   Mon Sep 23 20:56:44 2013 +0100

    Markdown support added.
---
 greycite.el |   60 ++++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 51 insertions(+), 9 deletions(-)

diff --git a/greycite.el b/greycite.el
index 01a5996..588b00f 100644
--- a/greycite.el
+++ b/greycite.el
@@ -47,7 +47,7 @@
 ;; `greycite-bibtex-doi-update' do similar jobs for DOIs.
 ;;
 ;; Reftex support is added automatically to adoc-mode. If you prefer to use
-;; someother mode than adoc, `greycite-asciidoc-reftex-support' will turn this
+;; some other mode than adoc, `greycite-asciidoc-reftex-support' will turn this
 ;; on. 
 ;;
 
@@ -61,6 +61,10 @@
 (add-hook 'adoc-mode-hook
           'greycite-asciidoc-reftex-support)
 
+(add-hook 'markdown-mode-hook
+          'greycite-markdown-reftex-support)
+
+
 (defvar greycite-reftex-citation-override nil)
 (defvar greycite-adoc-kblog-cite-format 
   '(
@@ -70,31 +74,60 @@
     (?j . "http:[]"))
   )
 
+(defvar greycite-markdown-cite-format
+  '(
+    (?\C-m . "[?](http://)")))
+
+
 (defvar greycite-default-bibliographies
   '("~/documents/bibtex/phil_lord_refs.bib" 
-    "~/documents/bibtex/phil_lord/journal_papers.bib"
-    "~/documents/bibtex/phil_lord/conference_papers.bib"
+    "~/documents/bibtex/phil_lord/phil_lord_all.bib"
     "~/documents/bibtex/urls.bib"
     "~/documents/bibtex/russet.bib"
+    "~/documents/bibtex/kblog.bib"
     ))
 
 
 (defun greycite-asciidoc-reftex-support()
   (interactive)
+  (greycite-alien-reftex-support greycite-adoc-kblog-cite-format))
+
+(defun greycite-markdown-reftex-support ()
+  (interactive)
+  (greycite-alien-reftex-support greycite-markdown-cite-format)
+  (make-local-variable 'reftex-cite-cleanup-optional-args)
+  (setq reftex-cite-cleanup-optional-args nil)
+  (add-hook 'greycite-pre-insert-hook 
+            'greycite-markdown-pre-hook))
+
+(defun greycite-markdown-pre-hook ()
+  (insert "]")
+  (save-excursion 
+    (forward-word -1)
+    (insert "[")))
+
+
+(defvar greycite-pre-insert-hook nil)
+
+(defun greycite-alien-reftex-support(cite-format)
+  (interactive)
   (reftex-mode 1)
   (make-local-variable 'greycite-reftex-citation-override)
   (setq greycite-reftex-citation-override t)
   (make-local-variable 'reftex-default-bibliography)
   (make-local-variable 'reftex-cite-format)
   (setq reftex-cite-format
-        greycite-adoc-kblog-cite-format)
+        cite-format)
   (setq reftex-default-bibliography greycite-default-bibliographies))
 
+
 (defadvice reftex-format-citation (around greycite-asciidoc-around activate)
-  "Alter citation style for kcite"
-  (if greycite-reftex-citation-override
+  "Alter citation stylue for kcite"
+  (if (and greycite-reftex-citation-override
+           (not (string= "%2a %y, %T, %B, %j %v:%P, %s %<" format)))
       (progn 
-        (setq ad-return-value (greycite-reftex-format-citation entry format)))
+        (setq ad-return-value (greycite-reftex-format-citation entry format))
+        (run-hooks 'greycite-pre-insert-hook))
     ad-do-it))
 
 ;; we can't just use reftex-format-citation -- it has will template with most
@@ -117,7 +150,10 @@
     (reftex-get-bib-field "url" entry))
    ((string= format "http:[]")
     (concat (reftex-get-bib-field "url" entry) "[]"))
-   ))
+   ;; markdown
+   ((string= format "[?](http://)")
+    (concat "?(" (reftex-get-bib-field "url" entry) ")"))
+   (t (error "Format not recognised"))))
 
 
 (defun greycite-reftex-or-false(entry field prefix &optional transform)
@@ -274,4 +310,10 @@
   (greycite-bibtex-region-from-greycite 
    (point-min) (point-max)))
 
-(provide 'greycite)
\ No newline at end of file
+(defun greycite-buffer ()
+  (interactive)
+  (while (< -1 (forward-line -1))
+    (greycite-bibtex-url)
+    (sit-for 2)))
+
+(provide 'greycite)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]