Giter VIP home page Giter VIP logo

with-editor's Introduction

A Git Porcelain inside Emacs

homepage | manual | faq | wiki | mastodon


Magit is an interface to the version control system Git, implemented as an Emacs package. Magit aspires to be a complete Git porcelain. While we cannot (yet) claim that Magit wraps and improves upon each and every Git command, it is complete enough to allow even experienced Git users to perform almost all of their daily version control tasks directly from within Emacs. While many fine Git clients exist, only Magit and Git itself deserve to be called porcelains.


Keeping its users this excited is a lot of work . If Magit makes you
more productive too, then please consider making a donation.
Thank you! — Jonas Bernoulli

Sponsor my work using Github Sponsors    Sponsor my work using Liberapay
Sponsor my work using Opencollective    Sponsor my work using PayPal

Some alternative donation methods are available.

Getting Started

If you are new to Magit, then either one of the following two articles should help understanding how it differs from other Git clients.

If you are completely new to Magit, then this article is a good visual introduction.

Almost everything that you see in Magit can be acted on by pressing some key, but that's not obvious from just seeing how Magit looks. The screenshots and accompanying text of this article explain how to perform a variety of actions on Magit's output.

Magit differs significantly from other Git interfaces, and its advantages are not immediately obvious simply from looking at a few screenshots as presented in the preceding article.

This article discusses Magit's properties in somewhat more abstract terms.

Video introductions

If you prefer video introductions, head over to that page, where find a collection of such introductions and other videos about Magit, by various creators.


Support and Contributing

Magit has many users and very few maintainers, so we kindly ask to read the appropriate guidelines before getting in contact. — Thanks!

TL;DR We now use discussions for feature requests (not issues) and prefer if you ask the community for support instead of the overworked maintainers.

Please also consider to contribute by supporting other users or by making a monetary donation. — Thanks!


Acknowledgments

Magit was started by Marius Vollmer, and is now maintained by Jonas Bernoulli and Kyle Meyer. Former maintainers are Nicolas Dudebout, Noam Postavsky, Peter J. Weisberg, Phil Jackson, Rémi Vanicat and Yann Hodique. Many more people have contributed code, suggested features or made monetary contributions.

Thanks to all of you, may (the history of) the source be with you!


Compile Test Manual NonGNU ELPA Melpa Melpa Stable

with-editor's People

Contributors

albinus avatar blahgeek avatar cjohansson avatar dalgong avatar dankessler avatar iyefrat avatar justbur avatar kyleam avatar marsam avatar mshroyer avatar npostavs avatar phst avatar soppera avatar suvayu avatar tarsius avatar vanicat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

with-editor's Issues

Can't commit via magit (WITH-EDITOR: $$ OPEN $0: -c: line 0: unexpected EOF)

I've tried magit with with-editor 2.6.0, 2.7.0 and 2.7.1 (so it doesn't seem to be related to #40), and all end up with the same error when I try to commit:

  1 git … commit --
