phillord / lentic

Create views of the same content in two Emacs buffers
183 stars 12 forks source link

About locked file of lentic-doc-orgify-if-necessary #28

Open tumashu opened 9 years ago

tumashu commented 9 years ago
(defun lentic-doc-orgify-if-necessary (file)
  (let* ((target
          (concat
           (file-name-sans-extension file)
           ".org"))
         (locked
          (or (file-locked-p file)
              (file-locked-p target)))
         (open
          (or
           (get-file-buffer file)
           (get-file-buffer target))))
    (unless (or locked open)
      (when (file-newer-than-file-p file target)
        (let ((lentic-kill-retain t))
          (lentic-batch-clone-and-save-with-config
           file 'lentic-orgel-org-init))))))

Why lock file? can this limit remove?

phillord commented 9 years ago

Well, if the target is locked trying to write to it is a bad idea. And if the file is locked, this may mean it's open in another Emacs.

tumashu commented 9 years ago

Oh, I found the wrong place....

The problem I faced is like this:

when "myfile.org" buffer exist, lentic refuse to write "myfile.org" when i update myfile.el, Is it possible add a yes-or-no, which can ask me: "myfile.org has been opend, do you want to close it force? "

phillord commented 9 years ago

Actually, I think that's a bug. Really, it should work out that the .org file is open and make sure that everything is saved. The file-locked-p is there for the situation when you are running emacs interactively and in batch at the same time (I do this quite often).

This needs to be fixed at some point, I agree.