LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 03-05-2007, 11:52 PM   #1
parv
Member
 
Registered: Jul 2004
Location: USA
Distribution: Mint, Scientifc Linux, Ubuntu
Posts: 180

Rep: Reputation: 30
emacs lisp problem, how to force to add " to path


in my .emacs I have:
(list "View" "yap %d" 'TeX-run-command nil t)

I wanna know how to modify the above lisp such that
yap /path/to/file will run as yap "/path/to/file

I need to add the " to the path but I am not familiar
with lisp that much.

Thanks.
 
Old 03-06-2007, 07:53 AM   #2
hoosier45678
LQ Newbie
 
Registered: Mar 2007
Posts: 3

Rep: Reputation: 0
Quote:
Originally Posted by parv
in my .emacs I have:
(list "View" "yap %d" 'TeX-run-command nil t)

I wanna know how to modify the above lisp such that
yap /path/to/file will run as yap "/path/to/file

I need to add the " to the path but I am not familiar
with lisp that much.

Thanks.
Just escape the quotes with a backslash:

(list "View" "yap \"%d\"" 'TeX-run-command nil t)
 
Old 03-06-2007, 08:42 AM   #3
parv
Member
 
Registered: Jul 2004
Location: USA
Distribution: Mint, Scientifc Linux, Ubuntu
Posts: 180

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by hoosier45678
Just escape the quotes with a backslash:

(list "View" "yap \"%d\"" 'TeX-run-command nil t)
Actually, I have tried to use \" but it did not help.
So I was thinking maybe I got it wrong somewhere.
The reason I posted this thread was:

I am using emacs+miktex to edit latex file.
When I try to preview dvi file using yap (included in miktex)
by "C-c C-v" within emacs, I could not open the dvi file.
It was because in Windows, there are path names containing "space",
such as "My Documents". But in command line, if I use
yap "My Documents\a.dvi, then it worked.

So I am thinking how to pass that " to the path name.
Thanks.
 
Old 03-06-2007, 10:17 AM   #4
parv
Member
 
Registered: Jul 2004
Location: USA
Distribution: Mint, Scientifc Linux, Ubuntu
Posts: 180

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by parv
Actually, I have tried to use \" but it did not help.
So I was thinking maybe I got it wrong somewhere.
The reason I posted this thread was:

I am using emacs+miktex to edit latex file.
When I try to preview dvi file using yap (included in miktex)
by "C-c C-v" within emacs, I could not open the dvi file.
It was because in Windows, there are path names containing "space",
such as "My Documents". But in command line, if I use
yap "My Documents\a.dvi, then it worked.

So I am thinking how to pass that " to the path name.
Thanks.
What if I want to replace all space in path name with " "?
 
Old 03-06-2007, 03:02 PM   #5
studioj
Member
 
Registered: Oct 2006
Posts: 460

Rep: Reputation: 31
try it like this
"yap '%d'"
or
"yap `%d`"

see if that will work
 
Old 03-06-2007, 04:06 PM   #6
parv
Member
 
Registered: Jul 2004
Location: USA
Distribution: Mint, Scientifc Linux, Ubuntu
Posts: 180

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by studioj
try it like this
"yap '%d'"
or
"yap `%d`"

see if that will work
unfortunately, neither works.

No such file or directory: c:\'%d.dvi
No such file or directory: c:\`%d`.dvi

And I even tried to move everything (emacs, miktex, and .dvi)
to c:\GNU which does not have space in its path name.
Now the problem is the yap window only starts after I close emacs.
But if in emacs I use M-! then type yap a.dvi, then no matter
where a.dvi locates, I can always open a.dvi.
Should "M-! yap a.dvi" and "M-x shell" + "shell command line: yap a.dvi"
be so much different?

Maybe we should figure out how to use global key
to make "C-c C-v" equal to "M-! yap filename"
BTW, how to implement this in emacs? I don't know
how to obtain the current file/buffer name.
 
Old 03-07-2007, 10:58 AM   #7
hoosier45678
LQ Newbie
 
Registered: Mar 2007
Posts: 3

Rep: Reputation: 0
I wonder if the problem is the use of backslashes on windows? (Incidentally, an emacs or TeX or Miktex forum might be more appropriate place for this question)

try the following to see if I'm right...

paste this into *scratch* (or your .emacs)

(defun yap-current-file()
(interactive)
(shell-command
(concat "yap " (replace-regexp-in-string "/" "\\\\\\\\" (buffer-file-name)) " &") "*yap output*" "*yap output*"))

put your cursor after it and C-x e

then change to the buffer you want to view and
M-x yap-current-file
 
Old 03-07-2007, 04:05 PM   #8
hoosier45678
LQ Newbie
 
Registered: Mar 2007
Posts: 3

Rep: Reputation: 0
Quote:
Originally Posted by hoosier45678
put your cursor after it and C-x e
Sorry. That should have been C-x C-e
 
Old 03-07-2007, 05:22 PM   #9
parv
Member
 
Registered: Jul 2004
Location: USA
Distribution: Mint, Scientifc Linux, Ubuntu
Posts: 180

Original Poster
Rep: Reputation: 30
Smile

Quote:
Originally Posted by hoosier45678
I wonder if the problem is the use of backslashes on windows? (Incidentally, an emacs or TeX or Miktex forum might be more appropriate place for this question)

try the following to see if I'm right...

paste this into *scratch* (or your .emacs)

(defun yap-current-file()
(interactive)
(shell-command
(concat "yap " (replace-regexp-in-string "/" "\\\\\\\\" (buffer-file-name)) " &") "*yap output*" "*yap output*"))

put your cursor after it and C-x e

then change to the buffer you want to view and
M-x yap-current-file
thanks very much! your code almost worked.
Some changes need to be made:
1. this is important, at the beginning of path name, put a ", o/w
yap still tried to open Documents.dvi if the absolute path is
Documents and Settings\blah\blah
2. need to replace .tex to .dvi which was missing

Anyway, many thanks to your code, really helped.
Now I feel accomplished something
 
  


Reply

Tags
emacs


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Emacs LISP - function and keymap? jantman Programming 5 09-28-2006 11:59 AM
Learning Lisp helpful for using Emacs? dr_zayus69 Programming 1 06-15-2005 12:44 PM
emacs and lisp jonathanz1980 Linux - Software 4 09-24-2004 10:00 AM
emacs and lisp jonathanz1980 Programming 4 09-24-2004 09:30 AM
Lisp, emacs-lisp aizkorri Programming 1 09-04-2002 06:16 PM


All times are GMT -5. The time now is 08:53 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration