* [babel] VC-Log does not run correctly @ 2011-09-08 14:16 Sebastien Vauban 2011-09-08 15:04 ` Eric Schulte 2011-09-09 15:08 ` suvayu ali 0 siblings, 2 replies; 5+ messages in thread From: Sebastien Vauban @ 2011-09-08 14:16 UTC (permalink / raw) To: emacs-orgmode-mXXj517/zsQ #+TITLE: Last VC Log #+AUTHOR: Seb Vauban #+DATE: 2011-09-08 #+LANGUAGE: en #+OPTIONS: num:nil toc:nil * Abstract I'm trying to get, from the VC backend (currently SVN in my case), the name and date of the last committer. Eventually, as well the last log message. Therefore, I try to use the =vc-log= function in the Library of Babel, copied back in this buffer, for the sake of simplicity. When calling =C-c C-e b= on this buffer, I get asked by Emacs: "Buffer has a running process; kill it? (yes or no)" - If I don't say anything, the export process is just hanging in the blue... - If I say yes, the export process really begins, but there is no vc log inserted where I expect it. - Exactly the same (as if I say yes) happens if I say no: export goes on, but no vc log! What could go wrong here? * Org Source #+source: vc-log #+headers: :var limit=-1 #+headers: :var buf=(buffer-name (current-buffer)) #+begin_src emacs-lisp :exports none ;; Most of this code is copied from vc.el vc-print-log (require 'vc) (when (vc-find-backend-function (vc-backend (buffer-file-name (get-buffer buf))) 'print-log) (let ((limit -1) (vc-fileset nil) (backend nil) (files nil)) (with-current-buffer (get-buffer buf) (setq vc-fileset (vc-deduce-fileset t)) ; FIXME: Why t? --Stef (setq backend (car vc-fileset)) (setq files (cadr vc-fileset))) (with-temp-buffer (let ((status (vc-call-backend backend 'print-log files (current-buffer)))) (when (and (processp status) ; Make sure status is a process (= 0 (process-exit-status status))) ; which has not terminated (while (not (eq 'exit (process-status status))) (sit-for 1 t))) (buffer-string))))) #+end_src Last edited by XXX on XXX #+call: vc-log() * HTML Result #+begin_src html Last VC Log Org Source Last edited by XXX on XXX Working file: c:/home/sva/ecm.org Date: 2011-09-08 Author: Seb Vauban Validate XHTML 1.0 #+end_src As you can see, there is no vc log at all, well the header of the vc log buffer: "Working file: c:/home/sva/ecm.org" * Messages buffer #+begin_src text Export buffer: Exporting... Running svn status -v ecm.html in foreground... Running svn status -v ecm.html...OK = 0 Position saved to mark ring, go back with M-x org-mark-ring-goto. (info) +-> Requiring `help-fns'... already loaded [6 times] executing Emacs-Lisp code block (vc-log)... (buf (quote "ecm.org")) (limit (quote -1)) Running svn log -rHEAD:0 ecm.org in background... done "Working file: c:/home/sva/ecm.org " (info) +-> Requiring `help-fns'... already loaded executing Emacs-Lisp code block... (results (quote "Working file: c:/home/sva/ecm.org ")) Code block evaluation complete. org-babel-exp processing... org-babel-exp processing... Exporting... Saving file c:/home/sva/ecm.html... Wrote c:/home/sva/ecm.html Running svn status -v ecm.html in foreground... Running svn status -v ecm.html...OK = 0 Exporting... done #+end_src Any idea on how to help me going further with this? Best regards, Seb -- Sebastien Vauban ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [babel] VC-Log does not run correctly 2011-09-08 14:16 [babel] VC-Log does not run correctly Sebastien Vauban @ 2011-09-08 15:04 ` Eric Schulte 2011-09-09 14:50 ` Sebastien Vauban 2011-09-12 12:18 ` Sebastien Vauban 2011-09-09 15:08 ` suvayu ali 1 sibling, 2 replies; 5+ messages in thread From: Eric Schulte @ 2011-09-08 15:04 UTC (permalink / raw) To: Sebastien Vauban; +Cc: emacs-orgmode Hi Seb, Off the top of my head I would recommend first running the vc-log code block interactively to see how it behaves, then possibly expanding the code block with C-c C-v v, copying the results to your scratch buffer, evaluating the resulting elisp with edebug (C-M-x with a prefix argument), which will then allow you to step through the code execution statement by statement. This should help to pinpoint the problem. Hope this helps -- Eric "Sebastien Vauban" <wxhgmqzgwmuf@spammotel.com> writes: > #+TITLE: Last VC Log > #+AUTHOR: Seb Vauban > #+DATE: 2011-09-08 > #+LANGUAGE: en > #+OPTIONS: num:nil toc:nil > > * Abstract > > I'm trying to get, from the VC backend (currently SVN in my case), the name > and date of the last committer. Eventually, as well the last log message. > > Therefore, I try to use the =vc-log= function in the Library of Babel, copied > back in this buffer, for the sake of simplicity. > > When calling =C-c C-e b= on this buffer, I get asked by Emacs: > > "Buffer has a running process; kill it? (yes or no)" > > - If I don't say anything, the export process is just hanging in the blue... > > - If I say yes, the export process really begins, but there is no vc log > inserted where I expect it. > > - Exactly the same (as if I say yes) happens if I say no: export goes on, but > no vc log! > > What could go wrong here? > > * Org Source > > #+source: vc-log > #+headers: :var limit=-1 > #+headers: :var buf=(buffer-name (current-buffer)) > #+begin_src emacs-lisp :exports none > ;; Most of this code is copied from vc.el vc-print-log > (require 'vc) > (when (vc-find-backend-function > (vc-backend (buffer-file-name (get-buffer buf))) 'print-log) > (let ((limit -1) > (vc-fileset nil) > (backend nil) > (files nil)) > (with-current-buffer (get-buffer buf) > (setq vc-fileset (vc-deduce-fileset t)) ; FIXME: Why t? --Stef > (setq backend (car vc-fileset)) > (setq files (cadr vc-fileset))) > (with-temp-buffer > (let ((status (vc-call-backend > backend 'print-log files (current-buffer)))) > (when (and (processp status) ; Make sure status is a process > (= 0 (process-exit-status status))) ; which has not terminated > (while (not (eq 'exit (process-status status))) > (sit-for 1 t))) > (buffer-string))))) > #+end_src > > Last edited by XXX on XXX > > #+call: vc-log() > > * HTML Result > > #+begin_src html > Last VC Log > Org Source > > Last edited by XXX on XXX > > Working file: c:/home/sva/ecm.org > > Date: 2011-09-08 > > Author: Seb Vauban > Validate XHTML 1.0 > #+end_src > > As you can see, there is no vc log at all, well the header of the vc log > buffer: > > "Working file: c:/home/sva/ecm.org" > > * Messages buffer > > #+begin_src text > Export buffer: > Exporting... > Running svn status -v ecm.html in foreground... > Running svn status -v ecm.html...OK = 0 > Position saved to mark ring, go back with M-x org-mark-ring-goto. > (info) +-> Requiring `help-fns'... already loaded [6 times] > executing Emacs-Lisp code block (vc-log)... > > (buf (quote "ecm.org")) > > (limit (quote -1)) > > Running svn log -rHEAD:0 ecm.org in background... done > "Working file: c:/home/sva/ecm.org > " > (info) +-> Requiring `help-fns'... already loaded > executing Emacs-Lisp code block... > > (results (quote "Working file: c:/home/sva/ecm.org > ")) > > Code block evaluation complete. > org-babel-exp processing... > org-babel-exp processing... > Exporting... > Saving file c:/home/sva/ecm.html... > Wrote c:/home/sva/ecm.html > Running svn status -v ecm.html in foreground... > Running svn status -v ecm.html...OK = 0 > Exporting... done > #+end_src > > Any idea on how to help me going further with this? > > Best regards, > Seb -- Eric Schulte http://cs.unm.edu/~eschulte/ ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [babel] VC-Log does not run correctly 2011-09-08 15:04 ` Eric Schulte @ 2011-09-09 14:50 ` Sebastien Vauban 2011-09-12 12:18 ` Sebastien Vauban 1 sibling, 0 replies; 5+ messages in thread From: Sebastien Vauban @ 2011-09-09 14:50 UTC (permalink / raw) To: emacs-orgmode-mXXj517/zsQ Hi Eric, Eric Schulte wrote: > Off the top of my head I would recommend first running the vc-log code > block interactively to see how it behaves Had alreayd done it. Same behavior: question asked; whichever the answer, the results is empty (well, almost: only the first line stating the name of the file). > then possibly expanding the code block with C-c C-v v, copying the results > to your scratch buffer, evaluating the resulting elisp with edebug (C-M-x > with a prefix argument), which will then allow you to step through the code > execution statement by statement. This should help to pinpoint the problem. #+begin_src emacs-lisp (let ((buf (quote "ecm-org.txt")) (limit (quote -1))) ;; Most of this code is copied from vc.el vc-print-log (require 'vc) (when (vc-find-backend-function (vc-backend (buffer-file-name (get-buffer buf))) 'print-log) (let ((limit -1) (vc-fileset nil) (backend nil) (files nil)) (with-current-buffer (get-buffer buf) (setq vc-fileset (vc-deduce-fileset t)) ; FIXME: Why t? --Stef (setq backend (car vc-fileset)) (setq files (cadr vc-fileset))) (with-temp-buffer (let ((status (vc-call-backend backend 'print-log files (current-buffer)))) (when (and (processp status) ; Make sure status is a process (= 0 (process-exit-status status))) ; which has not terminated (while (not (eq 'exit (process-status status))) (sit-for 1 t))) (buffer-string)))))) #+end_src The first 2 lines were added. Executing that block gives the same results. However, I still need to do your next piece of advice: going through an edebug. I'll do it, and will let you know. Best regards, Seb -- Sebastien Vauban ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [babel] VC-Log does not run correctly 2011-09-08 15:04 ` Eric Schulte 2011-09-09 14:50 ` Sebastien Vauban @ 2011-09-12 12:18 ` Sebastien Vauban 1 sibling, 0 replies; 5+ messages in thread From: Sebastien Vauban @ 2011-09-12 12:18 UTC (permalink / raw) To: emacs-orgmode-mXXj517/zsQ Hi Eric and all, Eric Schulte wrote: >> When calling =C-c C-e b= on this buffer, I get asked by Emacs: >> >> "Buffer has a running process; kill it? (yes or no)" >> >> - If I don't say anything, the export process is just hanging in the blue... >> >> - If I say yes, the export process really begins, but there is no vc log >> inserted where I expect it. >> >> - Exactly the same (as if I say yes) happens if I say no: export goes on, but >> no vc log! >> >> What could go wrong here? >> >> * Org Source >> >> #+source: vc-log >> #+headers: :var limit=-1 >> #+headers: :var buf=(buffer-name (current-buffer)) >> #+begin_src emacs-lisp :exports none >> ;; Most of this code is copied from vc.el vc-print-log >> (require 'vc) >> (when (vc-find-backend-function >> (vc-backend (buffer-file-name (get-buffer buf))) 'print-log) >> (let ((limit -1) >> (vc-fileset nil) >> (backend nil) >> (files nil)) >> (with-current-buffer (get-buffer buf) >> (setq vc-fileset (vc-deduce-fileset t)) ; FIXME: Why t? --Stef >> (setq backend (car vc-fileset)) >> (setq files (cadr vc-fileset))) >> (with-temp-buffer >> (let ((status (vc-call-backend >> backend 'print-log files (current-buffer)))) >> (when (and (processp status) ; Make sure status is a process >> (= 0 (process-exit-status status))) ; which has not terminated >> (while (not (eq 'exit (process-status status))) >> (sit-for 1 t))) >> (buffer-string))))) >> #+end_src > > Off the top of my head I would recommend Thanks for this clear TODO list, which has giving me some interesting returns... > first running the vc-log code block interactively to see how it behaves, As previously said, that worked OK. > then possibly expanding the code block with C-c C-v v, The values in the preamble of the expanded block do look OK (see next section). > copying the results to your scratch buffer, evaluating the resulting elisp > with edebug (C-M-x with a prefix argument), which will then allow you to > step through the code execution statement by statement. Did this on the following contents in the scratch buffer: #+begin_src emacs-lisp (let ((buf (quote "ecm-vc-log.txt")) (limit (quote -1))) ;; Most of this code is copied from vc.el vc-print-log (require 'vc) (when (vc-find-backend-function (vc-backend (buffer-file-name (get-buffer buf))) 'print-log) (let ((limit -1) (vc-fileset nil) (backend nil) (files nil)) (with-current-buffer (get-buffer buf) (setq vc-fileset (vc-deduce-fileset t)) ; FIXME: Why t? --Stef (setq backend (car vc-fileset)) (setq files (cadr vc-fileset))) (with-temp-buffer (let ((status (vc-call-backend backend 'print-log files (current-buffer)))) (when (and (processp status) ; Make sure status is a process (= 0 (process-exit-status status))) ; which has not terminated (while (not (eq 'exit (process-status status))) (sit-for 1 t))) (buffer-string)))))) #+end_src ... and it works OK as well. I mean: when I trace the code manually (with SPC), I do get the correct (thus, full) log history printed in the echo area, when I arrive at the last lines of this block's execution. All the vars were as well correctly resolved: - backend is SVN - file is a full path to the right location - etc. So, there is a difference between: - executing this code in the scratch buffer, step by step, versus - executing it in a #+call line However, these instructions helped me a lot. For example, I've observed that, in the scratch buffer, C-x C-e doesn't run in the intended way: I also have the question arising, about the running process. And this is somehow related to the process returning something, or being still alive. ...Here begins my point of incompetence... But, by playing around, I've managed to fix the code so that it now works OK in my Org buffer. Working code: #+source: vc-log #+headers: :var limit=-1 #+headers: :var buf=(buffer-name (current-buffer)) #+begin_src emacs-lisp :exports none ;; Most of this code is copied from vc.el vc-print-log (require 'vc) (when (vc-find-backend-function (vc-backend (buffer-file-name (get-buffer buf))) 'print-log) (let ((limit -1) (vc-fileset nil) (backend nil) (files nil)) (with-current-buffer (get-buffer buf) (setq vc-fileset (vc-deduce-fileset t)) ; FIXME: Why t? --Stef (setq backend (car vc-fileset)) (setq files (cadr vc-fileset))) (with-temp-buffer (let ((status (vc-call-backend backend 'print-log files (current-buffer)))) (when (and t ; (processp status) ; Make sure status is a process ;; (= 0 (process-exit-status status)) ; which has not terminated ) ;; (while (not (eq 'exit (process-status status))) (sit-for 1 t) ;; ) ) (buffer-string))))) #+end_src To get it working, I have had to fix 2 things (to the original version of vc-log, in the LOB): 1. comment the `and' condition: the lines with `processp status' and `process-exit-status' (adding a `t' value to make it success) If I don't do that, I do have the question "Buffer has a running process" arising... and no results displayed. 2. comment the `while' condition: the line with `process-status' If I don't do that, I've the error "edebug-signal: Buffer *temp*<1> has no process", and no results displayed. Finally, to be complete, I've played with the value of the wait timer (`sit-for'): - greater or equal to 1 works OK, but delays the execution for that amount of time, of course. - equal to 0, gets me back to the question arising, about "Buffer has a running process". Voilà, there it is. I can't say more about the strange things appearing here. But I'm willing to answer any question to further test this. I'm happy to have a workaround, but would be glad someone could help into making this code chunk robust on all Org platforms, as I guess what I've done is quite fragile... Best regards, Seb -- Sebastien Vauban ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [babel] VC-Log does not run correctly 2011-09-08 14:16 [babel] VC-Log does not run correctly Sebastien Vauban 2011-09-08 15:04 ` Eric Schulte @ 2011-09-09 15:08 ` suvayu ali 1 sibling, 0 replies; 5+ messages in thread From: suvayu ali @ 2011-09-09 15:08 UTC (permalink / raw) To: Sebastien Vauban; +Cc: emacs-orgmode Hi Seb, On Thu, Sep 8, 2011 at 4:16 PM, Sebastien Vauban <wxhgmqzgwmuf@spammotel.com> wrote: > (when (vc-find-backend-function > (vc-backend (buffer-file-name (get-buffer buf))) 'print-log) > AFAIU from a previous issue (more than a year back I think), you need to ensure buffer-file-name returns something reasonable. The problem is if it is evaluated in a temporary buffer (is that the case during export?) then it will return nil which confuses vc. Hope this helps. -- Suvayu Open source is the future. It sets us free. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-09-12 12:18 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-09-08 14:16 [babel] VC-Log does not run correctly Sebastien Vauban 2011-09-08 15:04 ` Eric Schulte 2011-09-09 14:50 ` Sebastien Vauban 2011-09-12 12:18 ` Sebastien Vauban 2011-09-09 15:08 ` suvayu ali
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.