all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Question on frame title
@ 2015-10-15 15:26 Benny Sum
  2015-10-15 16:26 ` Marcin Borkowski
       [not found] ` <mailman.391.1444926481.7904.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 11+ messages in thread
From: Benny Sum @ 2015-10-15 15:26 UTC (permalink / raw)
  To: help-gnu-emacs

I try to run shell-command to retrieve some information on the file and put it in the title frame.  But I got some strange behavior:

(setq frame-title-format
 (list (format "%s" (shell-command-to-string(concat "ls -1 " " %b ")))))

But it says ls: cannot access filename: No such file or directory on the title frame.  

It seems the filename is correct, but not sure why cannot access it.  Is it due to the white space returned from the %b?  

Anyone has a example code to run a shell-command on %b in frame-title-format?



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Question on frame title
  2015-10-15 15:26 Question on frame title Benny Sum
@ 2015-10-15 16:26 ` Marcin Borkowski
       [not found] ` <mailman.391.1444926481.7904.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 11+ messages in thread
From: Marcin Borkowski @ 2015-10-15 16:26 UTC (permalink / raw)
  To: help-gnu-emacs


On 2015-10-15, at 17:26, Benny Sum <benny.sum@gmail.com> wrote:

> I try to run shell-command to retrieve some information on the file and put it in the title frame.  But I got some strange behavior:
>
> (setq frame-title-format
>  (list (format "%s" (shell-command-to-string(concat "ls -1 " " %b ")))))
>
> But it says ls: cannot access filename: No such file or directory on the title frame.  
>
> It seems the filename is correct, but not sure why cannot access it.  Is it due to the white space returned from the %b?  
>
> Anyone has a example code to run a shell-command on %b in frame-title-format?

Do I get it correctly that "ls" gets a literal "%b" and has no idea what
to do with it?

What do you want to achieve that (setq frame-title-format "%f") doesn't do?

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Question on frame title
       [not found] ` <mailman.391.1444926481.7904.help-gnu-emacs@gnu.org>
@ 2015-10-15 16:43   ` Benny Sum
  2015-10-15 17:21     ` Marcin Borkowski
                       ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Benny Sum @ 2015-10-15 16:43 UTC (permalink / raw)
  To: help-gnu-emacs

ls is just as an example.  I want to do unix command to get the revision control of a file.  Ultimately, here is what I want to do:

Say unix command:
> info_data filename
-> revision number of the file from the database

(setq frame-title-format
 (list (format "%s" (shell-command-to-string(concat "info-data " " %b "))))) 

So, I just use ls -1 as an example of unix command.

But the problem is that it seems I don't have filename correctly.  It says I can't access the filename.  Did you try the command and see if that works for you?


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Question on frame title
  2015-10-15 16:43   ` Benny Sum
@ 2015-10-15 17:21     ` Marcin Borkowski
  2015-10-15 17:30     ` Random832
       [not found]     ` <mailman.402.1444930342.7904.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 11+ messages in thread
From: Marcin Borkowski @ 2015-10-15 17:21 UTC (permalink / raw)
  To: help-gnu-emacs


On 2015-10-15, at 18:43, Benny Sum <benny.sum@gmail.com> wrote:

> ls is just as an example.  I want to do unix command to get the revision control of a file.  Ultimately, here is what I want to do:
>
> Say unix command:
>> info_data filename
> -> revision number of the file from the database
>
> (setq frame-title-format
>  (list (format "%s" (shell-command-to-string(concat "info-data " " %b "))))) 
>
> So, I just use ls -1 as an example of unix command.
>
> But the problem is that it seems I don't have filename correctly.  It says I can't access the filename.  Did you try the command and see if that works for you?

Yes I did - in fact, it was as simple as putting the point in the right
place in your email and pressing C-x C-e;-).

One problem is that you probably want %f, not %b.

A bigger problem there *might* be with your approach is the timing:
apparently, you want the frame title to be updated whenever you switch
buffers, right?  This probably means that you want (:eval ...).  Another
approach could be to use a symbol as frame-title-format (like in (setq
frame-title-format 'foo) and make the variable foo contain what you want
to have displayed.

If there were a `buffer-switch-hook', you could then update it there.
It seems tere is no such thing, but yu could e.g. advise
switch-to-buffer (or maybe some other function).