WITH-EDITOR: $$ OPEN $0: -c: line 0: unexpected EOF while looking for matching `''
WITH-EDITOR: $$ OPEN $0: -c: line 1: syntax error: unexpected end of file
error: There was a problem with the editor '/nix/store/pnp2r30rd3ld3jfkk7zhl09xpxkiyg9w-emacs-27.0.50/bin/emacsclient'.
Please supply the message using either -m or -F option.

M-x with-editor-debug:

with-editor: /nix/store/773xq6893if0r25na6a9f6l1kvkrc4q4-emacs-packages-deps/share/emacs/site-lisp/elpa/with-editor-2.6.0/with-editor.el
emacs: /nix/store/pnp2r30rd3ld3jfkk7zhl09xpxkiyg9w-emacs-27.0.50/bin/emacs (27.0.50)
system:
  system-type: gnu/linux
  system-configuration: x86_64-pc-linux-gnu
  system-configuration-options: --prefix=/nix/store/pnp2r30rd3ld3jfkk7zhl09xpxkiyg9w-emacs-27.0.50
server:
  server-running-p: nil
  server-process: #<process serverNvE5YK>
  server-use-tcp: t
  server-name: server
  server-socket-dir: /tmp/emacs1000
    WARNING: not an accessible directory
  server-auth-dir: ~/.emacs.d/server/
    server24344abP
    server2flo75
    server3007480v
    server30132F3v
    server30431ZYO
    server4X1pih
    server90SvNz
    serverEQHF7c
    serverEwNTzI
    serverGsZg5M
    serverNvE5YK
    serverOfWPy5
    serverRn3ba4
    serverVA4N7f
    serverZvsFyg
    serverdICSSb
    serverhBoZfQ
    servermIiP2J
    servernojJgb
    serverrh80c5
    serverzPeBLB
with-editor-emacsclient-executable:
 value:   /nix/store/pnp2r30rd3ld3jfkk7zhl09xpxkiyg9w-emacs-27.0.50/bin/emacsclient (27.0.50)
 default: /nix/store/pnp2r30rd3ld3jfkk7zhl09xpxkiyg9w-emacs-27.0.50/bin/emacsclient (27.0.50)
 funcall: /nix/store/pnp2r30rd3ld3jfkk7zhl09xpxkiyg9w-emacs-27.0.50/bin/emacsclient (27.0.50)
path:
  $PATH: "/home/chronos/bin:/run/wrappers/bin:/etc/profiles/per-user/chronos/bin:/home/chronos/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin"
  exec-path: (/nix/store/773xq6893if0r25na6a9f6l1kvkrc4q4-emacs-packages-deps/bin /home/chronos/bin /run/wrappers/bin /etc/profiles/per-user/chronos/bin /home/chronos/.nix-profile/bin /nix/var/nix/profiles/default/bin /run/current-system/sw/bin /nix/store/pnp2r30rd3ld3jfkk7zhl09xpxkiyg9w-emacs-27.0.50/libexec/emacs/27.0.50/x86_64-pc-linux-gnu)
  with-editor-emacsclient-path:
    /nix/store/pnp2r30rd3ld3jfkk7zhl09xpxkiyg9w-emacs-27.0.50/bin (t)
      /nix/store/pnp2r30rd3ld3jfkk7zhl09xpxkiyg9w-emacs-27.0.50/bin/emacsclient (27.0.50)
    /nix/store/773xq6893if0r25na6a9f6l1kvkrc4q4-emacs-packages-deps/bin (t)
      /nix/store/773xq6893if0r25na6a9f6l1kvkrc4q4-emacs-packages-deps/bin/emacsclient (27.0.50)
    /home/chronos/bin (t)
    /run/wrappers/bin (/run/wrappers/wrappers.cqIHOod6cR)
    /etc/profiles/per-user/chronos/bin (nil)
    /home/chronos/.nix-profile/bin (t)
    /nix/var/nix/profiles/default/bin (nil)
    /run/current-system/sw/bin (t)
      /run/current-system/sw/bin/emacsclient (27.0.50)
    /nix/store/pnp2r30rd3ld3jfkk7zhl09xpxkiyg9w-emacs-27.0.50/libexec/emacs/27.0.50/x86_64-pc-linux-gnu (t)

should not with-editor start a server with a specific name?

(when (server-running-p server-name)

(server-start))

A bit about how I use emacs:

one emacs for org-mode with magit to sync files
another emacs daemon used by emacsclient for other edit task.

What frustrate me is once I used magit in the first emacs, the other emacs daemon will not start properly.

Would it not be better if with-editor always use a unique server-name no matter what the current server-name is.

with-editor-export-editor affecting find-dired

M-x find-dired no longer works when using (add-hook 'shell-mode-hook 'with-editor-export-editor):

Debugger entered--Lisp error: (wrong-type-argument processp nil)
set-process-filter(nil find-dired-filter)
find-dired("some/path" "")
call-interactively(find-dired record nil)
command-execute(find-dired record)
helm-M-x(nil "find-dired")
call-interactively(helm-M-x nil nil)
command-execute(helm-M-x)

Don't have a solution :( Currently working around it with:

(defun ar/use-emacs-for-shell-editor ()
  (unless (string-match-p "Find" (buffer-name))
    (with-editor-export-editor)))

(use-package with-editor :ensure t
  :config
  (add-hook 'shell-mode-hook 'ar/use-emacs-for-shell-editor))

Other than that, with-editor is working great in shell-mode. Thank you!

Help MacOS + Magit Users solve their "unsuitable" problems)

Hi, this may be more of a note about documentation than a bug, but, after dealing with the Warning message about a suitable EmacsClient (as mentioned in #26), I think it might be nice to be more explicit about how to do the following (for people who are left scratching their heads at this comment from the documentation):

...When it fails to do so, then the most likely reason is that someone found yet another way to package Emacs (most likely on macOS) without putting the executable on $PATH, and we have to add another kludge to find it anyway.

I cobbled together a solution by running a version of this command that was suitable to my system and $PATH:

ln -s /Applications/Emacs.app/Contents/MacOS/bin/emacsclient /usr/local/bin

as described at https://emacsformacosx.com/tips. And then of course adding to my ~/.bashrc):

alias emacsclient='/usr/local/bin' (as modified from a helpful note on the much-maligned wiki https://www.emacswiki.org/emacs/EmacsForMacOS#toc19)

As suggested in the documentation above, there are many ways to do this (and thus many ways to do this wrong!), but, if nothing else, hopefully this report might help point some other poor Mac user in the right direction.

Regardless, thanks again for the Magit-ical work!

proper way to use with-editor with minor mode active in opened buffer?

when i use (with-editor-async-shell-command ...) to spawn a command that opens an editor, a new emacs buffer opens, which is great. however, with-editor-mode is not enabled in that buffer, so the remaps from with-editor-mode-map are not active, which means it is hard to close the buffer in the proper way, since with-editor-finish or ...-cancel are not bound to any (standard) keys.

am i missing something?

error: Bad bounding indices: 0, 3

This error is coming from the cl-subseq call in the with-editor-locate-emacsclient-1 function. I'm running emacs "25.2" so the split-string only gets a 2 element list.

I've found 2 ways to fix it. One is to concat and extra ".0" to emacs-version. Either globally or in the let* of with-editor-locate-emacsclient-1. The other is to replace the hard 3 in with-editor-locate-emacsclient with (length (split-string emacs-version "\\."))

invalid-function `with-editor*`

With a recent upgrade of magit and with-editor, I am now experiencing this error:

  Debugger entered--Lisp error: (invalid-function with-editor*)
  with-editor*("GIT_EDITOR" #<process git>)
  magit-run-git-with-editor("commit" ("--"))
  magit-commit-create(nil)
  funcall-interactively(magit-commit-create nil)
  call-interactively(magit-commit-create)
  magit-invoke-popup-action(99)
  funcall-interactively(magit-invoke-popup-action 99)
  call-interactively(magit-invoke-popup-action nil nil)
  command-execute(magit-invoke-popup-action)

Magit 20181106.1203, Git 2.11.0, Emacs 25.1.1, gnu/linux

~/.emacs.d/elpa/with-editor-20181103.2149/

Installed with use-package with the following init.el:

;;
;; An all-around Emacs experience for an all-around development and
;; entertainment environment.
;;
;; Development: clojure, clojurescript, ruby, javascript, react, emacs
;; Entertainment: mu4e (email), emms
;; ---------------------------------------------------------------------------

;; Needed to install packages
(require 'package)
(add-to-list 'package-archives
             '("melpa" . "https://melpa.org/packages/") t)
(add-to-list 'package-archives
	     '("org" . "http://orgmode.org/elpa/") t)
(package-initialize)
(package-refresh-contents)

(unless (package-installed-p 'use-package)
  (package-install 'use-package))

(load-library "~/.emacs.d/private/secrets.el.gpg")

;; ----- Helper functions -----
(defun get-string-from-file (filePath)
  "Return FILEPATH's file content."
  (with-temp-buffer
    (insert-file-contents filePath)
    (buffer-string)))

;; ----- Manage Packages -------
(use-package auto-package-update
  :ensure t
  :config
  (setq auto-package-update-delete-old-versions t)
  (setq auto-package-update-hide-results t)
  (auto-package-update-maybe))

(use-package paradox
  :ensure t
  :config
  (paradox-enable))

;; ----- Navigation -------
(use-package ace-jump-mode
  :ensure t
  :bind ("C-." . ace-jump-mode))
(use-package multiple-cursors
  :ensure t
  :bind ("C-S-C C-S-C" . mc/edit-lines))

;; ----- Shell ------
(use-package multi-term
  :ensure t)

(use-package exec-path-from-shell
  :ensure t
  :config
  (exec-path-from-shell-initialize))

;; ----- Development -------
(use-package magit
  :ensure t)

(use-package smartparens
  ;;:delight
  :ensure t
  :config
  (smartparens-global-mode 1))

(use-package rainbow-delimiters
  :delight
  :ensure t
  :hook (prog-mode . rainbow-delimiters-mode))

(use-package company
  :ensure t
  :delight
  :hook (after-init . global-company-mode))

(use-package yasnippet
  :ensure t
  :delight
  :config
  (yas-global-mode 1))

(use-package projectile
  :ensure t)

(use-package projectile-direnv
  :ensure t
  :requires projectile)

(use-package projectile-git-autofetch
  :ensure t
  :requires projectile)

(use-package org-projectile
  :ensure t
  :requires (org projectile))

;; Clojure
(use-package clojure-snippets
  :requires yasnippet
  :ensure t)

(use-package cider
  :ensure t
  :init
  (setq cider-inject-dependencies-at-jack-in t))

(use-package ob-clojurescript
  :ensure t
  :requires org)

(use-package 4clojure
  :ensure t
  :requires cider)


;; Java
(use-package java-snippets
  :requires yasnippet
  :ensure t
  )

;; React
(use-package react-snippets
  :requires yasnippet
  :ensure t)

;; Markdown
(use-package markdown-mode
  :ensure t)

;; ----- RSS -------
(use-package elfeed-org
  :ensure t
  :requires elfeed
  :config
  (setq rmh-elfeed-org-files (list "~/.emacs.d/private/elfeed.org"))
  :init
  (elfeed-org)
  )

;; ------- Entertainment ------
(use-package emms
  :ensure t
  :config
    (setq emms-score-file "~/.emacs.d/private/emms/scores"
        emms-stream-bookmarks-file "~/.emacs.d/private/emms/emms-streams"
        emms-history-file "~/.emacs.d/private/emms/emms-history"
        emms-cache-file "~/.emacs.d/private/emms/emms-cache"
        emms-source-file-default-directory "~/Music"
        emms-player-mpg321-parameters '("-o" "alsa")
        emms-player-list '(emms-player-mplayer
                           emms-player-ogg123
                           emms-player-mpg321))
    :init
    (emms-minimalistic)
    (emms-default-players))

(use-package org-chef
  :ensure t
  :requires org)


;; ----- Miscellaneous -----
(use-package password-store
  :ensure t)

;; Old eyes like a larger font
(set-face-attribute 'default nil :height 140)

;; ------- Emacs Managed Settings ------
(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(ansi-color-faces-vector
   [default default default italic underline success warning error])
 '(custom-enabled-themes (quote (tango-dark)))
 '(inhibit-startup-screen t)
 '(package-selected-packages
   (quote
    (markdown-mode markdown chess gnugo magit password-store org-chef emms elfeed-org react-snippets java-snippets 4clojure ob-clojurescript cider clojure-snippets org-projectile projectile-git-autofetch projectile-direnv projectile yasnippet company rainbow-delimiters smartparens ox-reveal exec-path-from-shell multi-term multiple-cursors ace-jump-mode auto-package-update use-package)))
 '(sp-echo-match-when-invisible t))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(rainbow-delimiters-base-face ((t (:inherit nil :weight extra-bold)))))

Recent commit breaks emacsclient

Commit ae23243 breaks emacsclient for me: it fails with

ERROR: Invalid function: (` ((, file) , _))

I suspect the pcase-dolist in that commit is malformed.

This is emacs 24.4 under Linux Mint Debian Edition. Output of with-editor-debug:

