diff --git a/projectile.el b/projectile.el index ce67447d5..2125f17b3 100644 --- a/projectile.el +++ b/projectile.el @@ -41,6 +41,8 @@ (require 'ibuf-ext) (require 'compile) (require 'grep) +(require 'xml) + (eval-when-compile (require 'find-dired) (require 'subr-x)) @@ -346,6 +348,7 @@ See `projectile-register-project-type'." ".pijul" ; Pijul VCS root dir ".sl" ; Sapling VCS root dir ".jj" ; Jujutsu VCS root dir + ".osc" ; Osc VCS root dir ) "A list of files considered to mark the root of a project. The bottommost (parentmost) match has precedence." @@ -441,6 +444,7 @@ is set to `alien'." ".cache" ".clangd" ".sl" + ".osc" ".jj") "A list of directories globally ignored by projectile. @@ -796,6 +800,10 @@ Set to nil to disable listing submodules contents." "Command used by projectile to get the files in a svn project." :group 'projectile :type 'string) +(defcustom projectile-osc-command #'projectile-osc-command-files + "Command used by projectile to get the files in a svn project." + :group 'projectile + :type '(function string)) (defcustom projectile-generic-command (cond @@ -1538,8 +1546,22 @@ Fallback to a generic command when not in a VCS-controlled project." ('svn projectile-svn-command) ('sapling projectile-sapling-command) ('jj projectile-jj-command) + ('osc projectile-osc-command) (_ projectile-generic-command))) + +(defun projectile-osc-command-files (&optional root) + "Return files of osc vcs, return either packages or files belonging to package." + (or root (setq root default-directory)) + (let* ((files_ (car (xml-parse-file (if (file-exists-p ".osc/_files") + (expand-file-name ".osc/_files") + (if (file-exists-p ".osc/_packages") + (expand-file-name ".osc/_packages") + (error "Directory neither osc package or project")))))) + (entries (or (xml-get-children files_ 'entry) + (xml-get-children files_ 'package)))) + (mapcar (lambda (entry) (xml-get-attribute entry 'name)) entries))) + (defun projectile-get-sub-projects-command (vcs) "Get the sub-projects command for VCS. Currently that's supported just for Git (sub-projects being Git @@ -1636,12 +1658,15 @@ If `command' is nil or an empty string, return nil. This allows commands to be disabled. Only text sent to standard output is taken into account." - (when (stringp command) + (when (or (stringp command) + (functionp command)) (let ((default-directory root)) + (if (functionp command) + (funcall command root) (with-temp-buffer (shell-command command t "*projectile-files-errors*") (let ((shell-output (buffer-substring (point-min) (point-max)))) - (split-string (string-trim shell-output) "\0" t)))))) + (split-string (string-trim shell-output) "\0" t))))))) (defun projectile-adjust-files (project vcs files) "First remove ignored files from FILES, then add back unignored files." @@ -3787,6 +3812,7 @@ the variable `projectile-project-root'." ((projectile-file-exists-p (expand-file-name ".svn" project-root)) 'svn) ((projectile-file-exists-p (expand-file-name ".sl" project-root)) 'sapling) ((projectile-file-exists-p (expand-file-name ".jj" project-root)) 'jj) + ((projectile-file-exists-p (expand-file-name ".osc" project-root)) 'osc) ;; then we check if there's a VCS marker up the directory tree ;; that covers the case when a project is part of a multi-project repository ;; in those cases you can still the VCS to get a list of files for @@ -3801,6 +3827,7 @@ the variable `projectile-project-root'." ((projectile-locate-dominating-file project-root ".svn") 'svn) ((projectile-locate-dominating-file project-root ".sl") 'sapling) ((projectile-locate-dominating-file project-root ".jj") 'jj) + ((projectile-locate-dominating-file project-root ".osc") 'osc) (t 'none))) (defun projectile--test-name-for-impl-name (impl-file-path)