4

I am running emacs v26 daemon on the background and using a single terminal. Usually I open files using emacsclient -qt and close them using C-x C-s and C-x C-c to get back to terminal run the script and afterwards re-open another file.


I wanted to make this operation faster where when I run emacsclient -qt -e '(progn (find-file "file.py"))' seems like it opens the files much faster than emacsclient -qt file.py (this may lag to show previous buffers for a second).

But now, when I run emacsclient -qt -e '(progn (find-file "file.py"))' I keep seeing When done with this frame, type C-x 5 0 message in the minibuffer.

=> How can I suppress this warning message? and also safe to open files this way?


Not perfect but the script I come up with:

#!/bin/bash

open_emacs() {
    FILE=$1
    if [[ -d $FILE ]]; then
        echo "Folder path is provided, please provide a file"
        return
    fi

    if [ ! -f "$FILE" ]; then
        echo "$FILE does not exist."
        return
    fi

    if [ "$#" -ge 1 ]; then
        emacsclient -qt -e '(progn (find-file "'$FILE'"))'
        if [ $? -eq 0 ]; then
            true
        else
            emacsclient -qt -e '(progn (find-file "'$FILE'"))'
        fi
    else
        echo "## Please provide a file"
    fi
}

open_emacs file.py
Drew
  • 75,699
  • 9
  • 109
  • 225
alper
  • 1,238
  • 11
  • 30

1 Answers1

4

This is possible starting from Emacs 28, which provides the user option server-client-instructions for this purpose.

(setq server-client-instructions nil)
phils
  • 48,657
  • 3
  • 76
  • 115
  • I wish there was a hack to make it work for emacs26.3 too :-( – alper Mar 21 '21 at 15:02
  • You can easily backport the change from emacs 28 to emasc 26: it's a minor change, introducing the variable that @phils describes and then using it in two places in `server-execute` to suppress the `message` calls if the variable is nil. Actually, I checked emacs 27.1, but 26 should be similar. – NickD Mar 21 '21 at 18:24
  • For anyone wanting to do that: https://lists.gnu.org/archive/html/emacs-diffs/2020-12/msg00151.html – phils Mar 22 '21 at 21:38