Hth,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Question on frame title
  2015-10-15 16:43   ` Benny Sum
  2015-10-15 17:21     ` Marcin Borkowski
@ 2015-10-15 17:30     ` Random832
  2015-10-15 17:49       ` Random832
       [not found]       ` <mailman.405.1444931478.7904.help-gnu-emacs@gnu.org>
       [not found]     ` <mailman.402.1444930342.7904.help-gnu-emacs@gnu.org>
  2 siblings, 2 replies; 11+ messages in thread
From: Random832 @ 2015-10-15 17:30 UTC (permalink / raw)
  To: help-gnu-emacs

Benny Sum <benny.sum@gmail.com> writes:

> ls is just as an example.  I want to do unix command to get the
> revision control of a file.  Ultimately, here is what I want to do:
>
> Say unix command:
>> info_data filename
> -> revision number of the file from the database
>
> (setq frame-title-format
>  (list (format "%s" (shell-command-to-string(concat "info-data " " %b "))))) 
>
> So, I just use ls -1 as an example of unix command.
>
> But the problem is that it seems I don't have filename correctly.  It
> says I can't access the filename.  Did you try the command and see if
> that works for you?

I think you can do this with an :eval like this:

I included the default frame-title-format and put your info_data command
after it, since it won't work on non-files.

(setq frame-title-format
      '(""
        (multiple-frames "%b" ("" invocation-name "@" system-name))
        " "
        (:eval (when (stringp (buffer-file-name))
                 (shell-command-to-string
                   (concat "info_data "
                           (shell-quote-argument (buffer-file-name))))))))

This will re-execute the info-data command every time you switch
buffers. If the command is expensive, you may want to store the value in
a buffer-local variable.




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Question on frame title
  2015-10-15 17:30     ` Random832
@ 2015-10-15 17:49       ` Random832
       [not found]       ` <mailman.405.1444931478.7904.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 11+ messages in thread
From: Random832 @ 2015-10-15 17:49 UTC (permalink / raw)
  To: help-gnu-emacs

Random832 <random832@fastmail.com> writes:
> This will re-execute the info-data command every time you switch
> buffers. If the command is expensive, you may want to store the value in
> a buffer-local variable.

Actually it turns out it evaluates quite a bit more often than that. I
can't quite find the rhyme or reason to precisely when it gets evaluated.

Fun little test script:

(setq test-index 0)
(setq frame-title-format
      '(:eval (format "frame-title-format evaluated %d times "
                      (setq test-index (1+ test-index)))))

It gets evaluated when:

- Changing buffers
- Changing windows
- (Yes, that's even when it's the same window, or the same buffer)
- (Even the minibuffer. Sometimes.)
- Activating the mark
- Deactivating the mark
- Clicking the mouse anywhere (and again on release)

Probably best to try to get the value in a buffer-local variable.




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Question on frame title
       [not found]     ` <mailman.402.1444930342.7904.help-gnu-emacs@gnu.org>
@ 2015-10-15 23:08       ` Benny Sum
  0 siblings, 0 replies; 11+ messages in thread
From: Benny Sum @ 2015-10-15 23:08 UTC (permalink / raw)
  To: help-gnu-emacs

It seems working on emacs, but not xemacs.  


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Question on frame title
       [not found]       ` <mailman.405.1444931478.7904.help-gnu-emacs@gnu.org>
