emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH 0/2] Soem more minor patches
@ 2009-10-21  9:52 James TD Smith
  2009-10-21  9:52 ` [PATCH 1/2] Add an X11 equivalent to org-mac-idle-seconds James TD Smith
  2009-10-22  5:38 ` [PATCH 0/2] Soem more minor patches Carsten Dominik
  0 siblings, 2 replies; 7+ messages in thread
From: James TD Smith @ 2009-10-21  9:52 UTC (permalink / raw)
  To: emacs-orgmode

I found the changes John Wiegley made to org-repeat-re stopped it from matching
repeaters with just a '+' at the start. I have fixed this.

Also, I've added a way for the clock resolution code to use system idle time
under X11, using a small C program which uses the xscreensaver extension.

James TD Smith (2):
  Add an X11 equivalent to org-mac-idle-seconds.
  org-repeat-re was no longer matching simple +2d type repeaters. Fix.

 .gitignore          |    1 +
 ChangeLog           |    6 +++++-
 UTILITIES/x11idle.c |   21 +++++++++++++++++++++
 lisp/ChangeLog      |   11 ++++++++++-
 lisp/org-clock.el   |   10 ++++++++--
 lisp/org.el         |    2 +-
 6 files changed, 46 insertions(+), 5 deletions(-)
 create mode 100644 UTILITIES/x11idle.c

--
|-<James TD Smith>-<email/ahktenzero@mohorovi.cc>-|

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

* [PATCH 1/2] Add an X11 equivalent to org-mac-idle-seconds.
  2009-10-21  9:52 [PATCH 0/2] Soem more minor patches James TD Smith
@ 2009-10-21  9:52 ` James TD Smith
  2009-10-21  9:52   ` [PATCH 2/2] org-repeat-re was no longer matching simple +2d type repeaters. Fix James TD Smith
  2009-10-22 13:16   ` [PATCH 1/2] Add an X11 equivalent to org-mac-idle-seconds Carsten Dominik
  2009-10-22  5:38 ` [PATCH 0/2] Soem more minor patches Carsten Dominik
  1 sibling, 2 replies; 7+ messages in thread
From: James TD Smith @ 2009-10-21  9:52 UTC (permalink / raw)
  To: emacs-orgmode

This needs a small C program (in UTILITIES/x11idle.c) to work.
---
 .gitignore          |    1 +
 ChangeLog           |    6 +++++-
 UTILITIES/x11idle.c |   21 +++++++++++++++++++++
 lisp/ChangeLog      |    8 +++++++-
 lisp/org-clock.el   |   10 ++++++++--
 5 files changed, 42 insertions(+), 4 deletions(-)
 create mode 100644 UTILITIES/x11idle.c

diff --git a/.gitignore b/.gitignore
index ab68b2a..c21fc91 100644
--- a/.gitignore
+++ b/.gitignore
@@ -58,3 +58,4 @@ TODO
 # fill-column: 72
 # mode: conf
 # End:
+/UTILITIES/x11idle
diff --git a/ChangeLog b/ChangeLog
index 95387ea..77cca37 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-10-21  James TD Smith  <ahktenzero@mohorovi.cc>
+
+	* UTILITIES/x11idle.c: Add a small C program which outputs the X11
+	idle time
+
 2009-09-16  Carsten Dominik  <carsten.dominik@gmail.com>
 
 	* Makefile: Add dependencies for org-crypt.el.
@@ -65,4 +70,3 @@
 2008-04-25  Carsten Dominik  <dominik@science.uva.nl>
 
 	* Makefile (BATCH): Fix the path to the local lisp files.
-
diff --git a/UTILITIES/x11idle.c b/UTILITIES/x11idle.c
new file mode 100644
index 0000000..33d0035
--- /dev/null
+++ b/UTILITIES/x11idle.c
@@ -0,0 +1,21 @@
+#include <X11/extensions/scrnsaver.h>
+#include <stdio.h>
+
+/* Based on code from
+ * http://coderrr.wordpress.com/2008/04/20/getting-idle-time-in-unix/
+ *
+ * compile with 'gcc -l Xss x11idle.c -o x11idle' and copy x11idle into your
+ * path
+ */
+main() {
+    XScreenSaverInfo *info = XScreenSaverAllocInfo();
+    Display *display = XOpenDisplay(0);
+
+    //check that X11 is running or else you get a segafult/coredump
+    if (display != NULL) {
+	XScreenSaverQueryInfo(display, DefaultRootWindow(display), info);
+    }
+    XScreenSaverQueryInfo(display, DefaultRootWindow(display), info);
+    printf("%u\n", info->idle);
+    return 0;
+}
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index bcd6a8a..75bdc38 100755
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -37,6 +37,12 @@
 	modeline when habits are being displayed (if that module is being
 	loaded).
 
