需要org-mode zip,如何克服?

发布于 2024-12-22 13:10:33 字数 289 浏览 3 评论 0原文

我有一个组织模式文档,我想将其转换为开放文档格式。当我尝试执行此操作 (ctrl+c+e+o) 时,我收到一条错误消息:

创建 OpenDocument 文件所需的可执行“zip”。正在中止。

我的机器上安装了 p7zip,但我不知道如何告诉 emacs 它在那里。我不确定 org-mode 想要做什么,所以我不确定在 .emacs 中配置什么。

谢谢

I have an org-mode document that I want to convert to open Document format. When I try to do this (ctrl+c+e+o) I get an error message:

Executeable "zip" needed for creating OpenDocument files. Aborting.

I have p7zip installed on my machine but I don't know how to tell emacs it is there. I'm not sure what org-mode want to do so I'm not sure what to configure in .emacs.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

零度° 2024-12-29 13:10:33

您的 p7zip 可执行文件必须位于 Emacs exec-path 变量中,以便 Emacs 可以找到它。

此外,可执行文件必须名为“zip”,因为它是硬编码在 org-odt-init-outfile 函数中的。

因此,首先检查 exec-path 的设置,确保它包含 zip 可执行文件的位置。

`M-x customize-variable RET exec-path RET`

Your p7zip executable must be in Emacs exec-path variable, so that Emacs can find it.

Also, the executable must be called "zip" since it is hard-coded in the org-odt-init-outfile function.

So check the setting of exec-path first to make sure it includes the location of your zip executable.

`M-x customize-variable RET exec-path RET`
老旧海报 2024-12-29 13:10:33

您需要 Info-ZIP。请参阅 http://lists.gnu.org/archive/ html/emacs-orgmode/2011-07/msg00485.html

p7zip 可能与 zip 命令行实用程序不兼容,如果我通过这篇文章: http://sourceforge.net/projects/sevenzip/forums /forum/45797/topic/1521207?message=3786349。因此,我认为 p7zip 可能不是一个可行的选择。

You need Info-ZIP. See http://lists.gnu.org/archive/html/emacs-orgmode/2011-07/msg00485.html

p7zip may not be compatible with zip command-line utility, if I go by this post: http://sourceforge.net/projects/sevenzip/forums/forum/45797/topic/1521207?message=3786349. So, I think, p7zip may not be a viable option here.

流心雨 2024-12-29 13:10:33