with-editor: /u/c/feb/.emacs.d/elpa/with-editor-20170924.1057/with-editor.el
emacs: /usr/bin/emacs (24.4.1)
system:
system-type: gnu/linux
system-configuration: x86_64-pc-linux-gnu
system-configuration-options: --build x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib --libexecdir=/usr/lib --localstatedir=/var/lib --infodir=/usr/share/info --mandir=/usr/share/man --with-pop=yes --enable-locallisppath=/etc/emacs24:/etc/emacs:/usr/local/share/emacs/24.4/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.4/site-lisp:/usr/share/emacs/site-lisp --build x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib --libexecdir=/usr/lib --localstatedir=/var/lib --infodir=/usr/share/info --mandir=/usr/share/man --with-pop=yes --enable-locallisppath=/etc/emacs24:/etc/emacs:/usr/local/share/emacs/24.4/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.4/site-lisp:/usr/share/emacs/site-lisp --with-x=yes --with-x-toolkit=gtk3 --with-toolkit-scroll-bars 'CFLAGS=-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wall' CPPFLAGS=-D_FORTIFY_SOURCE=2 LDFLAGS=-Wl,-z,relro
server:
server-running-p: t
server-process: #
server-use-tcp: nil
server-name: server
server-socket-dir: /tmp/emacs1134
server
server4575
server-auth-dir: ~/.emacs.d/server/
WARNING: not an accessible directory
with-editor-emacsclient-executable:
value: /usr/bin/emacsclient.emacs24 (24.4)
default: /usr/bin/emacsclient.emacs24 (24.4)
funcall: /usr/bin/emacsclient.emacs24 (24.4)
path:
$PATH: ".:/u/c/feb/scripts:/u/c/feb/bin:/u/c/feb/bin.x86_64:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
exec-path: (. /u/c/feb/scripts /u/c/feb/bin /u/c/feb/bin.x86_64 /usr/local/bin /usr/bin /bin /usr/local/games /usr/games /usr/lib/emacs/24.4/x86_64-linux-gnu)
with-editor-emacsclient-path:
. (t)
/u/c/feb/scripts (t)
/u/c/feb/bin (t)
/u/c/feb/bin.x86_64 (nil)
/usr/local/bin (t)
/usr/bin (t)
/usr/bin/emacsclient (24.4)
/usr/bin/emacsclient.emacs24 (24.4)
/bin (t)
/usr/local/games (t)
/usr/games (t)
/usr/lib/emacs/24.4/x86_64-linux-gnu (t)

Can't find emacsclient if default-directory doesn't exist

It seems that with-editor-locate-emacsclient fails if default-directory doesn't exist. For example, with a current master build of Emacs and with-editor:

$ /correct/path/to/emacs/src/emacs -Q -batch -l ./with-editor.el -eval '(print (with-editor-locate-emacsclient))'
"/correct/path/to/emacs/lib-src/emacsclient"

But:

$ /correct/path/to/emacs/src/emacs -Q -batch -l ./with-editor.el -eval '(let ((default-directory "/does/not/exist/")) (print (with-editor-locate-emacsclient)))'
Warning (with-editor): Cannot determine a suitable Emacsclient

Determining an Emacsclient executable suitable for the
current Emacs instance failed.  For more information
please see https://github.com/magit/magit/wiki/Emacsclient.

nil

GitError! There was a problem with the editor '/usr/bin/emacsclient.emacs --socket-name=/tmp/emacs1000/server'.

Attempting to commit with magit generates the error: GitError! There was a problem with the editor '/usr/bin/emacsclient.emacs --socket-name=/tmp/emacs1000/server'. [Type '$' for details]

Hitting $ gives me:

hint: Waiting for your editor to close the file...
Waiting for Emacs...
*ERROR*: ‘recenter’ing a window that does not display current-buffer.
error: There was a problem with the editor '/usr/bin/emacsclient.emacs --socket-name=/tmp/emacs1000/server'.
Please supply the message using either -m or -F option.

M-x magit-version:

Magit 20191227.1438, Git 2.20.1, Emacs 26.3, gnu/linux

This is on Ubuntu 19.10.

output of M-x with-editor-debug:

 exec-path: (/home/anders/bin /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /usr/games /usr/local/games /snap/bin /home/anders/code/go/bin /home/anders/code/go/go/bin /home/anders/work/google-cloud-sdk/bin /usr/lib/emacs/26.3/x86_64-linux-gnu)
  with-editor-emacsclient-path:
    /home/anders/bin (t)
    /usr/local/sbin (t)
    /usr/local/bin (t)
    /usr/sbin (t)
    /usr/bin (t)
      /usr/bin/emacsclient (26.3)
      /usr/bin/emacsclient.emacs (26.3)
    /sbin (usr/sbin)
    /bin (usr/bin)
      /bin/emacsclient (26.3)
      /bin/emacsclient.emacs (26.3)
    /usr/games (t)
    /usr/local/games (t)
    /snap/bin (t)
    /home/anders/code/go/bin (t)
    /home/anders/code/go/go/bin (t)
    /home/anders/work/google-cloud-sdk/bin (t)
    /usr/lib/emacs/26.3/x86_64-linux-gnu (t)

Type error on commit with magit

I get the following when trying to commit with magit since I updated to Fedora 30 (via reinstall) the other day:

  1 git … commit --
hint: Waiting for your editor to close the file...
Waiting for Emacs...
*ERROR*: Wrong type argument: stringp, nil
error: There was a problem with the editor '/usr/bin/emacsclient --socket-name=/tmp/emacs1000/main'.
Please supply the message using either -m or -F option.

The one thing that I can think of might have caused this is that the reinstall meant new versions of all packages (incluing magit and with-editor).