+2009-10-21  James TD Smith  <ahktenzero@mohorovi.cc>
+
+	* org-clock.el (org-x11-idle-seconds): Add a method to get the X11
+	idle time using the xscreensaver extension.
+	(org-user-idle-seconds): Use X11 idle time if available.
+
 2009-10-20  Carsten Dominik  <carsten.dominik@gmail.com>
 
 	* org-agenda.el (org-agenda-next-line): New command.
@@ -161,7 +167,7 @@
 	currently active clock if the user has exceeded the time returned
 	by `org-user-idle-seconds', based on the value of
 	`org-clock-idle-time'.
-	(org-clock-in): If, after resolving clocks, 
+	(org-clock-in): If, after resolving clocks,
 	(org-clock-out): Cancel the `org-clock-idle-timer' on clock out.
 
 	* org-clock.el (org-clock-resolve-clock): New function that
diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index c7ebbf8..fddf3f8 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -762,16 +762,22 @@ non-dangling (i.e., currently open and valid) clocks."
   "Return the current Mac idle time in seconds"
   (string-to-number (shell-command-to-string "ioreg -c IOHIDSystem | perl -ane 'if (/Idle/) {$idle=(pop @F)/1000000000; print $idle; last}'")))
 
+(defun org-x11-idle-seconds ()
+  "Return the current X11 idle time in seconds"
+  (/ (string-to-number (shell-command-to-string "x11idle")) 1000))
+
 (defun org-user-idle-seconds ()
   "Return the number of seconds the user has been idle for.
 This routine returns a floating point number."
-  (if (eq system-type 'darwin)
+  (if (or (eq system-type 'darwin) (eq window-system 'x))
       (let ((emacs-idle (org-emacs-idle-seconds)))
 	;; If Emacs has been idle for longer than the user's
 	;; `org-clock-idle-time' value, check whether the whole system has
 	;; really been idle for that long.
 	(if (> emacs-idle (* 60 org-clock-idle-time))
-	    (min emacs-idle (org-mac-idle-seconds))
+	    (min emacs-idle (if (eq system-type 'darwin)
+				(org-mac-idle-seconds)
+			      (org-x11-idle-seconds)))
 	  emacs-idle))
     (org-emacs-idle-seconds)))
 
-- 
1.6.3.3

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

* [PATCH 2/2] org-repeat-re was no longer matching simple +2d type repeaters. Fix.
  2009-10-21  9:52 ` [PATCH 1/2] Add an X11 equivalent to org-mac-idle-seconds James TD Smith
@ 2009-10-21  9:52   ` James TD Smith
  2009-10-22 13:16   ` [PATCH 1/2] Add an X11 equivalent to org-mac-idle-seconds Carsten Dominik
  1 sibling, 0 replies; 7+ messages in thread
From: James TD Smith @ 2009-10-21  9:52 UTC (permalink / raw)
  To: emacs-orgmode

---
 lisp/ChangeLog |    3 +++
 lisp/org.el    |    2 +-
 2 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 75bdc38..9bd532d 100755
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -39,6 +39,9 @@
 
 2009-10-21  James TD Smith  <ahktenzero@mohorovi.cc>
 
+	* org.el (org-repeat-re): The changed org-repeat-re no longer
+	matched simple +2d type repeaters. Fix it so it does.
+
 	* org-clock.el (org-x11-idle-seconds): Add a method to get the X11
 	idle time using the xscreensaver extension.
 	(org-user-idle-seconds): Use X11 idle time if available.
diff --git a/lisp/org.el b/lisp/org.el
index cdb8d25..d5a30ac 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -475,7 +475,7 @@ An entry can be toggled between QUOTE and normal with
   :type 'string)
 
 (defconst org-repeat-re
-  "<[0-9]\\{4\\}-[0-9][0-9]-[0-9][0-9] [^>\n]*?\\([.+]?\\+[0-9]+[dwmy]\\(/[0-9]+[dwmy]\\)?\\)"
+  "<[0-9]\\{4\\}-[0-9][0-9]-[0-9][0-9] [^+.>\n]*\\([.+]?\\+[0-9]+[dwmy]\\(/[0-9]+[dwmy]\\)?\\)"
   "Regular expression for specifying repeated events.
 After a match, group 1 contains the repeat expression.")
 
-- 
1.6.3.3

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

* Re: [PATCH 0/2] Soem more minor patches
  2009-10-21  9:52 [PATCH 0/2] Soem more minor patches James TD Smith
  2009-10-21  9:52 ` [PATCH 1/2] Add an X11 equivalent to org-mac-idle-seconds James TD Smith
