* Re: [patch] now possible to search for text in folded blocks
2009-08-19 21:19 [patch] now possible to search for text in folded blocks Eric Schulte
@ 2009-08-20 7:59 ` Carsten Dominik
2009-08-20 10:03 ` Yuva
1 sibling, 0 replies; 4+ messages in thread
From: Carsten Dominik @ 2009-08-20 7:59 UTC (permalink / raw)
To: Eric Schulte; +Cc: Org Mode
Applied, thanks.
- Carsten
On Aug 19, 2009, at 10:19 PM, Eric Schulte wrote:
> Please apply, I don't *think* this can break anything. Thanks -- Eric
>
> From f73d4b67c027209905dd90868d57440ceacdea28 Mon Sep 17 00:00:00 2001
> From: Eric Schulte <schulte.eric@gmail.com>
> Date: Wed, 19 Aug 2009 15:17:09 -0600
> Subject: [PATCH] now possible to search for text inside of folded
> blocks
>
> ---
> lisp/org.el | 38 ++++++++++++++++++++++++--------------
> 1 files changed, 24 insertions(+), 14 deletions(-)
>
> diff --git a/lisp/org.el b/lisp/org.el
> index e2cdce8..14adeda 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -5364,24 +5364,34 @@ the range."
> (beginning-of-line)
> (if (re-search-forward org-block-regexp nil t)
> (let ((start (- (match-beginning 4) 1)) ;; beginning of body
> - (end (match-end 0))
> - ov) ;; end of entire body
> + (end (match-end 0)) ;; end of entire body
> + ov)
> (if (memq t (mapcar (lambda (overlay)
> (eq (org-overlay-get overlay
> 'invisible)
> - 'org-hide-block))
> + 'org-hide-block))
> (org-overlays-at start)))
> - (if (or (not force) (eq force 'off))
> - (mapc (lambda (ov)
> - (when (member ov org-hide-block-overlays)
> - (setq org-hide-block-overlays
> - (delq ov org-hide-block-overlays)))
> - (when (eq (org-overlay-get ov 'invisible)
> - 'org-hide-block)
> - (org-delete-overlay ov)))
> - (org-overlays-at start)))
> - (setq ov (org-make-overlay start end))
> + (if (or (not force) (eq force 'off))
> + (mapc (lambda (ov)
> + (when (member ov org-hide-block-overlays)
> + (setq org-hide-block-overlays
> + (delq ov org-hide-block-overlays)))
> + (when (eq (org-overlay-get ov 'invisible)
> + 'org-hide-block)
> + (org-delete-overlay ov)))
> + (org-overlays-at start)))
> + (setq ov (org-make-overlay start end))
> (org-overlay-put ov 'invisible 'org-hide-block)
> - (push ov org-hide-block-overlays)))
> + ;; make the block accessible to isearch
> + (org-overlay-put
> + ov 'isearch-open-invisible
> + (lambda (ov)
> + (when (member ov org-hide-block-overlays)
> + (setq org-hide-block-overlays
> + (delq ov org-hide-block-overlays)))
> + (when (eq (org-overlay-get ov 'invisible)
> + 'org-hide-block)
> + (org-delete-overlay ov))))
> + (push ov org-hide-block-overlays)))
> (error "Not looking at a source block"))))
>
> ;; org-tab-after-check-for-cycling-hook
> --
> 1.6.4.73.gc144
>
> _______________________________________________
> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] now possible to search for text in folded blocks
2009-08-19 21:19 [patch] now possible to search for text in folded blocks Eric Schulte
2009-08-20 7:59 ` Carsten Dominik
@ 2009-08-20 10:03 ` Yuva
2009-08-20 10:05 ` Yuva
1 sibling, 1 reply; 4+ messages in thread
From: Yuva @ 2009-08-20 10:03 UTC (permalink / raw)
To: Org Mode
[-- Attachment #1: Type: text/plain, Size: 2049 bytes --]
hi,
i've implemented a simple idea, but thought it could be done in a better
way. Need your feedback.
At work, i am running emacs+org-mode on windoze-xp computer, and i am happy
with my setup. Whenever i am away from my computer, or i am off for the day,
i generally lock my workstation and just leave (I dont shut my system down).
The org-mode clock runs even when i am not doing anything. I want it to
switch it to default task when i am away. So, i developed a simple
application which makes use of 'emacsclientw' and sends messages to
emacs-server to notify the status of my workstation.
Briefly, my setup is like this :
in my "orged.el"
-------------------------8<---------------------8<--------------------------
;;-------------------------------------------------------------------------
;; for listening to windows-session events.
;;-------------------------------------------------------------------------
;; sets default task.
;; @todo make it more intutive
(require 'org-clock)
(set-marker org-clock-default-task
34 (find-file "~/orged/personal/personal.org"))
;; Custom org-win-lock and org-win-unlock functions.
(defun org-win-lock()
"runs org-preferences when workstation gets locked
Switches to default task."
(interactive)
(find-file (buffer-file-name (marker-buffer org-clock-default-task)))
(goto-char org-clock-default-task)
(org-clock-in))
(defun org-win-unlock()
"runs org-preferences when workstation gets un-locked
Switches to interrupted task."
(interactive)
(find-file (buffer-file-name (marker-buffer org-clock-interrupted-task)))
(goto-char org-clock-default-task)
(org-clock-in))
;; start the server and notification application.
(server-start)
(start-process
"eval-a-exe" "buf-eval-a-exe" "~/sandbox/windows-lock-notif/a.exe")
-------------------------8<---------------------8<--------------------------
i also wrote a small application which polls on session events and send
messages to this emacs-server (see attachment).
My question is : Can it be done better?
[-- Attachment #2: main.c --]
[-- Type: application/octet-stream, Size: 4732 bytes --]
//-------------------------------------------------------------------------
// sending async messages to emacs-server.
// for me, "server" sounds like some kind of geek term, but infact all
// i have to do is add (server-start) to my orged.el file.
//
// build it like : gcc main.c -lwtsapi32
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
// msconfig.h stuff
//-------------------------------------------------------------------------
// contains stdafx.h and other definitions.
#define WINVER 0x0501
#define WIN32_LEAN_AND_MEAN
// includes.
#include <windows.h>
#include <wtsapi32.h>
//-------------------------------------------------------------------------
// main program.
//-------------------------------------------------------------------------
// synchronizing event.
static HANDLE hEvent;
static LRESULT OnWtsSessionChange(HWND hWnd, WPARAM wEventType)
{
TCHAR szCmdlineOnLock[] =
TEXT("C:\\cygwin\\usr\\local\\nt-emacs\\bin\\emacsclientw -e \"(org-win-lock)\"");
TCHAR szCmdlineOnUnlock[] =
TEXT("C:\\cygwin\\usr\\local\\nt-emacs\\bin\\emacsclientw -e \"(org-win-unlock)\"");
PROCESS_INFORMATION piProcInfo;
STARTUPINFO siStartInfo;
ZeroMemory( &piProcInfo, sizeof(PROCESS_INFORMATION) );
ZeroMemory( &siStartInfo, sizeof(STARTUPINFO) );
siStartInfo.cb = sizeof(STARTUPINFO);
siStartInfo.hStdError = NULL;
siStartInfo.hStdOutput = NULL;
siStartInfo.hStdInput = NULL;
siStartInfo.dwFlags |= STARTF_USESTDHANDLES;
TCHAR* cmdLine = NULL;
switch (wEventType)
{
case WTS_SESSION_LOCK :
cmdLine = szCmdlineOnLock;
break;
case WTS_SESSION_UNLOCK :
cmdLine = szCmdlineOnUnlock;
break;
case WTS_SESSION_LOGOFF :
SetEvent(hEvent);
DestroyWindow(hWnd);
break;
}
CreateProcess(NULL, cmdLine, NULL, NULL, TRUE, 0, NULL, NULL,
&siStartInfo, &piProcInfo);
return 0;
}
static LRESULT CALLBACK
WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
LRESULT result = 0;
switch (message)
{
case WM_WTSSESSION_CHANGE :
result = OnWtsSessionChange(hWnd, wParam);
break;
case WM_DESTROY :
PostQuitMessage (1);
break;
}
result = DefWindowProc(hWnd, message, wParam, lParam);
return result;
}
static DWORD WINAPI fnWaitForWtsNotifs(LPVOID lpParam)
{
WNDCLASS wc;
HWND hWnd;
MSG msg;
HANDLE hInstance = GetModuleHandle(NULL);
wc.style = 0; // Class style
wc.lpfnWndProc = (WNDPROC) WndProc; // Window procedure
wc.cbClsExtra = 0; // Class extra bytes
wc.cbWndExtra = 0; // Window extra bytes
wc.hInstance = (HINSTANCE)hInstance; // Instance handle
wc.hIcon = LoadIcon (NULL, IDI_WINLOGO); // Icon handle
wc.hCursor = LoadCursor (NULL, IDC_ARROW); // Cursor handle
wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1); // Background color
wc.lpszMenuName = NULL; // Menu name
wc.lpszClassName = "MyWndClass"; // WNDCLASS name
RegisterClass(&wc);
hWnd =
CreateWindow (
"MyWndClass", // WNDCLASS name
"RegisterApplication", // Window title
WS_OVERLAPPEDWINDOW, // Window style
CW_USEDEFAULT, // Horizontal position
CW_USEDEFAULT, // Vertical position
CW_USEDEFAULT, // Initial width
CW_USEDEFAULT, // Initial height
HWND_MESSAGE, // HWND_DESKTOP, Handle of parent window
NULL, // Menu handle
NULL, // Application's instance handle
NULL // Window-creation data
);
// register for wts notifications.
if ( ! WTSRegisterSessionNotification(hWnd, NOTIFY_FOR_ALL_SESSIONS) )
{
printf("WTSRegisterSessionNotification failed");
return -1;
}
while ( GetMessage(&msg, NULL, 0, 0) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
WTSUnRegisterSessionNotification(hWnd);
return msg.wParam;
}
int main()
{
HANDLE hThread;
DWORD dwId;
// create a thread, wait for notificatons.
hThread = CreateThread( NULL, 0, fnWaitForWtsNotifs, NULL, 0, &dwId);
if (NULL == hThread) { return -1; }
hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
if (INVALID_HANDLE_VALUE == hEvent) { return -1; }
WaitForSingleObject(hEvent, INFINITE);
CloseHandle(hEvent);
printf("exiting");
return 0;
}
[-- Attachment #3: Type: text/plain, Size: 204 bytes --]
_______________________________________________
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
^ permalink raw reply [flat|nested] 4+ messages in thread