My Config (I don't expect you to browse through that, just posting for completeness).

M-x with-editor-debug gives me:

with-editor: /home/mattiasb/.emacs.d/elpa/with-editor-20190224.931/with-editor.el
emacs: /usr/bin/emacs (26.1)
system:
  system-type: gnu/linux
  system-configuration: x86_64-redhat-linux-gnu
  system-configuration-options: --build=x86_64-redhat-linux-gnu --host=x86_64-redhat-linux-gnu --program-prefix= --disable-dependency-tracking --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64 --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/var/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-dbus --with-gif --with-jpeg --with-png --with-rsvg --with-tiff --with-xft --with-xpm --with-x-toolkit=gtk3 --with-gpm=no --with-xwidgets --with-modules build_alias=x86_64-redhat-linux-gnu host_alias=x86_64-redhat-linux-gnu 'CFLAGS=-DMAIL_USE_LOCKF -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' LDFLAGS=-Wl,-z,relro PKG_CONFIG_PATH=:/usr/lib64/pkgconfig:/usr/share/pkgconfig
server:
  server-running-p: t
  server-process: #<process main>
  server-use-tcp: nil
  server-name: main
  server-socket-dir: /tmp/emacs1000
    main
  server-auth-dir: ~/.emacs.d/server/
    WARNING: not an accessible directory
with-editor-emacsclient-executable:
 value:   /usr/bin/emacsclient (26.1)
 default: /usr/bin/emacsclient (26.1)
 funcall: /usr/bin/emacsclient (26.1)
path:
  $PATH: "/home/mattiasb/.local/bin:/home/mattiasb/.local/share/gem/bin:/home/mattiasb/.cabal/bin:/usr/share/Modules/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin"
  exec-path: (/home/mattiasb/.local/bin /home/mattiasb/.local/share/gem/bin /home/mattiasb/.cabal/bin /usr/share/Modules/bin /usr/local/bin /usr/local/sbin /usr/bin /usr/sbin /usr/libexec/emacs/26.1/x86_64-redhat-linux-gnu)
  with-editor-emacsclient-path:
    /home/mattiasb/.local/bin (t)
    /home/mattiasb/.local/share/gem/bin (nil)
    /home/mattiasb/.cabal/bin (nil)
    /usr/share/Modules/bin (t)
    /usr/local/bin (t)
    /usr/local/sbin (t)
    /usr/bin (t)
      /usr/bin/emacsclient (26.1)
    /usr/sbin (t)
    /usr/libexec/emacs/26.1/x86_64-redhat-linux-gnu (t)

My EDITOR env var is: EDITOR=emacsclient -c -nw -s main.

Is it a good idea to change `server-name' 's value?

with-editor/with-editor.el

Lines 428 to 433 in ee39f23

(unless server-process
(when (server-running-p server-name)
(setq server-name (format "server%s" (emacs-pid)))
(when (server-running-p server-name)
(server-force-delete server-name)))
(server-start))

Is it a good idea to change server-name 's value?
Someone maybe use server-name outside emacs, such as using emacsclient with server or socket file name which is same as default server-name value.

initial shell output discarded

with-editor-export-editor sets the process-filter to ignore output while injecting the process string. This discards the initial output of the shell, including motd and the shell prompt so initially the buffer is blank.

with-editor-export-editor sets the environment variable, but editing something opens an empty buffer

First off, my environment:

  • GNU Emacs 26.1 (build 1, x86_64-apple-darwin14.5.0, NS appkit-1348.17 Version 10.10.5 (Build 14F2511)) of 2018-05-28
  • MaGit version 20180612.1617
  • with-editor version 20180414.757

Here is what happens:

  • I run a command that requests an editor
  • A new buffer opens that has the address to some temporary file
  • Killing with C-c C-k or saving with C-c C-c returns me to the *shell* buffer, where the sleep command is still stuck.

At this point, I have to use C-c C-c in the shell buffer to get my prompt back.

magit fails to locate emacsclient at /usr/local/bin/emacsclient

Hi,

I compiled emacs 26.2 in ubuntu (still in 14.04) to use with doom-emacs and it reports that it cannot locate emacsclient

Warning (with-editor): Cannot determine a suitable Emacsclient

Determining an Emacsclient executable suitable for the
current Emacs instance failed.  For more information
please see https://github.com/magit/magit/wiki/Emacsclient.
Warning (ox-pandoc): Pandoc version number can not be retrieved.

in spite of

$ which emacsclient
/usr/local/bin/emacsclient

$ emacsclient -v
emacsclient 26.2

I could not locate any reason why magit failed to locate the emacsclient which was installed on the default location. Any clues?

Cheers,

Cannot commit - The directory '~/.emacs.d/server' is unsafe

Hello,

As stated in the title I cannot commit my staged changes. I get the message:
The directory '~/.emacs.d/server' is unsafe

Output of magit-version:
Magit 2.11.0, Git 2.14.2.windows.3, Emacs 25.3.1, windows-nt

Output of with-editor-debug:

with-editor: c:/Users/atabbern/AppData/Roaming/.emacs.d/elpa/with-editor-2.7.0/with-editor.el
emacs: c:/emacs-25.3-i686/bin/emacs (25.3.1)
system:
  system-type: windows-nt
  system-configuration: i686-w64-mingw32
  system-configuration-options: --host=i686-w64-mingw32 --without-dbus --without-compress-install 'CFLAGS=-static -O2 -g3'
server:
  server-running-p: nil
  server-process: nil
  server-use-tcp: t
  server-name: server
  server-socket-dir: nil
    WARNING: not an accessible directory
  server-auth-dir: ~\.emacs.d\server\
with-editor-emacsclient-executable:
 value:   c:/emacs-25.3-i686/bin/emacsclient.exe (25.3)
 default: c:/emacs-25.3-i686/bin/emacsclient.exe (25.3)
 funcall: c:/emacs-25.3-i686/bin/emacsclient.exe (25.3)
path:
  $PATH: "C:\\Program Files\\ImageMagick-7.0.7-Q16;C:\\Program Files (x86)\\Intel\\iCLS Client\\;C:\\Program Files\\Intel\\iCLS Client\\;C:\\windows\\system32;C:\\windows;C:\\windows\\System32\\Wbem;C:\\windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Windows\\CCM;C:\\windows\\CCM;C:\\Program Files\\Intel\\WiFi\\bin\\;C:\\Program Files\\Common Files\\Intel\\WirelessCommon\\;C:\\windows\\CCM;C:\\windows\\CCM;C:\\Program Files\\Microsoft\\Web Platform Installer\\;C:\\Program Files (x86)\\Microsoft ASP.NET\\ASP.NET Web Pages\\v1.0\\;C:\\Program Files (x86)\\Windows Kits\\8.0\\Windows Performance Toolkit\\;C:\\Program Files\\Microsoft SQL Server\\110\\Tools\\Binn\\;C:\\Program Files\\Microsoft SQL Server\\Client SDK\\ODBC\\110\\Tools\\Binn\\;C:\\Program Files (x86)\\Microsoft SQL Server\\120\\Tools\\Binn\\;C:\\Program Files\\Microsoft SQL Server\\120\\Tools\\Binn\\;C:\\Program Files\\Microsoft SQL Server\\120\\DTS\\Binn\\;C:\\Program Files (x86)\\Microsoft SQL Server\\120\\Tools\\Binn\\ManagementStudio\\;C:\\Program Files (x86)\\Microsoft SQL Server\\120\\DTS\\Binn\\;C:\\apps\\FME\\;C:\\Python27\\ArcGIS10.2\\;C:\\emacs-25.3-i686\\bin;C:\\Program Files\\PostgreSQL\\10\\bin;C:\\Program Files\\PostgreSQL\\Apache\\apache\\bin;C:\\Program Files\\Git\\cmd;C:\\Program Files (x86)\\Intel\\iCLS Client\\;C:\\Program Files\\Intel\\iCLS Client\\;C:\\windows\\system32;C:\\windows;C:\\windows\\System32\\Wbem;C:\\windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Windows\\CCM;C:\\windows\\CCM;C:\\Program Files\\Intel\\WiFi\\bin\\;C:\\Program Files\\Common Files\\Intel\\WirelessCommon\\;C:\\windows\\CCM;C:\\windows\\CCM;C:\\Program Files\\Microsoft\\Web Platform Installer\\;C:\\Program Files (x86)\\Microsoft ASP.NET\\ASP.NET Web Pages\\v1.0\\;C:\\Program Files (x86)\\Windows Kits\\8.0\\Windows Performance Toolkit\\;C:\\Program Files\\Microsoft SQL Server\\110\\Tools\\Binn\\;C:\\Program Files\\Microsoft SQL Server\\Client SDK\\ODBC\\110\\Tools\\Binn\\;C:\\Program Files (x86)\\Microsoft SQL Server\\120\\Tools\\Binn\\;C:\\Program Files\\Microsoft SQL Server\\120\\Tools\\Binn\\;C:\\Pro"
  exec-path: (c:/Program Files/ImageMagick-7.0.7-Q16 C:/Program Files (x86)/Intel/iCLS Client/ C:/Program Files/Intel/iCLS Client/ C:/windows/system32 C:/windows C:/windows/System32/Wbem C:/windows/System32/WindowsPowerShell/v1.0/ C:/Program Files/Intel/Intel(R) Management Engine Components/DAL C:/Program Files/Intel/Intel(R) Management Engine Components/IPT C:/Program Files (x86)/Intel/Intel(R) Management Engine Components/DAL C:/Program Files (x86)/Intel/Intel(R) Management Engine Components/IPT C:/Windows/CCM C:/windows/CCM C:/Program Files/Intel/WiFi/bin/ C:/Program Files/Common Files/Intel/WirelessCommon/ C:/windows/CCM C:/windows/CCM C:/Program Files/Microsoft/Web Platform Installer/ C:/Program Files (x86)/Microsoft ASP.NET/ASP.NET Web Pages/v1.0/ C:/Program Files (x86)/Windows Kits/8.0/Windows Performance Toolkit/ C:/Program Files/Microsoft SQL Server/110/Tools/Binn/ C:/Program Files/Microsoft SQL Server/Client SDK/ODBC/110/Tools/Binn/ C:/Program Files (x86)/Microsoft SQL Server/120/Tools/Binn/ C:/Program Files/Microsoft SQL Server/120/Tools/Binn/ C:/Program Files/Microsoft SQL Server/120/DTS/Binn/ C:/Program Files (x86)/Microsoft SQL Server/120/Tools/Binn/ManagementStudio/ C:/Program Files (x86)/Microsoft SQL Server/120/DTS/Binn/ C:/apps/FME/ C:/Python27/ArcGIS10.2/ C:/emacs-25.3-i686/bin C:/Program Files/PostgreSQL/10/bin C:/Program Files/PostgreSQL/Apache/apache/bin C:/Program Files/Git/cmd C:/Program Files (x86)/Intel/iCLS Client/ C:/Program Files/Intel/iCLS Client/ C:/windows/system32 C:/windows C:/windows/System32/Wbem C:/windows/System32/WindowsPowerShell/v1.0/ C:/Program Files/Intel/Intel(R) Management Engine Components/DAL C:/Program Files/Intel/Intel(R) Management Engine Components/IPT C:/Program Files (x86)/Intel/Intel(R) Management Engine Components/DAL C:/Program Files (x86)/Intel/Intel(R) Management Engine Components/IPT C:/Windows/CCM C:/windows/CCM C:/Program Files/Intel/WiFi/bin/ C:/Program Files/Common Files/Intel/WirelessCommon/ C:/windows/CCM C:/windows/CCM C:/Program Files/Microsoft/Web Platform Installer/ C:/Program Files (x86)/Microsoft ASP.NET/ASP.NET Web Pages/v1.0/ C:/Program Files (x86)/Windows Kits/8.0/Windows Performance Toolkit/ C:/Program Files/Microsoft SQL Server/110/Tools/Binn/ C:/Program Files/Microsoft SQL Server/Client SDK/ODBC/110/Tools/Binn/ C:/Program Files (x86)/Microsoft SQL Server/120/Tools/Binn/ C:/Program Files/Microsoft SQL Server/120/Tools/Binn/ C:/Pro c:/emacs-25.3-i686/libexec/emacs/25.3/i686-w64-mingw32)
  with-editor-emacsclient-path:
    c:/emacs-25.3-i686/bin (t)
      c:/emacs-25.3-i686/bin/emacsclient.exe (25.3)
    c:/Program Files/ImageMagick-7.0.7-Q16 (t)
    C:/Program Files/Microsoft SQL Server/120/DTS/Binn/ (nil)
    C:/Program Files (x86)/Microsoft SQL Server/120/Tools/Binn/ManagementStudio/ (nil)
    C:/Program Files (x86)/Microsoft SQL Server/120/DTS/Binn/ (nil)
    C:/apps/FME/ (t)
    C:/Python27/ArcGIS10.2/ (t)
    C:/emacs-25.3-i686/bin (t)
      C:/emacs-25.3-i686/bin/emacsclient.exe (25.3)
    C:/Program Files/PostgreSQL/10/bin (t)
    C:/Program Files/PostgreSQL/Apache/apache/bin (t)
    C:/Program Files/Git/cmd (t)
    C:/Program Files (x86)/Intel/iCLS Client/ (t)
    C:/Program Files/Intel/iCLS Client/ (t)
    C:/windows/system32 (t)
    C:/windows (t)
    C:/windows/System32/Wbem (t)
    C:/windows/System32/WindowsPowerShell/v1.0/ (t)
    C:/Program Files/Intel/Intel(R) Management Engine Components/DAL (t)
    C:/Program Files/Intel/Intel(R) Management Engine Components/IPT (t)
    C:/Program Files (x86)/Intel/Intel(R) Management Engine Components/DAL (t)
    C:/Program Files (x86)/Intel/Intel(R) Management Engine Components/IPT (t)
    C:/Windows/CCM (t)
    C:/Program Files/Intel/WiFi/bin/ (nil)
    C:/Program Files/Common Files/Intel/WirelessCommon/ (nil)
    C:/windows/CCM (t)
    C:/Program Files/Microsoft/Web Platform Installer/ (nil)
    C:/Program Files (x86)/Microsoft ASP.NET/ASP.NET Web Pages/v1.0/ (nil)
    C:/Program Files (x86)/Windows Kits/8.0/Windows Performance Toolkit/ (nil)
    C:/Program Files/Microsoft SQL Server/110/Tools/Binn/ (t)
    C:/Program Files/Microsoft SQL Server/Client SDK/ODBC/110/Tools/Binn/ (nil)
    C:/Program Files (x86)/Microsoft SQL Server/120/Tools/Binn/ (nil)
    C:/Program Files/Microsoft SQL Server/120/Tools/Binn/ (nil)
    C:/Pro (nil)
    c:/emacs-25.3-i686/libexec/emacs/25.3/i686-w64-mingw32 (t)

Any help is greatly appreciated. Thanks!

with-editor unavailable on MELPA, failing installaions

After trying to install Magit on a new Emacs configuration, it is unable to install from Melpa as it is the latest version appears to be unavailable.

How I produced this:
(use-package magit :ensure t :bind ("C-x g" . magit-status) ("C-x M-g" . magit-dispatch-popup))

(use-package): Failed to install magit: https://melpa.org/packages/with-editor-20181031.1658.tar: Not found

(package-install with-editor)

https://melpa.org/packages/with-editor-20181031.1658.tar: Not found

Something goes wrong when connecting to socket created by systemd

Please consider to add an user option (variable) to set path to socket file.

Long story:

Beginning with commit "Add external socket launching support" there is possibility to start Emacs daemon using external socket. There is special variable to reflect this: :use-external-socket but of course there is no way to determine the name of a socket and its path within Emacs (the example how to use socket activation of Emacs daemon is in documentation, one may find them in the same commit ). For such cases an user option would help to use magit that uses with-editor in turm.

EDITOR is not set correctly for it to be usable in zsh.

Contrary to what many people seem to think the zsh is not backward compatible with bourne shells. The main area of incompatiblilty is that it does not parse strings as words separated by spaces, but has another construct called an array which does do this. Here is a simple example of how it goes wrong:

To take a simple example, if I do:
  ~% test="ls -l" 
  ~% $test    
zsh: command not found: ls -l

As you can see “ls -l” has been taken as the name of a command, not a command followed by an argument. When I try to run a terminal with inside emacs I get the following:

 12012 ~% export EDITOR=sh\ -c\ \'echo\ \"WITH-EDITOR\:\ \$\$\ OPEN\ \$0\"\;\ sleep\ 604800\ \&\ sleep\=\$\!\;\ trap\ \"kill\ \$sleep\;\ exit\ 0\"\ USR1\;\ trap\ \"kill\ \$sleep\;\ exit\ 1\"\ USR2\;\ wait\ \$sleep\'
export: EDITOR: inconsistent type for assignment
 12013 ~% echo $EDITOR
emacsclient           
 12014 ~% 

The basic cause is the same, namely that zsh does not parse strings the same way as other shells. Note, in particular that the value of EDITOR remains unchanged.

The simplest situation in which I get this effect ist to run:

emacs -Q -l tester.el

Where tester.el contains the following code:

(add-to-list 'load-path "/path/to/with-editor")
(add-to-list 'load-path "/path/to/dash")
(add-hook 'term-exec-hook   'with-editor-export-editor)
(require 'with-editor)

If I then do M-x ansi-term and ask it to run /bin/zsh, I get the error.

In case it is of use my emacs version is:

GNU Emacs 25.1.50.1 (x86_64-unknown-linux-gnu, GTK+ Version [3.14.5) of 2016-09-14

uname -a gives:

Linux snares-penguin 4.7.3-gnu #1 SMP Wed Sep 7 13:31:10 UTC 2016 x86_64 GNU/Linux

And I am using stumpwm window manager.

To solve the problem, EDITOR needs to be a zsh array as in:

export EDITOR=( sh -c 'echo "WITH-EDITOR: $$ OPEN $0"; sleep 604800 & sleep=$!; trap "kill $sleep; exit 0" USR1; trap "kill $sleep; exit 1" USR2; wait $sleep' )

Note that there is no way of achieving this by changing with-editor-sleeping-editor. As a temporary solution I have edited lines 549-552 of with-editor.el from:

(process-send-string
       process (format "export %s=%s\n" envvar
                       (shell-quote-argument with-editor-sleeping-editor)))

to:

(process-send-string
       process (format "export %s=%s\n" envvar
                       "( sh -c 'echo \"WITH-EDITOR: $$ OPEN $0\"; sleep 604800 & sleep=$!; trap \"kill $sleep; exit 0\" USR1; trap \"kill $sleep; exit 1\" USR2; wait $sleep' )"))

but something better is needed, especially when dealing with remote shells which may or may not be zsh.

Problem with emacsclient and Windows

Under Windows, emacsclient has the (bad) property of not writing anything on the console, but rather reporting any output in a modal window. So the automatic detection fails. Any idea on how to solve this?
Also I'm not sure that the sleeping editor would work under Windows.

disable the focus grabbing behavior of with-editor

Hi, when executing magit-status and quickly focus out emacs, after the magit buffer pops up, emacs grabs the focus back. This is quite inconvenient. Is there a way to prevent that focus changing? Thanks!

After installing `with-editor*` not found

Hi,

I just installed via package-install with-editor and it installed correctly.

However, even after restarting Emacs I get M-x with-edi [No match] when I try to run any with-editor commands.

C-c C-c saves the file, but it's not recognized by the host program as an edit

Hi,

I'm trying to edit a file over SSH, but it's not working. Here is what I've done:

  • I've opened a tramp session to the remote host by doing C-x C-f /dockerbuild:, which connects me to the dockerbuild host.
  • I've opened a shell by doing M-x shell.
  • Then I've done M-x with-editor-export-editor, and I've verified that echo $EDITOR is indeed set.
  • Then I run kubectl edit deployment nginx, which is supposed to open an editor where I can edit a Kubernetes deployment. At this stage, a new buffer is opened as expected, and I see that I can do C-c C-c to save and C-c C-k to cancel.
  • I edit this file and do C-c C-c, the buffer is closed, and I see this in the *Messages* buffer:
Saving file /scp:dockerbuild:/tmp/kubectl-edit-81x80.yaml...
Tramp: Encoding local file ‘/var/folders/z0/_fn2998s7nz108464zj61b1dw19tm9/T/tramp.908l3g.yaml’ using ‘base64-encode-region’...done
Tramp: Decoding remote file ‘/scp:dockerbuild:/tmp/kubectl-edit-81x80.yaml’ using ‘base64 -d -i >%s’...done
Wrote /scp:dockerbuild:/tmp/kubectl-edit-81x80.yaml

At this stage, the *shell* buffer is selected, and I see this:

WITH-EDITOR: 61820 OPEN /tmp/kubectl-edit-wb4q5.yaml
Edit cancelled, no changes made.

Everything seems to be working perfectly, but for some reason the edits are not recognized.

I've verified that locally editing something with my editor set to emacs-client works -- Kubernetes recognizes my changes, so as far as I can guess it is not an issue with kubectl.

Thanks!

Missing the COPYING and author files

Hello,

While making the Debian package for with-editor, it appear that this package lack its copy of the GPL, when the copyright say that a copy of the GPL should be there.

Also, the copyright is given to the "The Magit Project Contributors", but there is no list of those. I've run git log -- lisp/with-editor.el | grep Author | sort -u, and found the following list of author:

 Barak A. Pearlmutter <[email protected]>
 Jonas Bernoulli <[email protected]>
 Lele Gaifax <[email protected]>
 Noam Postavsky <[email protected]>
 Rémi Vanicat <[email protected]>

Thanks.

Using C-x C-c in emacsclient doesn't behave as expected

In recent versions (within the last few months, I'm not sure), when I open a session with emacsclient -t and then attempt to finish with C-x C-c, I get the warning "Don’t kill this buffer. Instead cancel using C-c C-k." Of course, using C-c C-c at this point does what I want to do, but it seems an unnecessary complication, considering how

  1. C-x C-c has so much muscle-memory behind it;
  2. my impression has always been that C-x C-c is supposed to "do the right thing" inside an emacsclient session; and
  3. it's worked in the past under with-editor.

Of course, I understand there's likely some fundamental misunderstanding on my part.

I originally installed this package as a dependency of git-commit, which has been super useful for me.

Thanks!

git-commit-post-finish-hook possible bug

One thing I noticed when developing magit-patch-changelog was I couldn't make git-commit-post-finish-hook work. I traced it down to this line always being false after with-editor-return kills the COMMIT_MSG buffer.

MWE:

emacs -Q --batch -L . -l with-editor --eval "(package-initialize)" -l magit --eval "(with-temp-buffer \
    (defun git-commit-run-post-finish-hook () \
      (setq flag 1) \
      (run-hooks 'git-commit-post-finish-hook)) \
    (setq-local git-commit-post-finish-hook '((lambda () (setq flag 2)))) \
    (add-hook 'with-editor-post-finish-hook 'git-commit-run-post-finish-hook)
    (with-editor-finish nil) \
    (cl-assert flag) \
    (cl-assert (featurep 'git-commit)) \
    (cl-assert (= flag 2)))"

Given git-commit-run-post-finish-hook's already dubious standing, I might consider removing the variable altogether.

cannot get magit to commit

when I try and commit from magit status I get:

GitError! There was a problem with the editor '/Applications/Emacs.app/Contents/MacOS/bin/emacsclient --socket-name=/tmp/emacs501/server36854'.  [Type `$' for details]

when I press $ I get:

hint: Waiting for your editor to close the file...
Waiting for Emacs...
*ERROR*: Symbol’s function definition is void: magit-process
error: There was a problem with the editor '/Applications/Emacs.app/Contents/MacOS/bin/emacsclient --socket-name=/tmp/emacs501/server36854'.
Please supply the message using either -m or -F option.

output of debug:

 value:   /Applications/Emacs.app/Contents/MacOS/bin/emacsclient (26.1)
 default: /Applications/Emacs.app/Contents/MacOS/bin/emacsclient (26.1)
 funcall: /Applications/Emacs.app/Contents/MacOS/bin/emacsclient (26.1)
path:
  $PATH: "/Users/max/.rbenv/shims:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/usr/local/MacGPG2/bin:/opt/X11/bin:/Applications/Wireshark.app/Contents/MacOS:/Users/max/.rbenv/shims:/Users/max/bin:/Applications/Emacs.app/Contents/MacOS/bin-x86_64-10_10:/Applications/Emacs.app/Contents/MacOS/libexec-x86_64-10_10"
  exec-path: (/Users/max/.rbenv/shims/ /usr/local/bin/ /usr/local/sbin/ /usr/bin/ /bin/ /usr/sbin/ /sbin/ /usr/local/go/bin/ /usr/local/MacGPG2/bin/ /opt/X11/bin/ /Applications/Wireshark.app/Contents/MacOS/ /Users/max/.rbenv/shims/ /Users/max/bin/ /Applications/Emacs.app/Contents/MacOS/bin-x86_64-10_10/ /Applications/Emacs.app/Contents/MacOS/libexec-x86_64-10_10/ /Applications/Emacs.app/Contents/MacOS/libexec/)
  with-editor-emacsclient-path:
    /Applications/Emacs.app/Contents/MacOS/bin (bin-x86_64-10_5)
      /Applications/Emacs.app/Contents/MacOS/bin/emacsclient (26.1)
    /Applications/Emacs.app/Contents/MacOS (t)
    /usr/local/bin/ (t)
      /usr/local/bin/emacsclient (26.1)
    /usr/local/sbin/ (t)
    /usr/bin/ (t)
      /usr/bin/emacsclient (22.1)
    /bin/ (t)
    /usr/sbin/ (t)
    /sbin/ (t)
    /usr/local/go/bin/ (t)
    /usr/local/MacGPG2/bin/ (t)
    /opt/X11/bin/ (t)
    /Applications/Wireshark.app/Contents/MacOS/ (t)
    /Users/max/.rbenv/shims/ (t)
    /Users/max/bin/ (t)
    /Applications/Emacs.app/Contents/MacOS/bin-x86_64-10_10/ (t)
      /Applications/Emacs.app/Contents/MacOS/bin-x86_64-10_10/emacsclient (26.1)
    /Applications/Emacs.app/Contents/MacOS/libexec-x86_64-10_10/ (t)
    /Applications/Emacs.app/Contents/MacOS/libexec/ (t)

WITH-EDITOR... line doesn't work from a program that changes directory

I'm using a remote shell to explore a git checkout tree, run diffs, and do commits. (Yes, I know, should learn magit one of these days. :-) I used with-editor-export-editor to set $EDITOR in the shell process.

If I'm in a subdirectory of the git tree (not the top level), then "git commit" appears to invoke the editor from the top of the tree, with a path like ".git/COMMIT_EDITMSG"; running "lsof -p" on the "sleep" process run in the with-editor shell command confirms that its working directory is the top of the tree, not the directory where I invoked git from my shell, and therefore not the directory specified in default-directory (which is set correctly for my interactive shell's directory). So with-editor tries to edit a file that doesn't exist ($git_top/some/subdir/.git/COMMIT_EDITMSG), tells me how to create the non-existent .git directory, etc.

