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

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

[nongnu] elpa/markdown-mode 521658eb32 3/3: Merge pull request #687 from


From: ELPA Syncer
Subject: [nongnu] elpa/markdown-mode 521658eb32 3/3: Merge pull request #687 from cscheid/feat/markdown-command-function-needs-name
Date: Sat, 12 Feb 2022 02:58:26 -0500 (EST)

branch: elpa/markdown-mode
commit 521658eb32e456681592443e04ae507c3a59ed07
Merge: 8c7b0c4ab4 1d36f54d5e
Author: Shohei YOSHIDA <syohex@gmail.com>
Commit: GitHub <noreply@github.com>

    Merge pull request #687 from 
cscheid/feat/markdown-command-function-needs-name
    
    make `markdown` pass `buffer-file-name`  to `markdown-command` if needed
---
 CHANGES.md       |  5 +++++
 README.md        | 17 +++++++++--------
 markdown-mode.el |  6 +++++-
 3 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index 0511ef0426..2a2a3b12bb 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -2,6 +2,11 @@
 
 *Under development*
 
+*   Improvements:
+    -   `markdown` passes `buffer-file-name` as a parameter to
+        `markdown-command` when `markdown-command-needs-filename` is
+        `t` and `markdown-command` is a function.
+
 # Markdown Mode 2.5
 
 *   **Breaking changes:**
diff --git a/README.md b/README.md
index bde33d9b30..e597765077 100644
--- a/README.md
+++ b/README.md
@@ -665,13 +665,16 @@ that can be customized.  The <kbd>M-x 
customize-mode</kbd> command
 provides an interface to all of the possible customizations:
 
   * `markdown-command` - the command used to run Markdown (default:
-    `markdown`).  This variable may be customized to pass
-    command-line options to your Markdown processor of choice. We recommend
-    you to use list of strings if you want to set command line options like.
+    `markdown`).  This variable may be customized to pass command-line
+    options to your Markdown processor of choice. We recommend you to
+    use list of strings if you want to set command line options like.
     `'("pandoc" "--from=markdown" "--to=html5")`.  It can also be a
     function; in this case `markdown` will call it with three
-    arguments: the beginning and end of the region to process, and
-    a buffer to write the output to.
+    arguments or four arguments, depending on
+    `markdown-command-needs-filename`.  The first three arguments are:
+    the beginning and end of the region to process, and a buffer to
+    write the output to. When `markdown-command-needs-filename` is `t`, the 
fourth
+    argument is set to the name of the file.
 
   * `markdown-command-needs-filename` - set to `t` if
     `markdown-command` does not accept standard input (default:
@@ -680,9 +683,7 @@ provides an interface to all of the possible customizations:
     When set to `t`, `markdown-mode` will pass the name of the file
     as the final command-line argument to `markdown-command`.  Note
     that in the latter case, you will only be able to run
-    `markdown-command` from buffers which are visiting a file.  If
-    `markdown-command` is a function, `markdown-command-needs-filename`
-    is ignored.
+    `markdown-command` from buffers which are visiting a file. 
 
   * `markdown-open-command` - the command used for calling a standalone
     Markdown previewer which is capable of opening Markdown source files
diff --git a/markdown-mode.el b/markdown-mode.el
index 10342fb809..7c60b58951 100644
--- a/markdown-mode.el
+++ b/markdown-mode.el
@@ -7351,7 +7351,11 @@ Return the name of the output buffer used."
                      (if (not (null command-args))
                          (apply #'call-process-region begin-region end-region 
command nil buf nil command-args)
                        (call-process-region begin-region end-region command 
nil buf))
-                   (funcall markdown-command begin-region end-region buf)
+                   (if markdown-command-needs-filename
+                       (if (not buffer-file-name)
+                           (user-error "Must be visiting a file")
+                         (funcall markdown-command begin-region end-region buf 
buffer-file-name))
+                     (funcall markdown-command begin-region end-region buf))
                    ;; If the ‘markdown-command’ function didn’t signal an
                    ;; error, assume it succeeded by binding ‘exit-code’ to 0.
                    0))))))



reply via email to

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