不需要 p7zipinfo-zip 外部程序,Emacs deps 附带一个 zip 程序:minizip。 (有关更多信息,请参阅安装 Emacs Windows 支持库的最简单方法

我们需要了解的一些情况:

  1. minizip 不支持递归 zip
  2. zip 已被硬编码在ox-odt.el
  3. minizip 的选项与 `zip' 不兼容

,所以我在 elisp 中生成了 zip.bat 批处理 然后将 zip.bat 的路径添加到 %PATH% (用于组织导出到 odt)和 exec-path (用于zip 文件,dired-do-compress-to

zip.bat

@echo off
REM zip.bat for minizip on Windows
REM generated by More Reasonable Emacs https://github.com/junjiemars/.emacs.d

setlocal EnableDelayedExpansion

set _OPT=%*
set _ZIP=
set _ARGV=

REM parsing command line arguments

:getopt
if "%1"=="-mX0" set _OPT=%_OPT:-mX0=-0% & shift & goto :getopt

REM ignore options
if "%1"=="-r" set _OPT=%_OPT:-r=% & shift & goto :getopt
if "%1"=="--filesync" set _OPT=%_OPT:--filesync=% & shift & goto :getopt
if "%1"=="-rmTq" set _OPT=%_OPT:-rmTq=% & shift & goto :getopt

REM extract zip and argv
if not "%1"=="" (
  if "%_ZIP%"=="" (
    if "%_ARGV%"=="" (
      set _ZIP=%1
    )
  ) else (
    set _ARGV=%_ARGV% %1
  )
  set _OPT=!_OPT:%1=!
  shift
  goto :getopt
)

REM minizip recursive call

call :loop %_ARGV%
goto :end

:zip
set _file=%1
set _file=%_file:./=%
if not "%_file%"=="%_ZIP%" (
  if exist %_ZIP% (
    minizip %_OPT% -a %_ZIP% %_file%
  ) else (
    minizip %_OPT% %_ZIP% %_file%
  )
)
goto :end

:loop
for %%i in (%*) do (
  if exist "%%i/*" (
    for %%f in (%%i/*) do (
      call :loop %%i/%%f
    )
    for /d %%d in (%%i/*) do (
      call :loop %%i/%%d
    )
  ) else (
    call :zip %%i
  )
)

:end

生成zip.bat的函数make-zip-bat

(defun make-zip-bat (zip &rest ignore)
  "Make ZIP.bat in `exec-path' for minizip or 7za."
  (declare (indent 1))
  (when (stringp zip)
    (save-str-to-file
     (concat "@echo off\n"
                     (format "REM zip.bat for %s on Windows\n" zip)
                     "REM generated by More Reasonable Emacs https://github.com/junjiemars/.emacs.d\n\n"
                     (concat "REM local variable declaration\n\n"
                                     "setlocal EnableDelayedExpansion\n"
                                     "\n"
                                     "set _OPT=%*\n"
                                     "set _ZIP=\n"
                                     "set _ARGV=\n"
                                     "\n"
                                     "REM parsing command line arguments\n\n"
                                     ":getopt\n"
                                     (cond ((string= "minizip" zip)
                                                    "if \"%1\"==\"-mX0\" set _OPT=%_OPT:-mX0=-0% & shift & goto :getopt\n")
                                                 ((string= "7za" zip)
                                                    (concat
                                                     "if \"%1\"==\"-mX0\" set _OPT=%_OPT:-mX0=-mx0% & shift & goto :getopt\n"
                                                     "if \"%1\"==\"-0\" set _OPT=%_OPT:-0=-mx0% & shift & goto :getopt\n"
                                                     "if \"%1\"==\"-9\" set _OPT=%_OPT:-9=-mx9% & shift & goto :getopt\n")))
                                     "\n"
                                     "REM ignore options\n"
                                     (let ((options nil))
                                         (dolist (x (cond ((string= "minizip" zip)
                                                                             (append '("-r" "--filesync" "-rmTq") ignore))
                                                                            ((string= "7za" zip)
                                                                             (append '("-r" "--filesync" "-rmTq"))))
                                                                options)
                                             (setq options
                                                         (concat options
                                                                         (format "if \"%%1\"==\"%s\" set _OPT=%%_OPT:%s=%% & shift & goto :getopt\n" x x)))))
                                     "\n"
                                     "REM extract zip and argv\n"
                                     "if not \"%1\"==\"\" (\n"
                                     "  if \"%_ZIP%\"==\"\" (\n"
                                     "    if \"%_ARGV%\"==\"\" (\n"
                                     "      set _ZIP=%1\n"
                                     "    )\n"
                                     "  ) else (\n"
                                     "    set _ARGV=%_ARGV% %1\n"
                                     "  )\n"
                                     "  set _OPT=!_OPT:%1=!\n"
                                     "  shift\n"
                                     "  goto :getopt\n"
                                     ")\n\n")
                     (cond ((string= "7za" zip)
                                    (concat "REM 7za call\n"
                                                    "7za a %_OPT% -tzip -- %_ZIP% %_ARGV%\n"
                                                    "if exist %_ZIP% (\n"
                                                    "  7za d %_OPT% -tzip -- %_ZIP% %_ZIP%\n"
                                                    ")\n"))
                                 ((string= "minizip" zip)
                                    (concat "REM minizip recursive call\n\n"
                                                    "call :loop %_ARGV%\n"
                                                    "goto :end\n"
                                                    "\n:zip\n"
                                                    "set _file=%1\n"
                                                    "set _file=%_file:./=%\n"
                                                    "if not \"%_file%\"==\"%_ZIP%\" (\n"
                                                    "  if exist %_ZIP% (\n"
                                                    "    minizip %_OPT% -a %_ZIP% %_file%\n"
                                                    "  ) else (\n"
                                                    "    minizip %_OPT% %_ZIP% %_file%\n"
                                                    "  )\n"
                                                    ")\n"
                                                    "goto :end\n"
                                                    "\n:loop\n"
                                                    "for %%i in (%*) do (\n"
                                                    "  if exist \"%%i/*\" (\n"
                                                    "    for %%f in (%%i/*) do (\n"
                                                    "      call :loop %%i/%%f\n"
                                                    "    )\n"
                                                    "    for /d %%d in (%%i/*) do (\n"
                                                    "      call :loop %%i/%%d\n"
                                                    "    )\n"
                                                    "  ) else (\n"
                                                    "    call :zip %%i\n"
                                                    "  )\n"
                                                    ")\n"
                                                    "\n:end\n"))))
     (v-home% ".exec/zip.bat"))))

zip的简单方法> 的工作原理是将 zip.bat 的内容复制到名为 zip.bat 的文件中,并将该文件放在 exec-path 下。要查看更多更合理的Emacs:zip程序make- zip-bat 也支持 7-Zip

Do not need p7zip or info-zip external programs, Emacs deps ship with a zip program: minizip. (for more information, see Easiest way to install Emacs Windows support libraries)

The some situations we need to be known:

  1. minizip does not support recursive zip
  2. zip had been hard-coded in ox-odt.el
  3. minizip's options is not compatible with `zip'

So I generated a zip.bat batch in elisp then add the path of zip.bat to %PATH% (for org export to odt) and exec-path (for zip files, dired-do-compress-to)

zip.bat:

@echo off
REM zip.bat for minizip on Windows
REM generated by More Reasonable Emacs https://github.com/junjiemars/.emacs.d

setlocal EnableDelayedExpansion

set _OPT=%*
set _ZIP=
set _ARGV=

REM parsing command line arguments

:getopt
if "%1"=="-mX0" set _OPT=%_OPT:-mX0=-0% & shift & goto :getopt

REM ignore options
if "%1"=="-r" set _OPT=%_OPT:-r=% & shift & goto :getopt
if "%1"=="--filesync" set _OPT=%_OPT:--filesync=% & shift & goto :getopt
if "%1"=="-rmTq" set _OPT=%_OPT:-rmTq=% & shift & goto :getopt

REM extract zip and argv
if not "%1"=="" (
  if "%_ZIP%"=="" (
    if "%_ARGV%"=="" (
      set _ZIP=%1
    )
  ) else (
    set _ARGV=%_ARGV% %1
  )
  set _OPT=!_OPT:%1=!
  shift
  goto :getopt
)

REM minizip recursive call

call :loop %_ARGV%
goto :end

:zip
set _file=%1
set _file=%_file:./=%
if not "%_file%"=="%_ZIP%" (
  if exist %_ZIP% (
    minizip %_OPT% -a %_ZIP% %_file%
  ) else (
    minizip %_OPT% %_ZIP% %_file%
  )
)
goto :end

:loop
for %%i in (%*) do (
  if exist "%%i/*" (
    for %%f in (%%i/*) do (
      call :loop %%i/%%f
    )
    for /d %%d in (%%i/*) do (
      call :loop %%i/%%d
    )
  ) else (
    call :zip %%i
  )
)

:end

The function make-zip-bat that generate zip.bat:

(defun make-zip-bat (zip &rest ignore)
  "Make ZIP.bat in `exec-path' for minizip or 7za."
  (declare (indent 1))
  (when (stringp zip)
    (save-str-to-file
     (concat "@echo off\n"
                     (format "REM zip.bat for %s on Windows\n" zip)
                     "REM generated by More Reasonable Emacs https://github.com/junjiemars/.emacs.d\n\n"
                     (concat "REM local variable declaration\n\n"
                                     "setlocal EnableDelayedExpansion\n"
                                     "\n"
                                     "set _OPT=%*\n"
                                     "set _ZIP=\n"
                                     "set _ARGV=\n"
                                     "\n"
                                     "REM parsing command line arguments\n\n"
                                     ":getopt\n"
                                     (cond ((string= "minizip" zip)
                                                    "if \"%1\"==\"-mX0\" set _OPT=%_OPT:-mX0=-0% & shift & goto :getopt\n")
                                                 ((string= "7za" zip)
                                                    (concat
                                                     "if \"%1\"==\"-mX0\" set _OPT=%_OPT:-mX0=-mx0% & shift & goto :getopt\n"
                                                     "if \"%1\"==\"-0\" set _OPT=%_OPT:-0=-mx0% & shift & goto :getopt\n"
                                                     "if \"%1\"==\"-9\" set _OPT=%_OPT:-9=-mx9% & shift & goto :getopt\n")))
                                     "\n"
                                     "REM ignore options\n"
                                     (let ((options nil))
                                         (dolist (x (cond ((string= "minizip" zip)
                                                                             (append '("-r" "--filesync" "-rmTq") ignore))
                                                                            ((string= "7za" zip)
                                                                             (append '("-r" "--filesync" "-rmTq"))))
                                                                options)
                                             (setq options
                                                         (concat options
                                                                         (format "if \"%%1\"==\"%s\" set _OPT=%%_OPT:%s=%% & shift & goto :getopt\n" x x)))))
                                     "\n"
                                     "REM extract zip and argv\n"
                                     "if not \"%1\"==\"\" (\n"
                                     "  if \"%_ZIP%\"==\"\" (\n"
                                     "    if \"%_ARGV%\"==\"\" (\n"
                                     "      set _ZIP=%1\n"
                                     "    )\n"
                                     "  ) else (\n"
                                     "    set _ARGV=%_ARGV% %1\n"
                                     "  )\n"
                                     "  set _OPT=!_OPT:%1=!\n"
                                     "  shift\n"
                                     "  goto :getopt\n"
                                     ")\n\n")
                     (cond ((string= "7za" zip)
                                    (concat "REM 7za call\n"
                                                    "7za a %_OPT% -tzip -- %_ZIP% %_ARGV%\n"
                                                    "if exist %_ZIP% (\n"
                                                    "  7za d %_OPT% -tzip -- %_ZIP% %_ZIP%\n"
                                                    ")\n"))
                                 ((string= "minizip" zip)
                                    (concat "REM minizip recursive call\n\n"
                                                    "call :loop %_ARGV%\n"
                                                    "goto :end\n"
                                                    "\n:zip\n"
                                                    "set _file=%1\n"
                                                    "set _file=%_file:./=%\n"
                                                    "if not \"%_file%\"==\"%_ZIP%\" (\n"
                                                    "  if exist %_ZIP% (\n"
                                                    "    minizip %_OPT% -a %_ZIP% %_file%\n"
                                                    "  ) else (\n"
                                                    "    minizip %_OPT% %_ZIP% %_file%\n"
                                                    "  )\n"
                                                    ")\n"
                                                    "goto :end\n"
                                                    "\n:loop\n"
                                                    "for %%i in (%*) do (\n"
                                                    "  if exist \"%%i/*\" (\n"
                                                    "    for %%f in (%%i/*) do (\n"
                                                    "      call :loop %%i/%%f\n"
                                                    "    )\n"
                                                    "    for /d %%d in (%%i/*) do (\n"
                                                    "      call :loop %%i/%%d\n"
                                                    "    )\n"
                                                    "  ) else (\n"
                                                    "    call :zip %%i\n"
                                                    "  )\n"
                                                    ")\n"
                                                    "\n:end\n"))))
     (v-home% ".exec/zip.bat"))))

The simple way to let zip works is to copy the content of zip.bat into a file named zip.bat and put that file under exec-path. To see more More Reasonable Emacs: zip program, make-zip-bat support 7-Zip too.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文