@ 2009-10-22  5:38 ` Carsten Dominik
  2009-10-22 10:22   ` James TD Smith
  1 sibling, 1 reply; 7+ messages in thread
From: Carsten Dominik @ 2009-10-22  5:38 UTC (permalink / raw)
  To: James TD Smith; +Cc: emacs-orgmode


On Oct 21, 2009, at 11:52 AM, James TD Smith wrote:

> I found the changes John Wiegley made to org-repeat-re stopped it  
> from matching
> repeaters with just a '+' at the start. I have fixed this.

Hi James, can you please provide an example for this bug?

Thanks!

- Carsten


>
> Also, I've added a way for the clock resolution code to use system  
> idle time
> under X11, using a small C program which uses the xscreensaver  
> extension.
>
> James TD Smith (2):
>  Add an X11 equivalent to org-mac-idle-seconds.
>  org-repeat-re was no longer matching simple +2d type repeaters. Fix.
>
> .gitignore          |    1 +
> ChangeLog           |    6 +++++-
> UTILITIES/x11idle.c |   21 +++++++++++++++++++++
> lisp/ChangeLog      |   11 ++++++++++-
> lisp/org-clock.el   |   10 ++++++++--
> lisp/org.el         |    2 +-
> 6 files changed, 46 insertions(+), 5 deletions(-)
> create mode 100644 UTILITIES/x11idle.c
>
> --
> |-<James TD Smith>-<email/ahktenzero@mohorovi.cc>-|
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

- Carsten

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

* Re: [PATCH 0/2] Soem more minor patches
  2009-10-22  5:38 ` [PATCH 0/2] Soem more minor patches Carsten Dominik
@ 2009-10-22 10:22   ` James TD Smith
  2009-10-22 13:17     ` Carsten Dominik
  0 siblings, 1 reply; 7+ messages in thread
From: James TD Smith @ 2009-10-22 10:22 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode

Hi Carsten,

On 2009-10-22 07:38:04(+0200), Carsten Dominik wrote:
>
> On Oct 21, 2009, at 11:52 AM, James TD Smith wrote:
>
> > I found the changes John Wiegley made to org-repeat-re stopped it from
> > matching repeaters with just a '+' at the start. I have fixed this.
>
> Hi James, can you please provide an example for this bug?

I've had another look at this and it looks like it's already been fixed. The
version of org-repeat-re in b40c4e did fail to match repeated timestamps like
<2009-10-22 Thu +4d> but would not match <2009-10-22 Thu .+4d> or
<2009-10-22 Thu ++4d>, so org-log-repeat would return nil and repeated tasks
stop repeating.

The org-repeat-re in f93ace works fine.
>
> >
> > Also, I've added a way for the clock resolution code to use system
> > idle time
> > under X11, using a small C program which uses the xscreensaver
> > extension.
> >
> > James TD Smith (2):
> >  Add an X11 equivalent to org-mac-idle-seconds.
> >  org-repeat-re was no longer matching simple +2d type repeaters. Fix.
> >
> > .gitignore          |    1 +
> > ChangeLog           |    6 +++++-
> > UTILITIES/x11idle.c |   21 +++++++++++++++++++++
> > lisp/ChangeLog      |   11 ++++++++++-
> > lisp/org-clock.el   |   10 ++++++++--
> > lisp/org.el         |    2 +-
> > 6 files changed, 46 insertions(+), 5 deletions(-)
> > create mode 100644 UTILITIES/x11idle.c

James

--
|-<James TD Smith>-<email/ahktenzero@mohorovi.cc>-|

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

* Re: [PATCH 1/2] Add an X11 equivalent to org-mac-idle-seconds.
  2009-10-21  9:52 ` [PATCH 1/2] Add an X11 equivalent to org-mac-idle-seconds James TD Smith
  2009-10-21  9:52   ` [PATCH 2/2] org-repeat-re was no longer matching simple +2d type repeaters. Fix James TD Smith
@ 2009-10-22 13:16   ` Carsten Dominik
  1 sibling, 0 replies; 7+ messages in thread
