From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Rusi Newsgroups: gmane.emacs.help Subject: Re: resending... desktop files not working for recent ubuntu? Date: Mon, 13 Jun 2016 18:54:29 -0700 (PDT) Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1465869328 32028 80.91.229.3 (14 Jun 2016 01:55:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 14 Jun 2016 01:55:28 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jun 14 03:55:27 2016 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bCdZf-0005Yn-G7 for geh-help-gnu-emacs@m.gmane.org; Tue, 14 Jun 2016 03:55:27 +0200 Original-Received: from localhost ([::1]:60478 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCdZe-0001YS-Le for geh-help-gnu-emacs@m.gmane.org; Mon, 13 Jun 2016 21:55:26 -0400 X-Received: by 10.157.54.181 with SMTP id h50mr14553557otc.4.1465869270107; Mon, 13 Jun 2016 18:54:30 -0700 (PDT) X-Received: by 10.36.57.131 with SMTP id l125mr328541ita.7.1465869269979; Mon, 13 Jun 2016 18:54:29 -0700 (PDT) Original-Path: usenet.stanford.edu!v48no1653326qgd.0!news-out.google.com!v8ni382qgv.0!nntp.google.com!31no6433qgh.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=219.91.210.203; posting-account=mBpa7woAAAAGLEWUUKpmbxm-Quu5D8ui Original-NNTP-Posting-Host: 219.91.210.203 User-Agent: G2/1.0 Injection-Date: Tue, 14 Jun 2016 01:54:30 +0000 Original-Xref: usenet.stanford.edu gnu.emacs.help:218127 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:110436 Archived-At: On Tuesday, May 31, 2016 at 10:51:57 AM UTC+5:30, Alexis wrote: > Rustom Mody writes: > > > Apologies for second copy 1st doesnt seem to have appeared > > > > --------------------------------------------- I have this > > emacs.desktop file put in ~/.local/share/applications > > > > --------------- [Desktop Entry] Name=EmacsClient > > GenericName=Text Editor Comment=Edit text > > MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++; > > > > Exec=emacsclient -n -a emacs %F Icon=python Type=Application > > Terminal=false Categories=Development;TextEditor; > > StartupWMClass=Emacs > > > > --------------- Currently this laptop is on ubuntu 16.4 (xenial) > > -- vanilla unity desktop It used to work ok in earlier ubuntus > > Now on 16.4 it shows 2 emacs icons when editing a file via > > emacsclient Clicking the second icon shows no effect After about > > 10 seconds it disappears > > > > Dont know when it stopped working because frankly I am not much > > of a nautilus -> click -> emacsclient type of user > > > > Current generation -- my students -- however default to this > > kind of usage And so they default to one or both of - gedit by > > default - dozens of emacses open for each file they clicked > > Shouldn't you specify '' (i.e. the empty string) as the -a > argument in the Exec option? From the man page for emacsclient(1): > > -a, --alternate-editor=EDITOR > > if the Emacs server is not running, run the specified editor > instead. This can also be specified via the > `ALTERNATE_EDITOR' environment variable. If the value of > EDITOR is the empty string, run `emacs --daemon' to start > Emacs in daemon mode, and try to connect to it. > > > Alexis. Made some small progress with this following suggestions: http://stackoverflow.com/questions/1167484/how-to-gracefully-shutdown-emacs-daemon This needs 1. emacs started with --daemon 2. emacs.desktop as earlier described 3. Having this in the init: (defun shutdown-emacs-server () (interactive) (when (not (eq window-system 'x)) (message "Initializing x windows system.") (x-initialize-window-system) (when (not x-display-name) (setq x-display-name (getenv "DISPLAY"))) (select-frame (make-frame-on-display x-display-name '((window-system . x)))) ) (let ((last-nonmenu-event nil)(window-system "x"))(save-buffers-kill-emacs))) 4. And having this systemd service in ~/.local/share/systemd/user/ [Unit] Description=Emacs: the extensible, self-documenting text editor [Service] Type=forking ExecStart=/usr/bin/emacs --daemon ExecStop=/usr/bin/emacsclient --eval '(shutdown-emacs-server)' Restart=no TimeoutStartSec=12 [Install] WantedBy=default.target ============================== Basically the idea is that a dialog should be popped up for saving buffers when the server is terminated even if no frame was active This is currently unreliable - ie sometimes it pops up and sometimes not thereby losing unsaved work Is there some more official way of using emacs in client-server mode?