Reload if content file changed on disk (feature request)

Bug #1834336 reported by metastork
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Xpad
New
Undecided
Unassigned

Bug Description

Hi all, wonderful work on xpad, and the scrollbars fix in version 5.4 is working very well! I thought I'd float a small request for a feature, which others might perhaps find useful if using xpad as a todolist.

Currently, I think, if directly modifying a ~/.config/xpad/content-ABCDEF file in a text editor, an existing xpad instance that is open does not reflect those changes (which is expected behaviour).

But it may be useful if xpad periodically checks when it's running whether a content-ABCDEF file has been modified more recently than the last time xpad has written the file and, if it has been, to reload the file from disk.

==Why?==

This would allow using command line tools (like TODO.txt, awk, etc) or text editors to do more advanced searches and manipulation of the content file (i.e., to have a script automatically and periodically delete any items that have been marked DONE or formatted with 'strikethrough' (or even archive those into another xpad note), or to sort the file by priority of tasks, etc).

It is possible to currently emulate this behaviour by using "xpad --quit" and restarting xpad but that's perhaps less elegant for those who keep it running in the background, and it could be nice if it was native functionality.

Edit: Another temporary but much easier solution to implement, could be a command line option like --refresh. This could manually reload all open files from disk and could be triggered by users' scripts manipulating the content files.

==Potential risks==

While a fairly simple operation, this could negatively impact performance a little (potentially the check could be limited to only run if an xpad window is currently in focus / active?).

It could also lead to issues in xpad remembering the previous cursor position within a note, if complex manipulations have been made, which may be more tricky to solve (but it could perhaps be behaviour that a user would accept if they intentionally manually modify the file...)

Finally, I'm not sure how robust the content- file format is and if it would be possible for users to corrupt the file if they accidentally break some formatting codes or insert strange characters into the file.

Would be happy to hear the community's thoughts on if this would be a useful feature.

Tags: feature
metastork (metastork)
description: updated
Revision history for this message
metastork (metastork) wrote :

Hi, in case you want to consider merging this, I've made a pull request for my local install adding a --refresh command line argument functionality, which seems to work fine (but please note I have never coded in C properly, so please check that it looks fine if considering it):

https://code.launchpad.net/~metastork/xpad/xpad

(sorry about the errant white-space diffs in the branch - I'm new to bzr and wasn't able to get it to ignore white spaces that sublime text seems to have inserted for no obvious reason)

Revision history for this message
Arthur Borsboom (arthurborsboom) wrote : Re: [Bug 1834336] Re: Reload if content file changed on disk (feature request)
Download full text (3.8 KiB)

Nice!

I probably will have a look at it next week.
I might use your code as a starting point, keeping in mind a possible
future auto-refresh (on disk update) functionality.

No worries, about the crappy code.
I am a decent Java developer, but a horrible C coder myself too. :)

On Thu, 27 Jun 2019 at 10:30, metastork <email address hidden> wrote:

> Hi, in case you want to consider merging this, I've made a pull request
> for my local install adding a --refresh command line argument
> functionality, which seems to work fine (but please note I have never
> coded in C properly, so please check that it looks fine if considering
> it):
>
> https://code.launchpad.net/~metastork/xpad/xpad
>
> (sorry about the errant white-space diffs in the branch - I'm new to bzr
> and wasn't able to get it to ignore white spaces that sublime text seems
> to have inserted for no obvious reason)
>
> --
> You received this bug notification because you are subscribed to Xpad.
> Matching subscriptions: Arthur Borsboom
> https://bugs.launchpad.net/bugs/1834336
>
> Title:
> Reload if content file changed on disk (feature request)
>
> Status in Xpad:
> New
>
> Bug description:
> Hi all, wonderful work on xpad, and the scrollbars fix in version 5.4
> is working very well! I thought I'd float a small request for a
> feature, which others might perhaps find useful if using xpad as a
> todolist.
>
> Currently, I think, if directly modifying a ~/.config/xpad/content-
> ABCDEF file in a text editor, an existing xpad instance that is open
> does not reflect those changes (which is expected behaviour).
>
> But it may be useful if xpad periodically checks when it's running
> whether a content-ABCDEF file has been modified more recently than the
> last time xpad has written the file and, if it has been, to reload the
> file from disk.
>
> ==Why?==
>
> This would allow using command line tools (like TODO.txt, awk, etc) or
> text editors to do more advanced searches and manipulation of the
> content file (i.e., to have a script automatically and periodically
> delete any items that have been marked DONE or formatted with
> 'strikethrough' (or even archive those into another xpad note), or to
> sort the file by priority of tasks, etc).
>
> It is possible to currently emulate this behaviour by using "xpad
> --quit" and restarting xpad but that's perhaps less elegant for those
> who keep it running in the background, and it could be nice if it was
> native functionality.
>
> Edit: Another temporary but much easier solution to implement, could
> be a command line option like --refresh. This could manually reload
> all open files from disk and could be triggered by users' scripts
> manipulating the content files.
>
> ==Potential risks==
>
> While a fairly simple operation, this could negatively impact
> performance a little (potentially the check could be limited to only
> run if an xpad window is currently in focus / active?).
>
> It could also lead to issues in xpad remembering the previous cursor
> position within a note, if complex manipulations have been made, which
> may be more tricky to solve (but it cou...

Read more...

Revision history for this message
metastork (metastork) wrote :

Thanks Arthur, that'd be great, no hurry! I've mostly just recycled existing functions in xpad, and it seems to be working quite well now to call it from shell scripts that process the files directly, though I'll have to do some more testing.

One possible issue is that I'm not sure right now what xpad's autosave interval / logic is. If the script runs too quickly after making a change in xpad, xpad might overwrite any changes made outside it (but I haven't done enough testing / digging into the code to fully confirm this yet).

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.