* Re: Why emacsclient -e "(current-word nil t)" does not print ? [not found] <mailman.2874.1248150680.2239.help-gnu-emacs@gnu.org> @ 2009-07-21 6:52 ` Anselm Helbig 2009-07-21 7:33 ` Pascal J. Bourguignon 1 sibling, 0 replies; 16+ messages in thread From: Anselm Helbig @ 2009-07-21 6:52 UTC (permalink / raw) To: help-gnu-emacs Hi! > I'm doing a piece of code. What needs get the output of > emacsclient -e "(current-word nil t)" > > and send it to an external command. But there was NO output. I don't > understand. > > Could someone explain that? Try this command: emacsclient -e "(current-buffer)" And then look at the contents of the buffer, there you will find the answer - but not much more. 8-) HTH, Anselm -- Anselm Helbig mailto:anselm.helbig+news2009@googlemail.com ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Why emacsclient -e "(current-word nil t)" does not print ? [not found] <mailman.2874.1248150680.2239.help-gnu-emacs@gnu.org> 2009-07-21 6:52 ` Why emacsclient -e "(current-word nil t)" does not print ? Anselm Helbig @ 2009-07-21 7:33 ` Pascal J. Bourguignon 2009-07-21 11:23 ` Wang Lei [not found] ` <mailman.2902.1248175432.2239.help-gnu-emacs@gnu.org> 1 sibling, 2 replies; 16+ messages in thread From: Pascal J. Bourguignon @ 2009-07-21 7:33 UTC (permalink / raw) To: help-gnu-emacs Wang Lei <wanglei.198112@gmail.com> writes: > Hi, all. > > I'm doing a piece of code. What needs get the output of > emacsclient -e "(current-word nil t)" > > and send it to an external command. But there was NO output. I don't > understand. > > Could someone explain that? That's because -e prints the result only when it's not nil. Try: emacsclient -e "(or (current-word nil t) :nil)" -- __Pascal Bourguignon__ ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Why emacsclient -e "(current-word nil t)" does not print ? 2009-07-21 7:33 ` Pascal J. Bourguignon @ 2009-07-21 11:23 ` Wang Lei [not found] ` <mailman.2902.1248175432.2239.help-gnu-emacs@gnu.org> 1 sibling, 0 replies; 16+ messages in thread From: Wang Lei @ 2009-07-21 11:23 UTC (permalink / raw) To: Pascal J. Bourguignon; +Cc: help-gnu-emacs On 7/21/09, Pascal J. Bourguignon <pjb@informatimago.com> wrote: > Wang Lei <wanglei.198112@gmail.com> writes: > >> Hi, all. >> >> I'm doing a piece of code. What needs get the output of >> emacsclient -e "(current-word nil t)" >> >> and send it to an external command. But there was NO output. I don't >> understand. >> >> Could someone explain that? > > That's because -e prints the result only when it's not nil. > Try: > > emacsclient -e "(or (current-word nil t) :nil)" > Actually, what am i interested is the "current word", in this line, it's should print 't'. In emacs it does print 't'. But with emacsclient, nothing. Is this normal? > > -- > __Pascal Bourguignon__ > -- Regards Lei ^ permalink raw reply [flat|nested] 16+ messages in thread
[parent not found: <mailman.2902.1248175432.2239.help-gnu-emacs@gnu.org>]
* Re: Why emacsclient -e "(current-word nil t)" does not print ? [not found] ` <mailman.2902.1248175432.2239.help-gnu-emacs@gnu.org> @ 2009-07-21 11:43 ` Anselm Helbig 2009-07-21 11:52 ` Pascal J. Bourguignon 2009-07-21 11:47 ` Pascal J. Bourguignon [not found] ` <7cskgqjm0s.fsf@pbourguignon.informatimago.com> 2 siblings, 1 reply; 16+ messages in thread From: Anselm Helbig @ 2009-07-21 11:43 UTC (permalink / raw) To: help-gnu-emacs At Tue, 21 Jul 2009 19:23:44 +0800, Wang Lei <wanglei.198112@gmail.com> wrote: > > On 7/21/09, Pascal J. Bourguignon <pjb@informatimago.com> wrote: > > Wang Lei <wanglei.198112@gmail.com> writes: > > > >> Hi, all. > >> > >> I'm doing a piece of code. What needs get the output of > >> emacsclient -e "(current-word nil t)" > >> > >> and send it to an external command. But there was NO output. I don't > >> understand. > >> > >> Could someone explain that? > > > > That's because -e prints the result only when it's not nil. > > Try: > > > > emacsclient -e "(or (current-word nil t) :nil)" > > > Actually, what am i interested is the "current word", in this line, > it's should print 't'. In emacs it does print 't'. But with > emacsclient, nothing. When executing a command with emacsclient, you're obviously in the *server* buffer. It's empty, so current-word doesn't output anything. -- Anselm Helbig mailto:anselm.helbig+news2009@googlemail.com ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Why emacsclient -e "(current-word nil t)" does not print ? 2009-07-21 11:43 ` Anselm Helbig @ 2009-07-21 11:52 ` Pascal J. Bourguignon 2009-07-21 12:12 ` Miles Bader 0 siblings, 1 reply; 16+ messages in thread From: Pascal J. Bourguignon @ 2009-07-21 11:52 UTC (permalink / raw) To: help-gnu-emacs Anselm Helbig <anselm.helbig+news2009@googlemail.com> writes: > At Tue, 21 Jul 2009 19:23:44 +0800, > Wang Lei <wanglei.198112@gmail.com> wrote: >> >> On 7/21/09, Pascal J. Bourguignon <pjb@informatimago.com> wrote: >> > Wang Lei <wanglei.198112@gmail.com> writes: >> > >> >> Hi, all. >> >> >> >> I'm doing a piece of code. What needs get the output of >> >> emacsclient -e "(current-word nil t)" >> >> >> >> and send it to an external command. But there was NO output. I don't >> >> understand. >> >> >> >> Could someone explain that? >> > >> > That's because -e prints the result only when it's not nil. >> > Try: >> > >> > emacsclient -e "(or (current-word nil t) :nil)" >> > >> Actually, what am i interested is the "current word", in this line, >> it's should print 't'. In emacs it does print 't'. But with >> emacsclient, nothing. > > When executing a command with emacsclient, you're obviously in the > *server* buffer. It's empty, so current-word doesn't output anything. Perhaps that depends on the version of emacs, because with 22.2.1 I get the current word: $ emacsclient -e '(current-word)' "Halley" -- __Pascal Bourguignon__ ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Why emacsclient -e "(current-word nil t)" does not print ? 2009-07-21 11:52 ` Pascal J. Bourguignon @ 2009-07-21 12:12 ` Miles Bader 0 siblings, 0 replies; 16+ messages in thread From: Miles Bader @ 2009-07-21 12:12 UTC (permalink / raw) To: help-gnu-emacs pjb@informatimago.com (Pascal J. Bourguignon) writes: >> When executing a command with emacsclient, you're obviously in the >> *server* buffer. It's empty, so current-word doesn't output anything. > > Perhaps that depends on the version of emacs, because with 22.2.1 I > get the current word: > > $ emacsclient -e '(current-word)' > "Halley" It's easy to see, of course: $ emacsclient -e '(buffer-name)' " *server*" One can use `with-current-buffer' to specify what buffer to use, of course: $ emacsclient -e '(with-current-buffer "*scratch*" (current-word))' "oink" ("oink" happens to be what my cursor was on in the *scratch* buffer) -Miles -- Bore, n. A person who talks when you wish him to listen. ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Why emacsclient -e "(current-word nil t)" does not print ? [not found] ` <mailman.2902.1248175432.2239.help-gnu-emacs@gnu.org> 2009-07-21 11:43 ` Anselm Helbig @ 2009-07-21 11:47 ` Pascal J. Bourguignon 2009-07-21 13:01 ` Wang Lei [not found] ` <7cskgqjm0s.fsf@pbourguignon.informatimago.com> 2 siblings, 1 reply; 16+ messages in thread From: Pascal J. Bourguignon @ 2009-07-21 11:47 UTC (permalink / raw) To: help-gnu-emacs Wang Lei <wanglei.198112@gmail.com> writes: > On 7/21/09, Pascal J. Bourguignon <pjb@informatimago.com> wrote: >> Wang Lei <wanglei.198112@gmail.com> writes: >> >>> Hi, all. >>> >>> I'm doing a piece of code. What needs get the output of >>> emacsclient -e "(current-word nil t)" >>> >>> and send it to an external command. But there was NO output. I don't >>> understand. >>> >>> Could someone explain that? >> >> That's because -e prints the result only when it's not nil. >> Try: >> >> emacsclient -e "(or (current-word nil t) :nil)" >> > Actually, what am i interested is the "current word", in this line, > it's should print 't'. In emacs it does print 't'. But with > emacsclient, nothing. > > Is this normal? Perhaps. I cannot parse your sentence starting with "Actually". Did you read what I wrote above? I won't repeat it. Otherwise, if you use emacsclient from within emacs (eg. from the M-x shell) you will obviously get different results. Once you hit RET, emacs changes the position of the cursor, so the current word is not the same as when you hit RET, and current-word will return nil. And I don't see how current-word could return t. At best, it could return "t", if you had the cursor on a single letter 't'. -- __Pascal Bourguignon__ ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Why emacsclient -e "(current-word nil t)" does not print ? 2009-07-21 11:47 ` Pascal J. Bourguignon @ 2009-07-21 13:01 ` Wang Lei 0 siblings, 0 replies; 16+ messages in thread From: Wang Lei @ 2009-07-21 13:01 UTC (permalink / raw) To: Pascal J. Bourguignon; +Cc: help-gnu-emacs On 7/21/09, Pascal J. Bourguignon <pjb@informatimago.com> wrote: > Wang Lei <wanglei.198112@gmail.com> writes: > >> On 7/21/09, Pascal J. Bourguignon <pjb@informatimago.com> wrote: >>> Wang Lei <wanglei.198112@gmail.com> writes: >>> >>>> Hi, all. >>>> >>>> I'm doing a piece of code. What needs get the output of >>>> emacsclient -e "(current-word nil t)" >>>> >>>> and send it to an external command. But there was NO output. I don't >>>> understand. >>>> >>>> Could someone explain that? >>> >>> That's because -e prints the result only when it's not nil. >>> Try: >>> >>> emacsclient -e "(or (current-word nil t) :nil)" >>> >> Actually, what am i interested is the "current word", in this line, >> it's should print 't'. In emacs it does print 't'. But with >> emacsclient, nothing. >> >> Is this normal? > > Perhaps. I cannot parse your sentence starting with "Actually". > I mean "in fact", sorry for my poor english. ;) > Did you read what I wrote above? I won't repeat it. > Yes, I read and tried. It return :nil. > > > Otherwise, if you use emacsclient from within emacs (eg. from the M-x > shell) you will obviously get different results. Once you hit RET, > emacs changes the position of the cursor, so the current word is not > the same as when you hit RET, and current-word will return nil. > Yes. Maybe this is the reason, or maybe as Miles Bader said, it is in the *server* buffer and it is empty. Anyway, it proves what i have thought is wrong. > And I don't see how current-word could return t. At best, it could > return "t", if you had the cursor on a single letter 't'. > I meaned, in emacs C-x C-e, it returns "t". > > -- > __Pascal Bourguignon__ > Thanks for all your helps and patience! -- Regards Lei ^ permalink raw reply [flat|nested] 16+ messages in thread
[parent not found: <7cskgqjm0s.fsf@pbourguignon.informatimago.com>]
[parent not found: <mailman.2906.1248181279.2239.help-gnu-emacs@gnu.org>]
* Re: Why emacsclient -e "(current-word nil t)" does not print ? [not found] ` <mailman.2906.1248181279.2239.help-gnu-emacs@gnu.org> @ 2009-07-21 13:35 ` Pascal J. Bourguignon 2009-07-21 14:56 ` Wang Lei [not found] ` <7ck522jh0n.fsf@pbourguignon.informatimago.com> 1 sibling, 1 reply; 16+ messages in thread From: Pascal J. Bourguignon @ 2009-07-21 13:35 UTC (permalink / raw) To: help-gnu-emacs Wang Lei <wanglei.198112@gmail.com> writes: > On 7/21/09, Pascal J. Bourguignon <pjb@informatimago.com> wrote: >> Wang Lei <wanglei.198112@gmail.com> writes: >> >>> On 7/21/09, Pascal J. Bourguignon <pjb@informatimago.com> wrote: >>>> Wang Lei <wanglei.198112@gmail.com> writes: >>>> >>>>> Hi, all. >>>>> >>>>> I'm doing a piece of code. What needs get the output of >>>>> emacsclient -e "(current-word nil t)" >>>>> >>>>> and send it to an external command. But there was NO output. I don't >>>>> understand. >>>>> >>>>> Could someone explain that? >>>> >>>> That's because -e prints the result only when it's not nil. >>>> Try: >>>> >>>> emacsclient -e "(or (current-word nil t) :nil)" >>>> >>> Actually, what am i interested is the "current word", in this line, >>> it's should print 't'. In emacs it does print 't'. But with >>> emacsclient, nothing. >>> >>> Is this normal? >> >> Perhaps. I cannot parse your sentence starting with "Actually". >> > I mean "in fact", sorry for my poor english. ;) Yes, I understand the meaning of the word "Actually", but it's the whole sentence that I don't understand: Actually, what am i interested is the "current word", in this line, it's should print 't'. What is the "it" that should print 't'? "current word" is two words, "current" and "word"... Which of those two words are you interested in? The current word, or the word "current", or the word "word"? Or do you mean that "this line" refers to another line? >> Did you read what I wrote above? I won't repeat it. >> > Yes, I read and tried. It return :nil. So this shows that there is no current word, since current-word returns nil, which my expression explicitely substitute with :nil. >> Otherwise, if you use emacsclient from within emacs (eg. from the M-x >> shell) you will obviously get different results. Once you hit RET, >> emacs changes the position of the cursor, so the current word is not >> the same as when you hit RET, and current-word will return nil. >> > Yes. Maybe this is the reason, or maybe as Miles Bader said, it is in > the *server* buffer and it is empty. > > Anyway, it proves what i have thought is wrong. I can confirm that with my version of emacs, I get the current buffer and the current word: $ emacsclient -e '(list emacs-version (buffer-name) (current-word))' ("22.2.1" "Main.cc" "FilterFunction") >> And I don't see how current-word could return t. At best, it could >> return "t", if you had the cursor on a single letter 't'. >> > I meant, in emacs C-x C-e, it returns "t". With my emacs, On a line alone, (current-word) C-x C-e shows «"current-word"» in the mini buffer. On a line alone, (current-word) SPC t C-b C-x C-e shows «"t"» in the mini buffer. On a line alone, (current-word) SPC SPC t C-b C-b C-x C-e shows «"current-word"» in the mini buffer. -- __Pascal Bourguignon__ ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Why emacsclient -e "(current-word nil t)" does not print ? 2009-07-21 13:35 ` Pascal J. Bourguignon @ 2009-07-21 14:56 ` Wang Lei 0 siblings, 0 replies; 16+ messages in thread From: Wang Lei @ 2009-07-21 14:56 UTC (permalink / raw) To: Pascal J. Bourguignon; +Cc: help-gnu-emacs >What is the "it" that should print 't'? In my (current-word nil t) C-x C-e shows "t" in minibuffer. This "it" means this expression "(current-word nil t)". >$ emacsclient -e '(list emacs-version (buffer-name) (current-word))' >("22.2.1" "Main.cc" "FilterFunction") Mine. In urxvt and emacs shell mode: $emacsclient -e '(list emacs-version (buffer-name) (current-word))' ("23.1.50.1" " *server*" nil) It looks like the output really depends on the version. > Anyway, it proves what i have thought is wrong. Here, I wanted to say I have tried to write a external program, that gets the emacs' current word with emacsclient and send it to sdcv to search. This is part of the whole function, the rest is to get it from selection or prompt for. But now, it looks like i can not integrate the emacs-part. On 7/21/09, Pascal J. Bourguignon <pjb@informatimago.com> wrote: > Wang Lei <wanglei.198112@gmail.com> writes: > >> On 7/21/09, Pascal J. Bourguignon <pjb@informatimago.com> wrote: >>> Wang Lei <wanglei.198112@gmail.com> writes: >>> >>>> On 7/21/09, Pascal J. Bourguignon <pjb@informatimago.com> wrote: >>>>> Wang Lei <wanglei.198112@gmail.com> writes: >>>>> >>>>>> Hi, all. >>>>>> >>>>>> I'm doing a piece of code. What needs get the output of >>>>>> emacsclient -e "(current-word nil t)" >>>>>> >>>>>> and send it to an external command. But there was NO output. I don't >>>>>> understand. >>>>>> >>>>>> Could someone explain that? >>>>> >>>>> That's because -e prints the result only when it's not nil. >>>>> Try: >>>>> >>>>> emacsclient -e "(or (current-word nil t) :nil)" >>>>> >>>> Actually, what am i interested is the "current word", in this line, >>>> it's should print 't'. In emacs it does print 't'. But with >>>> emacsclient, nothing. >>>> >>>> Is this normal? >>> >>> Perhaps. I cannot parse your sentence starting with "Actually". >>> >> I mean "in fact", sorry for my poor english. ;) > > Yes, I understand the meaning of the word "Actually", but it's the > whole sentence that I don't understand: > > Actually, what am i interested is the "current word", in this > line, it's should print 't'. > > What is the "it" that should print 't'? > > "current word" is two words, "current" and "word"... Which of those > two words are you interested in? The current word, or the word > "current", or the word "word"? Or do you mean that "this line" refers > to another line? > > > >>> Did you read what I wrote above? I won't repeat it. >>> >> Yes, I read and tried. It return :nil. > > So this shows that there is no current word, since current-word > returns nil, which my expression explicitely substitute with :nil. > > >>> Otherwise, if you use emacsclient from within emacs (eg. from the M-x >>> shell) you will obviously get different results. Once you hit RET, >>> emacs changes the position of the cursor, so the current word is not >>> the same as when you hit RET, and current-word will return nil. >>> >> Yes. Maybe this is the reason, or maybe as Miles Bader said, it is in >> the *server* buffer and it is empty. >> >> Anyway, it proves what i have thought is wrong. > > I can confirm that with my version of emacs, I get the current buffer > and the current word: > > $ emacsclient -e '(list emacs-version (buffer-name) (current-word))' > ("22.2.1" "Main.cc" "FilterFunction") > > >>> And I don't see how current-word could return t. At best, it could >>> return "t", if you had the cursor on a single letter 't'. >>> >> I meant, in emacs C-x C-e, it returns "t". > > With my emacs, > > On a line alone, (current-word) C-x C-e shows «"current-word"» in the mini > buffer. > > On a line alone, (current-word) SPC t C-b C-x C-e shows «"t"» in the mini > buffer. > > On a line alone, (current-word) SPC SPC t C-b C-b C-x C-e shows > «"current-word"» in the mini buffer. > > > -- > __Pascal Bourguignon__ > -- Regards Lei ^ permalink raw reply [flat|nested] 16+ messages in thread
[parent not found: <7ck522jh0n.fsf@pbourguignon.informatimago.com>]
[parent not found: <mailman.2912.1248188185.2239.help-gnu-emacs@gnu.org>]
* Re: Why emacsclient -e "(current-word nil t)" does not print ? [not found] ` <mailman.2912.1248188185.2239.help-gnu-emacs@gnu.org> @ 2009-07-21 15:24 ` Pascal J. Bourguignon 2009-07-22 5:14 ` Wang Lei [not found] ` <mailman.2960.1248239652.2239.help-gnu-emacs@gnu.org> 0 siblings, 2 replies; 16+ messages in thread From: Pascal J. Bourguignon @ 2009-07-21 15:24 UTC (permalink / raw) To: help-gnu-emacs Wang Lei <wanglei.198112@gmail.com> writes: >>What is the "it" that should print 't'? > > In my (current-word nil t) C-x C-e shows "t" in minibuffer. > This "it" means this expression "(current-word nil t)". Ok, in this case, it's normal that you get "t" since that the word that is before the cursor (just before the closing parenthesis) when you type C-x C-e. >>$ emacsclient -e '(list emacs-version (buffer-name) (current-word))' >>("22.2.1" "Main.cc" "FilterFunction") > > Mine. In urxvt and emacs shell mode: > $emacsclient -e '(list emacs-version (buffer-name) (current-word))' > ("23.1.50.1" " *server*" nil) > > It looks like the output really depends on the version. Yes. But as mentionned by Miles, you can write a more complex expression to select the buffer where you want to work: $ emacsclient -e '(mapcar (function buffer-name) (buffer-list))' ("some" "buffer" "names" ...) $ emacsclient -e '(with-current-buffer "index" (current-word nil t))' "source" > Here, I wanted to say I have tried to write a external program, that > gets the emacs' current word with emacsclient and send it to sdcv to > search. This is part of the whole function, the rest is to get it from > selection or prompt for. But now, it looks like i can not integrate > the emacs-part. (You could, but you must know what buffer you want.) Why do it from the exterior? Stay with emacs. Write an emacs command. (defun search-with-sdcv () (interactive) (let ((word (current-word nil t))) (when word (shell-command (format "sdcv %S" word) "*sdcv output*" "*sdcv errors*")))) Then you may even bind that command to a key: (global-set-key (kbd "<F12>") 'search-with-sdcv) so you just have one key to type to initiate that search from emacs, without leaving emacs. -- __Pascal Bourguignon__ ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Why emacsclient -e "(current-word nil t)" does not print ? 2009-07-21 15:24 ` Pascal J. Bourguignon @ 2009-07-22 5:14 ` Wang Lei [not found] ` <mailman.2960.1248239652.2239.help-gnu-emacs@gnu.org> 1 sibling, 0 replies; 16+ messages in thread From: Wang Lei @ 2009-07-22 5:14 UTC (permalink / raw) To: Pascal J. Bourguignon; +Cc: help-gnu-emacs On 7/21/09, Pascal J. Bourguignon <pjb@informatimago.com> wrote: > Wang Lei <wanglei.198112@gmail.com> writes: > >>>What is the "it" that should print 't'? >> >> In my (current-word nil t) C-x C-e shows "t" in minibuffer. >> This "it" means this expression "(current-word nil t)". > > Ok, in this case, it's normal that you get "t" since that the word > that is before the cursor (just before the closing parenthesis) when > you type C-x C-e. > > > >>>$ emacsclient -e '(list emacs-version (buffer-name) (current-word))' >>>("22.2.1" "Main.cc" "FilterFunction") >> >> Mine. In urxvt and emacs shell mode: >> $emacsclient -e '(list emacs-version (buffer-name) (current-word))' >> ("23.1.50.1" " *server*" nil) >> >> It looks like the output really depends on the version. > > Yes. But as mentionned by Miles, you can write a more complex > expression to select the buffer where you want to work: > > > $ emacsclient -e '(mapcar (function buffer-name) (buffer-list))' > ("some" "buffer" "names" ...) > > $ emacsclient -e '(with-current-buffer "index" (current-word nil t))' > "source" > > >> Here, I wanted to say I have tried to write a external program, that >> gets the emacs' current word with emacsclient and send it to sdcv to >> search. This is part of the whole function, the rest is to get it from >> selection or prompt for. But now, it looks like i can not integrate >> the emacs-part. > > (You could, but you must know what buffer you want.) > Actually, I don't know. I want the program can get any word in any application to search. In applications like browser you have to rely selection, but in emacs "mark" or "current-word" should be better. > > Why do it from the exterior? Stay with emacs. Write an emacs command. > > (defun search-with-sdcv () > (interactive) > (let ((word (current-word nil t))) > (when word > (shell-command (format "sdcv %S" word) "*sdcv output*" "*sdcv > errors*")))) > > Then you may even bind that command to a key: > > (global-set-key (kbd "<F12>") 'search-with-sdcv) > > so you just have one key to type to initiate that search from emacs, > without leaving emacs. > > -- > __Pascal Bourguignon__ > Thanks for you code. I already have one. And I have wrote another, it is a window manager extension, who can get word from selection or user input. It is not necessary have two, so i thought to integrate them. ............. NOW. Maybe having two choices is ok. Because if I really want to integrate everything, "get word from screen" should be my choice, not selection ang prompt. Thanks for you help! -- Regards Lei ^ permalink raw reply [flat|nested] 16+ messages in thread
[parent not found: <mailman.2960.1248239652.2239.help-gnu-emacs@gnu.org>]
* Re: Why emacsclient -e "(current-word nil t)" does not print ? [not found] ` <mailman.2960.1248239652.2239.help-gnu-emacs@gnu.org> @ 2009-07-22 6:19 ` Teemu Likonen 2009-07-22 6:35 ` Anselm Helbig 1 sibling, 0 replies; 16+ messages in thread From: Teemu Likonen @ 2009-07-22 6:19 UTC (permalink / raw) To: help-gnu-emacs On 2009-07-22 13:14 (+0800), Wang Lei wrote: > On 7/21/09, Pascal J. Bourguignon <pjb@informatimago.com> wrote: >> Wang Lei <wanglei.198112@gmail.com> writes: >>> Here, I wanted to say I have tried to write a external program, that >>> gets the emacs' current word with emacsclient and send it to sdcv to >>> search. This is part of the whole function, the rest is to get it >>> from selection or prompt for. But now, it looks like i can not >>> integrate the emacs-part. >> >> (You could, but you must know what buffer you want.) > Actually, I don't know. I want the program can get any word in any > application to search. In applications like browser you have to rely > selection, but in emacs "mark" or "current-word" should be better. How about using the selected window? Its buffer can be obtained with Emacs client: emacsclient -e '(with-current-buffer (window-buffer (selected-window)) (current-word))' ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Why emacsclient -e "(current-word nil t)" does not print ? [not found] ` <mailman.2960.1248239652.2239.help-gnu-emacs@gnu.org> 2009-07-22 6:19 ` Teemu Likonen @ 2009-07-22 6:35 ` Anselm Helbig 2009-07-22 13:27 ` Wang Lei 1 sibling, 1 reply; 16+ messages in thread From: Anselm Helbig @ 2009-07-22 6:35 UTC (permalink / raw) To: help-gnu-emacs > NOW. Maybe having two choices is ok. Because if I really want to > integrate everything, "get word from screen" should be my choice, not > selection ang prompt. Thanks for you help! So I understand that you really require to call your code from outside of emacs. When you're not in emacs, there's AFAIK no way to tell which buffer is "current". You may have many buffers, and also any number of frames and windows. This code takes the buffer that the first window of the currently selected frame is pointing to, which will probably do what you want: (with-current-buffer (window-buffer (frame-first-window)) (current-word nil t)) HTH, Anselm -- Anselm Helbig mailto:anselm.helbig+news2009@googlemail.com ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Why emacsclient -e "(current-word nil t)" does not print ? 2009-07-22 6:35 ` Anselm Helbig @ 2009-07-22 13:27 ` Wang Lei 0 siblings, 0 replies; 16+ messages in thread From: Wang Lei @ 2009-07-22 13:27 UTC (permalink / raw) To: anselm.helbig+news2009; +Cc: help-gnu-emacs Thanks! It works. I have finished it. Here is the code. -------------------->8-------------------->8-------------------- (defvar sdcv-replace-template ",$|^`|\\.$|^'|'$|\\?$") (defvar emacs-window-name "@EMACS@") (defun display-message-seconds (message seconds #!optional attributes) "Display message for N seconds." (interactive) (display-message message attributes) (make-timer (lambda () (display-message)) seconds)) (defun sdcv-get-word () "Get the word from current-word in emacs or selection or user input." (let* ((stream (make-string-output-stream)) (process (make-process stream)) (title "Enter String ") (word "") (result "")) (if (string= (window-name (input-focus)) emacs-window-name) (progn (call-process process nil "emacsclient" "-e" "(with-current-buffer (window-buffer (frame-first-window)) (current-word nil t))") (setq word (get-output-stream-string stream)) (setq word (string-replace "^\"(.+)\"\n" "\\1" word))) (setq word (string-replace sdcv-replace-template "" (x-get-selection 'PRIMARY)))) (setq word (string-replace sdcv-replace-template "" word)) (setq title (concat title "(" word "):" )) (setq result (prompt-for-string title)) (if (string= result "") word result))) (defun sdcv-search () "Search word with sdcv." (interactive) (let* ((word (sdcv-get-word)) (output (make-string-output-stream)) (proc (make-process output)) (errmsg "NO definite result. Try again.") (msg-attr '((position . (0 . 0)) (background . "LightGoldenrod1") (foreground . "black")))) (call-process proc nil "sdcv" "-n" "--data-dir" "~/.stardict/dic/stardict-langdao-ec-gb-2.4.2/" word) (setq output (get-output-stream-string output)) (if (> (when (string-match "Found \(..?\) items" output) (string->number (expand-last-match "\\1"))) 1) (display-message-seconds errmsg 2 msg-attr) (display-message-seconds output 5 msg-attr)))) -------------------->8-------------------->8-------------------- This is librep, it's like elisp, used in sawfish wm. Maybe it's useless for you at all. Just have a look. ;) On 7/22/09, Anselm Helbig <anselm.helbig+news2009@googlemail.com> wrote: >> NOW. Maybe having two choices is ok. Because if I really want to >> integrate everything, "get word from screen" should be my choice, not >> selection ang prompt. Thanks for you help! > > So I understand that you really require to call your code from outside > of emacs. When you're not in emacs, there's AFAIK no way to tell which > buffer is "current". You may have many buffers, and also any number of > frames and windows. This code takes the buffer that the first window > of the currently selected frame is pointing to, which will probably do > what you want: > > (with-current-buffer (window-buffer (frame-first-window)) (current-word > nil t)) > > HTH, > > Anselm > > > -- > Anselm Helbig > mailto:anselm.helbig+news2009@googlemail.com > -- Regards Lei ^ permalink raw reply [flat|nested] 16+ messages in thread
* Why emacsclient -e "(current-word nil t)" does not print ? @ 2009-07-21 4:31 Wang Lei 0 siblings, 0 replies; 16+ messages in thread From: Wang Lei @ 2009-07-21 4:31 UTC (permalink / raw) To: help-gnu-emacs Hi, all. I'm doing a piece of code. What needs get the output of emacsclient -e "(current-word nil t)" and send it to an external command. But there was NO output. I don't understand. Could someone explain that? Thanks! -- Regards Lei ^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2009-07-22 13:27 UTC | newest] Thread overview: 16+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <mailman.2874.1248150680.2239.help-gnu-emacs@gnu.org> 2009-07-21 6:52 ` Why emacsclient -e "(current-word nil t)" does not print ? Anselm Helbig 2009-07-21 7:33 ` Pascal J. Bourguignon 2009-07-21 11:23 ` Wang Lei [not found] ` <mailman.2902.1248175432.2239.help-gnu-emacs@gnu.org> 2009-07-21 11:43 ` Anselm Helbig 2009-07-21 11:52 ` Pascal J. Bourguignon 2009-07-21 12:12 ` Miles Bader 2009-07-21 11:47 ` Pascal J. Bourguignon 2009-07-21 13:01 ` Wang Lei [not found] ` <7cskgqjm0s.fsf@pbourguignon.informatimago.com> [not found] ` <mailman.2906.1248181279.2239.help-gnu-emacs@gnu.org> 2009-07-21 13:35 ` Pascal J. Bourguignon 2009-07-21 14:56 ` Wang Lei [not found] ` <7ck522jh0n.fsf@pbourguignon.informatimago.com> [not found] ` <mailman.2912.1248188185.2239.help-gnu-emacs@gnu.org> 2009-07-21 15:24 ` Pascal J. Bourguignon 2009-07-22 5:14 ` Wang Lei [not found] ` <mailman.2960.1248239652.2239.help-gnu-emacs@gnu.org> 2009-07-22 6:19 ` Teemu Likonen 2009-07-22 6:35 ` Anselm Helbig 2009-07-22 13:27 ` Wang Lei 2009-07-21 4:31 Wang Lei
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.