I'm experimenting with a change to the shell command to use something like:
case "$0" in
/*) echo ... $0 ... ;;
*) echo ... $(pwd -L)/$0 ... ;;
esac; ...

and at least at first it seems to work.

Do not add-hook to term-mode-hook

The documentation has instructions to:

(add-hook 'term-mode-hook   'with-editor-export-editor)

However, that fires too early. term-mode-hook runs before the process is created. We want:

(add-hook 'term-exec-hook   'with-editor-export-editor)

"user-error: Don’t kill this buffer. Instead cancel using C-c C-k" when trying to quit emacs

I was about to commit a change, then added some more stuff and committed again, and was left with a stale COMMIT_EDITMSG buffer. On trying to kill-emacs later, I got

user-error: Don’t kill this buffer. Instead cancel using C-c C-k

but without any mention of which of my 200 or so buffers this was about …

Maybe instead of with-editor-kill-buffer-noop we could have something like "You should use C-c C-k to cancel safely. If you really want to kill this buffer, type 'yes'". Or at least it could mention the name of the buffer?

not working on windows10 prerelease, GUI

OS: Windows 10 Home Insider Preview 15007
Emacs dist: https://sourceforge.net/projects/emacsbinw64/

I installed magit. when emacs try to load magit - load with-editor also, emacs just shows message box few times and finally failed to find suitable emacsclient.
because emacsclient --version does not print version to stdout, but shows the message box. so with-editor-emacsclient-version not works, it just shows message box and failed to get version string.

Cannot Determine a suitable EmacsClient

Hi, when I want to use emacs tramp mode and maggit I get the following error:

Warning (with-editor): Cannot determine a suitable Emacsclient

After looking through the issues here is the complete output from the editor-debug:

with-editor: /Users/omer/.emacs.d/elpa/with-editor-20160408.201/with-editor.el
emacs: /usr/local/opt/emacs/Emacs.app/Contents/MacOS/Emacs (24.5.1)
system:
  system-type: darwin
  system-configuration: x86_64-apple-darwin15.5.0
  system-configuration-options: --prefix=/usr/local/Cellar/emacs/24.5 --enable-locallisppath=/usr/local/share/emacs/site-lisp --infodir=/usr/local/Cellar/emacs/24.5/share/info/emacs --with-xml2 --without-dbus --without-gnutls --with-ns --disable-ns-self-contained
server:
  server-running-p: nil
  server-process: nil
  server-use-tcp: nil
  server-name: server
  server-socket-dir: /var/folders/l2/g8583vx16jxf_2d3n050mqch0000gn/T//emacs501
    ERROR: not an accessible directory
  server-auth-dir: ~/.emacs.d/server/
    WARNING: not an accessible directory
magit-emacsclient-executable:
 value:   nil (nil)
 default: nil (nil)
 funcall: nil (nil)
path:
  $PATH: "/usr/bin:/bin:/usr/sbin:/sbin"
  exec-path: (/usr/bin /bin /usr/sbin /sbin /usr/local/Cellar/emacs/24.5/libexec/emacs/24.5/x86_64-apple-darwin15.5.0)
  with-editor-emacsclient-path:
    /usr/local/opt/emacs/Emacs.app/Contents/MacOS (t)
    /usr/bin (t)
      /usr/bin/emacsclient (22.1)
    /bin (t)
    /usr/sbin (t)
    /sbin (t)
    /usr/local/Cellar/emacs/24.5/libexec/emacs/24.5/x86_64-apple-darwin15.5.0 (t)

Seems like I need to modify $PATH but I am not sure about the correct order

Revert or provide config handle for old exit behavior

Hi, I understand that the change to exiting is intentional. However, I'd like to ask that either the change be reverted or a handle be provided for the old behavior.

The problem is that on machines without magit/with-editor installed, saving a nonempty commit_message buffer and exiting causes the commit to go through properly. As I understand it, this is because git is checking the exit status of the $EDITOR process to determine whether to commit, and an unclean exit is treated as "abort commit".

Having a different contract here makes learning the muscle memory difficult, but there is also the problem that if I accidentally save and C-x C-c, with with-editor, the contents of the commit message are lost, which I consider unacceptable.

I understand you prefer the new behavior, but could you at least provide a handle to restore the old?

Can't commit on macos - 10.12.6, emacs - 25.2

Error

1 git … commit --
Waiting for Emacs...
ERROR: Canceled by user
error: There was a problem with the editor '/Applications/Emacs.app/Contents/MacOS/bin-x86_64-10_9/emacsclient --socket-name=/var/folders/5r/2nbp1w853mqg29r19mxq7w8w0000gn/T/emacs501/server'.
Please supply the message using either -m or -F option.

installation of emacs:

through the cask
brew cask install emacs

with-editor debug:

With-editor: /Users/sapelkinav/.emacs.d/elpa/with-editor-20170707.1401/with-editor.el
emacs: /Applications/Emacs.app/Contents/MacOS/Emacs-x86_64-10_9 (25.2.1)
system:
system-type: darwin
system-configuration: x86_64-apple-darwin13.4.0
system-configuration-options: --with-ns '--enable-locallisppath=/Library/Application Support/Emacs/${version}/site-lisp:/Library/Application Support/Emacs/site-lisp' --with-modules
server:
server-running-p: t
server-process: #
server-use-tcp: nil
server-name: server
server-socket-dir: /var/folders/5r/2nbp1w853mqg29r19mxq7w8w0000gn/T//emacs501
server
server-auth-dir: ~/.emacs.d/server/
WARNING: not an accessible directory
with-editor-emacsclient-executable:
value: /usr/local/bin/emacsclient (25.2)
default: /usr/local/bin/emacsclient (25.2)
funcall: /usr/local/bin/emacsclient (25.2)
path:
$PATH: "/Users/sapelkinav/.sdkman/candidates/groovy/current/bin:/usr/local/Cellar/node/8.1.3/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:/Users/sapelkinav/code/go/bin:/usr/local/opt/go/libexec/bin:/Applications/Emacs.app/Contents/MacOS/bin-x86_64-10_9:/Applications/Emacs.app/Contents/MacOS/libexec-x86_64-10_9"
exec-path: (/Users/sapelkinav/.sdkman/candidates/groovy/current/bin /usr/local/Cellar/node/8.1.3/bin /Library/Frameworks/Python.framework/Versions/3.6/bin /usr/local/bin /usr/bin /bin /usr/sbin /sbin /usr/local/share/dotnet /Users/sapelkinav/code/go/bin /usr/local/opt/go/libexec/bin /Applications/Emacs.app/Contents/MacOS/bin-x86_64-10_9 /Applications/Emacs.app/Contents/MacOS/libexec-x86_64-10_9 /Applications/Emacs.app/Contents/MacOS/libexec /Applications/Emacs.app/Contents/MacOS/bin)
with-editor-emacsclient-path:
/Applications/Emacs.app/Contents/MacOS (t)
/Users/sapelkinav/.sdkman/candidates/groovy/current/bin (t)
/usr/local/Cellar/node/8.1.3/bin (t)
/Library/Frameworks/Python.framework/Versions/3.6/bin (t)
/usr/local/bin (t)
/usr/local/bin/emacsclient (25.2)
/usr/bin (t)
/usr/bin/emacsclient (22.1)
/bin (t)
/usr/sbin (t)
/sbin (t)
/usr/local/share/dotnet (t)
/Users/sapelkinav/code/go/bin (t)
/usr/local/opt/go/libexec/bin (t)
/Applications/Emacs.app/Contents/MacOS/bin-x86_64-10_9 (t)
/Applications/Emacs.app/Contents/MacOS/bin-x86_64-10_9/emacsclient (25.2)
/Applications/Emacs.app/Contents/MacOS/libexec-x86_64-10_9 (t)
/Applications/Emacs.app/Contents/MacOS/libexec (libexec-x86_64-10_5)
/Applications/Emacs.app/Contents/MacOS/bin (bin-x86_64-10_5)
/Applications/Emacs.app/Contents/MacOS/bin/emacsclient (25.2)

systemctl edit command fails

Any kind of call to systemctl in an attempt to edit units fails. Example:

systemctl --user edit emacs

results in

"WITH-EDITOR:: -c: line 0: unexpected EOF while looking for matching `''
"WITH-EDITOR:: -c: line 1: syntax error: unexpected end of file
editor failed with error code 1.
Editing "~/.config/systemd/user/emacs.service.d/override.conf" canceled: temporary file is empty.

Here's how I load with-editor

(use-package with-editor
  :ensure t
  :init
  (progn
    (add-hook 'shell-mode-hook  'with-editor-export-editor)
    (add-hook 'eshell-mode-hook 'with-editor-export-editor))
  :config
  (shell-command-with-editor-mode))

"cannot determine a suitable Emacsclient" with nix-pkgs emacs

Thanks for with-editor and magit. Emacs installed with nix-env fails to find an emacsclient here. (I removed emacs-plus from homebrew but that didn't help.)

with-editor: /Users/simon/.emacs.d/elpa/with-editor-20181113.1845/with-editor.el
emacs: /nix/store/pyfdhlfcwpb6cvbbbjkp26hvp7rnkjkg-emacs-26.1/Applications/Emacs.app/Contents/MacOS/Emacs (26.1)
system:
  system-type: darwin
  system-configuration: x86_64-apple-darwin17.7.0
  system-configuration-options: --prefix=/nix/store/pyfdhlfcwpb6cvbbbjkp26hvp7rnkjkg-emacs-26.1 --with-modules --with-ns --disable-ns-self-contained CFLAGS=-DMAC_OS_X_VERSION_MAX_ALLOWED=101200
server:
  server-running-p: nil
  server-process: nil
  server-use-tcp: nil
  server-name: server
  server-socket-dir: /var/folders/r7/f9j9c2zd1k97v47cr84j_qvc0000gn/T//emacs501
    ERROR: not an accessible directory
  server-auth-dir: ~/.emacs.d/server/
    WARNING: not an accessible directory
with-editor-emacsclient-executable:
 value:   nil (nil)
 default: nil (nil)
 funcall: nil (nil)
path:
  $PATH: "/Users/simon/bin.local:/Users/simon/bin:/Users/simon/src/hledger/bin:/Users/simon/src/hledger/extra:/Users/simon/.local/bin:/Users/simon/.cabal/bin:/usr/local/bin:/usr/local/sbin:/opt/local/bin:/opt/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/Applications/splunk/bin:/Users/simon/src/PLAINTEXTACCOUNTING/beancount/bin"
  exec-path: (/usr/bin /bin /usr/sbin /sbin /nix/store/pyfdhlfcwpb6cvbbbjkp26hvp7rnkjkg-emacs-26.1/libexec/emacs/26.1/x86_64-apple-darwin17.7.0 /Users/simon/bin.local /Users/simon/bin /Users/simon/src/hledger/bin /Users/simon/src/hledger/extra /Users/simon/.local/bin /Users/simon/.cabal/bin /usr/local/bin /usr/local/sbin /opt/local/bin /opt/local/sbin /usr/bin /usr/sbin /bin /sbin /Applications/splunk/bin /Users/simon/src/PLAINTEXTACCOUNTING/beancount/bin)
  with-editor-emacsclient-path:
    /nix/store/pyfdhlfcwpb6cvbbbjkp26hvp7rnkjkg-emacs-26.1/Applications/Emacs.app/Contents/MacOS (t)
    /nix/store/pyfdhlfcwpb6cvbbbjkp26hvp7rnkjkg-emacs-26.1/libexec/emacs/26.1/x86_64-apple-darwin17.7.0 (t)
    /Users/simon/bin.local (t)
    /Users/simon/bin (t)
    /Users/simon/src/hledger/bin (t)
    /Users/simon/src/hledger/extra (nil)
    /Users/simon/.local/bin (t)
    /Users/simon/.cabal/bin (t)
    /usr/local/bin (t)
    /usr/local/sbin (t)
    /opt/local/bin (nil)
    /opt/local/sbin (nil)
    /usr/bin (t)
      /usr/bin/emacsclient (22.1)
    /usr/sbin (t)
    /bin (t)
    /sbin (t)
    /Applications/splunk/bin (nil)
    /Users/simon/src/PLAINTEXTACCOUNTING/beancount/bin (nil)

broken for local shells (more or less)

When using with-editor-export-editor for local shell-mode (ie, not TRAMP), typical use for $EDITOR does not work.

$ crontab -e
crontab: no crontab for peterhurley - using an empty one
crontab: editor or filename too long
crontab: "sh -c 'echo "WITH-EDITOR: $$ OPEN $0"; sleep 604800 & sleep=$!; trap "kill $sleep; exit 0" USR1; trap "kill $sleep; exit 1" USR2; wait $sleep'" exited with status 1
$ fc
"WITH-EDITOR:: -c: line 0: unexpected EOF while looking for matching `''
"WITH-EDITOR:: -c: line 1: syntax error: unexpected end of file
$ export EDITOR=emacsclient
$ crontab -e
crontab: no crontab for peterhurley - using an empty one
Waiting for Emacs...
crontab: no changes made to crontab
$ fc
Waiting for Emacs...
crontab -e
crontab: no crontab for peterhurley - using an empty one
Waiting for Emacs...
crontab: no changes made to crontab
$

TRAMP issue in Emacs 26

In Emacs 26, attempting to commit under TRAMP (e.g. via sudo method) results in

Debugger entered--Lisp error: (wrong-number-of-arguments (6 . 7) 5)
  tramp-make-tramp-file-name("sudo" #("root" 0 4 (tramp-default t)) "host" "/.git/COMMIT_EDITMSG" nil)
  with-editor-output-filter("WITH-EDITOR: 3484 OPEN /.git/COMMIT_EDITMSG\n")
  with-editor-process-filter(#<process git<1>> "WITH-EDITOR: 3484 OPEN /.git/COMMIT_EDITMSG\n" t)
  (lambda (proc str) (magit-process-filter proc str) (with-editor-process-filter proc str t))(#<process git<1>> "WITH-EDITOR: 3484 OPEN /.git/COMMIT_EDITMSG\n")

because the signature of tramp-make-tramp-file-name now accepts port at the previous position of localname:

(defun tramp-make-tramp-file-name
    (method user domain host port localname &optional hop)
  "Constructs a Tramp file name from METHOD, USER, HOST and LOCALNAME.
When not nil, optional DOMAIN, PORT and HOP are used."
  ...)

Please, adapt.

Have `with-editor-emacsclient-path` look in lib-src?

I often run Emacs directly out of a build directory, and it is especially in this situation that I need with-editor to be smartest about finding the right "emacsclient"!

In my build (I would assume this is the same for everyone?), the emacsclient is in ./lib-src, and not in ./src, where with-editor seems to be looking.

Thanks!

wrong-type-argument processp nil

I configure with-editor like this:

(use-package with-editor
  :ensure t
  :config
  (add-hook 'shell-mode-hook  'with-editor-export-editor)
  (add-hook 'term-mode-hook   'with-editor-export-editor)
  (add-hook 'eshell-mode-hook 'with-editor-export-editor)
  )

And configure fzf like this:

(use-package fzf
  :ensure t
  :bind (:map find-prefix
              ("f" . fzf)
              ("d" . fzf-directory))
  )

When I execute fzf command, it report error:

Debugger entered--Lisp error: (wrong-type-argument processp nil)
  process-filter(nil)
  with-editor-export-editor()
  run-hooks(change-major-mode-after-body-hook term-mode-hook)
  apply(run-hooks (change-major-mode-after-body-hook term-mode-hook))
  run-mode-hooks(term-mode-hook)
  term-mode()
  make-term("fzf" "fzf" nil "-x" "--color" "bw" "--margin" "1,0")
  apply(make-term "fzf" "fzf" nil ("-x" "--color" "bw" "--margin" "1,0"))
  fzf/start("/home/stardiviner/Code/learning/")
  fzf()
  funcall-interactively(fzf)
  call-interactively(fzf record nil)
  command-execute(fzf record)

minor error in TeXinfo manual (I think)

When describing 'with-editor-shell-command', the info file says "This command is like ‘async-shell-command’[...]", which is also what it says about 'with-editor-async-shell-command'. I think it should say "This command is like 'shell-command'". But I'm not entirely sure, so I wanted to check first.

It also goes on to say "This only has an effect if the shell command is run asynchronously, i.e. when the command ends with ‘&’." I would think this statement applies to 'with-editor-async-shell-command' rather than to 'with-editor-shell-command', but again, I'm not entirely sure.

Error: "WITH-EDITOR:: -c: line 0: unexpected EOF while looking for matching `''

I'm getting the following error in the *Async Shell Command* buffer with version ee39f23 of with-editor when runing (with-editor-async-shell-command "pass edit foobar") . (pass command is from https://www.passwordstore.org/).

"WITH-EDITOR:: -c: line 0: unexpected EOF while looking for matching `''
"WITH-EDITOR:: -c: line 1: syntax error: unexpected end of file
Password unchanged.

The following also appears in the *Messages* buffer.

#<process Shell>
EDITOR=sh\ -c\ \'echo\ \"WITH-EDITOR\:\ \$\$\ OPEN\ \$0\"\;\ sleep\ 604800\ \&\ sleep\=\$\!\;\ trap\ \"kill\ \$sleep\;\ exit\ 0\"\ USR1\;\ trap\ \"kill\ \$sleep\;\ exit\ 1\"\ USR2\;\ wait\ \$sleep\' pass edit foobar: exited abnormally with code 1.

If I checkout the commit before 99d3278, the same command works.

I am running GNU Emacs 26.0.60 on macOS.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.