From: Carsten Dominik @ 2009-10-22 13:16 UTC (permalink / raw)
  To: James TD Smith; +Cc: emacs-orgmode

Applied, thanks.

- Carsten

On Oct 21, 2009, at 11:52 AM, James TD Smith wrote:

> This needs a small C program (in UTILITIES/x11idle.c) to work.
> ---
> .gitignore          |    1 +
> ChangeLog           |    6 +++++-
> UTILITIES/x11idle.c |   21 +++++++++++++++++++++
> lisp/ChangeLog      |    8 +++++++-
> lisp/org-clock.el   |   10 ++++++++--
> 5 files changed, 42 insertions(+), 4 deletions(-)
> create mode 100644 UTILITIES/x11idle.c
>
> diff --git a/.gitignore b/.gitignore
> index ab68b2a..c21fc91 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -58,3 +58,4 @@ TODO
> # fill-column: 72
> # mode: conf
> # End:
> +/UTILITIES/x11idle
> diff --git a/ChangeLog b/ChangeLog
> index 95387ea..77cca37 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,8 @@
> +2009-10-21  James TD Smith  <ahktenzero@mohorovi.cc>
> +
> +	* UTILITIES/x11idle.c: Add a small C program which outputs the X11
> +	idle time
> +
> 2009-09-16  Carsten Dominik  <carsten.dominik@gmail.com>
>
> 	* Makefile: Add dependencies for org-crypt.el.
> @@ -65,4 +70,3 @@
> 2008-04-25  Carsten Dominik  <dominik@science.uva.nl>
>
> 	* Makefile (BATCH): Fix the path to the local lisp files.
> -
> diff --git a/UTILITIES/x11idle.c b/UTILITIES/x11idle.c
> new file mode 100644
> index 0000000..33d0035
> --- /dev/null
> +++ b/UTILITIES/x11idle.c
> @@ -0,0 +1,21 @@
> +#include <X11/extensions/scrnsaver.h>
> +#include <stdio.h>
> +
> +/* Based on code from
> + * http://coderrr.wordpress.com/2008/04/20/getting-idle-time-in-unix/
> + *
> + * compile with 'gcc -l Xss x11idle.c -o x11idle' and copy x11idle  
> into your
> + * path
> + */
> +main() {
> +    XScreenSaverInfo *info = XScreenSaverAllocInfo();
> +    Display *display = XOpenDisplay(0);
> +
> +    //check that X11 is running or else you get a segafult/coredump
> +    if (display != NULL) {
> +	XScreenSaverQueryInfo(display, DefaultRootWindow(display), info);
> +    }
> +    XScreenSaverQueryInfo(display, DefaultRootWindow(display), info);
> +    printf("%u\n", info->idle);
> +    return 0;
> +}
> diff --git a/lisp/ChangeLog b/lisp/ChangeLog
> index bcd6a8a..75bdc38 100755
> --- a/lisp/ChangeLog
> +++ b/lisp/ChangeLog
> @@ -37,6 +37,12 @@
> 	modeline when habits are being displayed (if that module is being
> 	loaded).
>
> +2009-10-21  James TD Smith  <ahktenzero@mohorovi.cc>
> +
> +	* org-clock.el (org-x11-idle-seconds): Add a method to get the X11
> +	idle time using the xscreensaver extension.
> +	(org-user-idle-seconds): Use X11 idle time if available.
> +
> 2009-10-20  Carsten Dominik  <carsten.dominik@gmail.com>
>
> 	* org-agenda.el (org-agenda-next-line): New command.
> @@ -161,7 +167,7 @@
> 	currently active clock if the user has exceeded the time returned
> 	by `org-user-idle-seconds', based on the value of
> 	`org-clock-idle-time'.
> -	(org-clock-in): If, after resolving clocks,
> +	(org-clock-in): If, after resolving clocks,
> 	(org-clock-out): Cancel the `org-clock-idle-timer' on clock out.
>
> 	* org-clock.el (org-clock-resolve-clock): New function that
> diff --git a/lisp/org-clock.el b/lisp/org-clock.el
> index c7ebbf8..fddf3f8 100644
> --- a/lisp/org-clock.el
> +++ b/lisp/org-clock.el
> @@ -762,16 +762,22 @@ non-dangling (i.e., currently open and valid)  
> clocks."
>   "Return the current Mac idle time in seconds"
>   (string-to-number (shell-command-to-string "ioreg -c IOHIDSystem |  
> perl -ane 'if (/Idle/) {$idle=(pop @F)/1000000000; print $idle;  
> last}'")))
>
> +(defun org-x11-idle-seconds ()
> +  "Return the current X11 idle time in seconds"
> +  (/ (string-to-number (shell-command-to-string "x11idle")) 1000))
> +
> (defun org-user-idle-seconds ()
>   "Return the number of seconds the user has been idle for.
> This routine returns a floating point number."
> -  (if (eq system-type 'darwin)
> +  (if (or (eq system-type 'darwin) (eq window-system 'x))
>       (let ((emacs-idle (org-emacs-idle-seconds)))
> 	;; If Emacs has been idle for longer than the user's
> 	;; `org-clock-idle-time' value, check whether the whole system has
> 	;; really been idle for that long.
> 	(if (> emacs-idle (* 60 org-clock-idle-time))
> -	    (min emacs-idle (org-mac-idle-seconds))
> +	    (min emacs-idle (if (eq system-type 'darwin)
> +				(org-mac-idle-seconds)
> +			      (org-x11-idle-seconds)))
> 	  emacs-idle))
>     (org-emacs-idle-seconds)))
>
> -- 
> 1.6.3.3
>
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