@ 2015-10-16 11:05         ` Benny Sum
  2015-10-16 13:35           ` Random832
       [not found]           ` <mailman.455.1445002561.7904.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 11+ messages in thread
From: Benny Sum @ 2015-10-16 11:05 UTC (permalink / raw)
  To: help-gnu-emacs

On Thursday, October 15, 2015 at 1:51:21 PM UTC-4, Random832 wrote:
> Random832 <random832@fastmail.com> writes:
> > This will re-execute the info-data command every time you switch
> > buffers. If the command is expensive, you may want to store the value in
> > a buffer-local variable.
> 
> Actually it turns out it evaluates quite a bit more often than that. I
> can't quite find the rhyme or reason to precisely when it gets evaluated.
> 
> Fun little test script:
> 
> (setq test-index 0)
> (setq frame-title-format
>       '(:eval (format "frame-title-format evaluated %d times "
>                       (setq test-index (1+ test-index)))))
> 
> It gets evaluated when:
> 
> - Changing buffers
> - Changing windows
> - (Yes, that's even when it's the same window, or the same buffer)
> - (Even the minibuffer. Sometimes.)
> - Activating the mark
> - Deactivating the mark
> - Clicking the mouse anywhere (and again on release)
> 
> Probably best to try to get the value in a buffer-local variable.

Yes, it is very slow.  How do I get the value in a buffer-local variable?


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Question on frame title
  2015-10-16 11:05         ` Benny Sum
@ 2015-10-16 13:35           ` Random832
       [not found]           ` <mailman.455.1445002561.7904.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 11+ messages in thread
From: Random832 @ 2015-10-16 13:35 UTC (permalink / raw)
  To: help-gnu-emacs

Benny Sum <benny.sum@gmail.com> writes:
> Yes, it is very slow.  How do I get the value in a buffer-local
> variable?

This hasn't been tested at all, but maybe something like this:

(defvar buffer-frame-title-suffix "")
(make-variable-buffer-local 'buffer-frame-title-suffix)
(setq frame-title-format '("%b" buffer-frame-title-suffix))

(defun do-run-info_data ()
  (setq buffer-frame-title-suffix
	(if (stringp (buffer-file-name))
	    (concat " "
		    (shell-command-to-string
		     (concat "info_data "
			     (shell-quote-argument (buffer-file-name)))))
	    "")))

(add-hook 'find-file-hook 'do-run-info_data)

Not sure if any of this needs to change for xemacs.




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Question on frame title
       [not found]           ` <mailman.455.1445002561.7904.help-gnu-emacs@gnu.org>
@ 2015-10-16 18:15             ` Benny Sum
  2015-10-16 19:14               ` Benny Sum
  0 siblings, 1 reply; 11+ messages in thread
From: Benny Sum @ 2015-10-16 18:15 UTC (permalink / raw)
  To: help-gnu-emacs

I got this on the title bar on emacs:
sh: pkginfo: command not found 


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Question on frame title
  2015-10-16 18:15             ` Benny Sum
@ 2015-10-16 19:14               ` Benny Sum
  0 siblings, 0 replies; 11+ messages in thread
From: Benny Sum @ 2015-10-16 19:14 UTC (permalink / raw)
  To: help-gnu-emacs

On Friday, October 16, 2015 at 2:15:50 PM UTC-4, Benny Sum wrote:
> I got this on the title bar on emacs:
> sh: pkginfo: command not found

Actually I found the problem and work perfectly in the emacs now.  Thanks!


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2015-10-16 19:14 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-15 15:26 Question on frame title Benny Sum
2015-10-15 16:26 ` Marcin Borkowski
     [not found] ` <mailman.391.1444926481.7904.help-gnu-emacs@gnu.org>
2015-10-15 16:43   ` Benny Sum
2015-10-15 17:21     ` Marcin Borkowski
2015-10-15 17:30     ` Random832
2015-10-15 17:49       ` Random832
     [not found]       ` <mailman.405.1444931478.7904.help-gnu-emacs@gnu.org>
2015-10-16 11:05         ` Benny Sum
2015-10-16 13:35           ` Random832
     [not found]           ` <mailman.455.1445002561.7904.help-gnu-emacs@gnu.org>
2015-10-16 18:15             ` Benny Sum
2015-10-16 19:14               ` Benny Sum
     [not found]     ` <mailman.402.1444930342.7904.help-gnu-emacs@gnu.org>
2015-10-15 23:08       ` Benny Sum

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.