Merge lp:~rakete/zeitgeist-datasources/emacs-zeitgeist-ignore-files-merge-fix into lp:zeitgeist-datasources

Proposed by Andreas Raster
Status: Merged
Merge reported by: Siegfried Gevatter
Merged at revision: not available
Proposed branch: lp:~rakete/zeitgeist-datasources/emacs-zeitgeist-ignore-files-merge-fix
Merge into: lp:zeitgeist-datasources
Diff against target: 88 lines (+39/-25)
1 file modified
emacs/zeitgeist.el (+39/-25)
To merge this branch: bzr merge lp:~rakete/zeitgeist-datasources/emacs-zeitgeist-ignore-files-merge-fix
Reviewer Review Type Date Requested Status
Siegfried Gevatter Approve
Zeitgeist Data-Sources Team Pending
Review via email: mp+120146@code.launchpad.net

Description of the change

Two main changes:

Give module developers and users a way to prevent zeitgeist from indexing certain files. Either by using a let closure like (let ((zeitgeist-preventt)) (anything in here is ignored by zeitgeist)) or by setting a global regular expression that matches filenames that should be ignored.

A variable to select which .desktop to associate with the files edited by emacs for users using a emacsserver/client setup. Or any custom emacs .desktop file instead of the default one.

If there is interest to merge this I can make this code a little nicer (defcustom instead of defvar). I am using this code since I've written it and never had problems, but I don't use the global regular expression actually, so I would test that too before actually merging.

To post a comment you must log in.
Revision history for this message
Siegfried Gevatter (rainct) wrote :

> If there is interest to merge this

Yeah, why not? :)

Thanks for your interest in contributing to Zeitgeist!

Revision history for this message
Andreas Raster (rakete) wrote :

It has been a year, and I almost forgot about the whole thing, but I am still using the emacs zeitgeist-datasource with my own patch and would really like if this (or something similar) could be merged.

Revision history for this message
Siegfried Gevatter (rainct) wrote :

Hi Andreas,

Sorry for the extreme delay. I've merged your commit into the Git repository:

http://cgit.freedesktop.org/zeitgeist/zeitgeist-datasources/commit/?id=cdd1c219ed3afa9500403c3c499f49583d599034

Thanks, and happy holidays!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'emacs/zeitgeist.el'
2--- emacs/zeitgeist.el 2012-02-11 20:10:02 +0000
3+++ emacs/zeitgeist.el 2012-08-17 11:33:26 +0000
4@@ -24,6 +24,12 @@
5 (require 'cl)
6 (require 'dbus)
7
8+(defvar zeitgeist-emacs-application "application://emacs23.desktop")
9+
10+(defvar zeitgeist-ignore-files-re nil)
11+
12+(defvar zeitgeist-prevent-send nil)
13+
14 ;;** General Functions
15
16 (defun zeitgeist-call (method &rest args)
17@@ -140,7 +146,9 @@
18 ;; Manifestation
19 "http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#UserActivity"
20 ;; Actor (the application, aka emacs)
21- "application://emacs23.desktop")
22+ ;;"application://emacs23.desktop"
23+ zeitgeist-emacs-application
24+ )
25 ;; List of subjects (aas)
26 (list
27 (list
28@@ -159,31 +167,37 @@
29 "Send zeitgeist the EVENT with PROPS."
30 (let ((event-interpretation (zeitgeist-event-interpretation event)))
31 (condition-case err
32- (case event
33- ;; File handling events
34- ((zeitgeist-open-file-event
35- zeitgeist-close-file-event
36- zeitgeist-create-file-event
37- zeitgeist-modify-file-event)
38- (zeitgeist-call
39- "InsertEvents"
40- (zeitgeist-create-event
41- event-interpretation
42- (concat "file://" (plist-get props :file))
43- "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Document"
44- "http://www.semanticdesktop.org/ontologies/nfo#FileDataObject"
45- (concat "file://" (file-name-directory (plist-get props :file)))
46- (zeitgeist-get-mime-type)
47- (file-name-nondirectory
48- (file-name-sans-versions (plist-get props :file)))
49- "")))
50- ;; Email events
51- ((zeitgeist-mail-read-event
52- zeitgeist-mail-sent-event)
53- ;; TODO: Implement me!
54- ))
55+ (case event
56+ ;; File handling events
57+ ((zeitgeist-open-file-event
58+ zeitgeist-close-file-event
59+ zeitgeist-create-file-event
60+ zeitgeist-modify-file-event)
61+ (unless (or zeitgeist-prevent-send
62+ (some (lambda (re)
63+ (string-match re (plist-get props :file)))
64+ zeitgeist-ignore-files-re))
65+ (zeitgeist-call
66+ "InsertEvents"
67+ (zeitgeist-create-event
68+ event-interpretation
69+ (concat "file://" (plist-get props :file))
70+ "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Document"
71+ "http://www.semanticdesktop.org/ontologies/nfo#FileDataObject"
72+ (concat "file://" (file-name-directory (plist-get props :file)))
73+ (zeitgeist-get-mime-type)
74+ (file-name-nondirectory
75+ (file-name-sans-versions (plist-get props :file)))
76+ ""))
77+ (message "zeitgeist event: %s" (file-name-nondirectory
78+ (file-name-sans-versions (plist-get props :file))))))
79+ ;; Email events
80+ ((zeitgeist-mail-read-event
81+ zeitgeist-mail-sent-event)
82+ ;; TODO: Implement me!
83+ ))
84 ;; Ouch, something failed when trying to communicate with zeitgeist!
85- (error (message "ERROR (ZEITGEIST): %s" (cadr err))))))
86+ (error (message "ERROR (ZEITGEIST): %s" (prin1-to-string err))))))
87
88 ;;** Usual File Reading/Editing
89

Subscribers

People subscribed via source and target branches