- Carsten

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

* Re: [PATCH 0/2] Soem more minor patches
  2009-10-22 10:22   ` James TD Smith
@ 2009-10-22 13:17     ` Carsten Dominik
  0 siblings, 0 replies; 7+ messages in thread
From: Carsten Dominik @ 2009-10-22 13:17 UTC (permalink / raw)
  To: James TD Smith; +Cc: emacs-orgmode

OK, thanks for checking.

- Carsten

On Oct 22, 2009, at 12:22 PM, James TD Smith wrote:

> Hi Carsten,
>
> On 2009-10-22 07:38:04(+0200), Carsten Dominik wrote:
>>
>> On Oct 21, 2009, at 11:52 AM, James TD Smith wrote:
>>
>>> I found the changes John Wiegley made to org-repeat-re stopped it  
>>> from
>>> matching repeaters with just a '+' at the start. I have fixed this.
>>
>> Hi James, can you please provide an example for this bug?
>
> I've had another look at this and it looks like it's already been  
> fixed. The
> version of org-repeat-re in b40c4e did fail to match repeated  
> timestamps like
> <2009-10-22 Thu +4d> but would not match <2009-10-22 Thu .+4d> or
> <2009-10-22 Thu ++4d>, so org-log-repeat would return nil and  
> repeated tasks
> stop repeating.
>
> The org-repeat-re in f93ace works fine.
>>
>>>
>>> Also, I've added a way for the clock resolution code to use system
>>> idle time
>>> under X11, using a small C program which uses the xscreensaver
>>> extension.
>>>
>>> James TD Smith (2):
>>> Add an X11 equivalent to org-mac-idle-seconds.
>>> org-repeat-re was no longer matching simple +2d type repeaters. Fix.
>>>
>>> .gitignore          |    1 +
>>> ChangeLog           |    6 +++++-
>>> UTILITIES/x11idle.c |   21 +++++++++++++++++++++
>>> lisp/ChangeLog      |   11 ++++++++++-
>>> lisp/org-clock.el   |   10 ++++++++--
>>> lisp/org.el         |    2 +-
>>> 6 files changed, 46 insertions(+), 5 deletions(-)
>>> create mode 100644 UTILITIES/x11idle.c
>
> James
>
> --
> |-<James TD Smith>-<email/ahktenzero@mohorovi.cc>-|

- Carsten

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

end of thread, other threads:[~2009-10-22 13:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-21  9:52 [PATCH 0/2] Soem more minor patches James TD Smith
2009-10-21  9:52 ` [PATCH 1/2] Add an X11 equivalent to org-mac-idle-seconds James TD Smith
2009-10-21  9:52   ` [PATCH 2/2] org-repeat-re was no longer matching simple +2d type repeaters. Fix James TD Smith
2009-10-22 13:16   ` [PATCH 1/2] Add an X11 equivalent to org-mac-idle-seconds Carsten Dominik
2009-10-22  5:38 ` [PATCH 0/2] Soem more minor patches Carsten Dominik
2009-10-22 10:22   ` James TD Smith
2009-10-22 13:17     ` Carsten Dominik

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).