Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Please present a use case. I'm sure there should be a better way to do it. If there's not, I'll update my answer.</p> <p>I imagine that running the hook on <em>every</em> file would be annoying as hell. I can run a command on any file with <kbd>C-x d !</kbd>.</p> <p>With this code:</p> <pre><code>(require 'dired-x) (global-set-key (kbd "C-x d") 'dired-jump) </code></pre> <p><kbd>C-x d</kbd> will not only open current directory with <code>dired</code>, but also jump to current file's line. With this <kbd>!</kbd> will run a command on the file. This command can be auto-completed with <kbd>TAB</kbd> which is also superior to your current solution.</p> <h2>UPD1</h2> <p>Now I see that you want to run <code>bk edit</code> only on files in the repository. Here's how you can do it:</p> <pre><code>(defvar bitkeeper-dirs '("/tmp/")) (defun bitkeeper-p (file) (reduce (lambda (a b) (or a (string-match (expand-file-name b) file))) bitkeeper-dirs :initial-value nil)) (add-hook 'find-file-hook (lambda () (let ((file (buffer-file-name))) (when (bitkeeper-p file) (read-only-mode -1) (shell-command (format "cat %s &gt; /tmp/stuff" file)))))) </code></pre> <ol> <li>You should put a list of your Bitkeeper repositories in <code>bitkeeper-dirs</code>. The current predicate just tests if the file being opened is in one of this directories.</li> <li>You could write a better predicate if you want. I can't since I don't know how Bitkeeper works. If it were git, I'd probably call <code>git status</code> and see what it returns.</li> <li>You should replace <code>"cat %s &gt; /tmp/stuff"</code> with <code>"bk edit %s"</code>. The current string is just there for testing purposes.</li> </ol> <h2>UPD2</h2> <p>In answer to </p> <blockquote> <p>The best way to test whether a file is in a bk repo is to run "bk root file" a status of 0 means its in a repo. A status of 1 means it is not.</p> </blockquote> <p>Here's the new predicate. I can't test it since I don't have Bitkeeper.</p> <pre><code>(defun bitkeeper-p (file) (string= "0" (shell-command-to-string (format "bk root %s") file))) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload