如何在Win32上从Emacs打印?

Chr*_*erg 7 printing emacs winapi

我正在运行Emacs 23.0.60.1,从这里下载,在Windows XP上,网络打印机配置为默认打印机.

如何设置Emacs以轻松打印缓冲区内容?

针对Win32的修补Emacs版本的文档提到了"快速和简单"打印,但是没有出现"快速打印"菜单条目,并且常规条目("打印缓冲区","Postscript打印缓冲区")似乎没有任何东西.

编辑:
我在Emacs 22.3的官方Windows版本中遇到了同样的问题.因此,任何版本的设置/故障排除说明将不胜感激.

EDIT2:
我选择了下面由Joe Casadonte提供的PrintFile解决方案,效果很好.不过,我仍然对任何有关"正确"方式不起作用的想法感兴趣.

(顺便说一句,这是一个适当的SO问题,只是边缘编程相关吗?)

ayc*_*ter 5

我将使用通用USB打印机描述Windows 7的所有内容.根据您的版本需要调整流程.通常可以以相同的方式访问网络.只需使用//NetworkComputerName/SharedPrinterName//而不是// MyComputer/MyPrinter并跳过步骤1.-6 ..

  1. 转到开始 - >控制面板 - >硬件和声音 - >设备和打印机
  2. 右键单击您的打印机选择"打印机属性"
  3. 转到"共享"并选中"共享此打印机"和"在客户端计算机上呈现打印作业"
  4. 输入共享名称:MyPrinter或您可以记住并且没有空格的内容.
  5. 单击"确定"保存更改.
  6. 转到开始 - >计算机以检查左下角的计算机名称(例如MyComputer)
  7. 在Emacs中评估(setq printer-name "//MyComputer/MyPrinter")或将其放在.emacs.el文件中
  8. 完成.您可以使用打印文件M-x print-buffer


Joe*_*nte 4

这不是“正确”的方式,但多年来我一直这样做,而且效果非常好。我使用PrintFile,一个免费打印程序(也可以独立使用)。然后我的 .emacs 中有这个:

(defun joc-make-fname-from-buffer-name (buffer-name-in)
  "Returns a valid filename from a given buffer name"
  (interactive "b")
  (save-match-data
    (let* ((start (string-match "[^ \*]" buffer-name-in))
           (end (string-match "[ \*]*$" buffer-name-in (match-end 0)))
           (rc (substring buffer-name-in start end)))
      ;; remove some special characters
      (while (string-match "[:]+" rc)
        (setq rc (replace-match "_" t t rc)))
      rc)))

(when is-win32
    (defun joc-print-buffer-or-region (prefix)
      "Prints buffer or region via PrintFile32.  If a prefix arg is set (via C-u) then
       the current region is printed, otherwise the current buffer is printed."

      (interactive "P")

      ;; ----- set the print directory, fname and args -----
      (let* ((print-dir (expand-file-name "~/emacs/print"))
             (print-fname (joc-make-fname-from-buffer-name (buffer-name)))
             (print-fullpath (concat print-dir "/" print-fname))
             (print-args "/delete")
             ;; ----- set rstart and rend to the current region -----
             (rstart (point-min)) (rend (point-max)))

        ;; ----- if prefix given, set them to region -----
        (if (and prefix)
            (if (and (point) (mark) (/= (point) (mark)))
                (progn (setq rstart (min (point) (mark)))
                       (setq rend (max (point) (mark))))
              (error "No region defined")))

        ;; ----- make the directory -----
        (if (not (file-directory-p print-dir))
            (make-directory print-dir))

        ;; ----- write buffer/region to a temp file, print it, delete directory -----
        (write-region rstart rend print-fullpath)
        (call-process "prfile32" nil t nil print-args print-fullpath)
        (delete-directory print-dir))))
Run Code Online (Sandbox Code Playgroud)

我已经很多年没有看过它了,因为它确实有效,所以我确信它可以改进。