Guest User

Untitled

a guest
May 24th, 2018
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.26 KB | None | 0 0
  1. commit 4c911e570f8c82b7f91b251bb92089e27c4bc15f
  2. Author: Leo <sdl.web@gmail.com>
  3. Date: Fri Apr 23 11:57:02 2010 +0100
  4.  
  5. Use parent directory for files with same base name
  6.  
  7. Modified lisp/ChangeLog
  8. diff --git a/lisp/ChangeLog b/lisp/ChangeLog
  9. index eb80b35..1b3dd8b 100644
  10. --- a/lisp/ChangeLog
  11. +++ b/lisp/ChangeLog
  12. @@ -269,6 +269,15 @@
  13. * desktop.el (desktop-kill): ask-if-new: Ask if desktop file exists,
  14. but we aren't using it.
  15.  
  16. +2010-04-26 Leo Liu <sdl.web@googlemail.com>
  17. +
  18. + * ido.el (ido-handle-duplicate-virtual-buffers): New variable.
  19. + (ido-find-duplicate-basenames): New function.
  20. + (ido-add-virtual-buffers-to-list): If multiple virtual buffer
  21. + names appear, optionally prefix some with parent directory names
  22. + to disambiguate. By default this is disabled and only the most
  23. + recently used name is used.
  24. +
  25. 2010-04-25 Jan Djärv <jan.h.d@swipnet.se>
  26.  
  27. * tool-bar.el (tool-bar-local-item-from-menu): Revert unintended
  28. Modified lisp/ido.el
  29. diff --git a/lisp/ido.el b/lisp/ido.el
  30. index f75f029..eca7652 100644
  31. --- a/lisp/ido.el
  32. +++ b/lisp/ido.el
  33. @@ -792,6 +792,13 @@ enabled if this variable is configured to a non-nil value."
  34. :type 'boolean
  35. :group 'ido)
  36.  
  37. +(defcustom ido-handle-duplicate-virtual-buffers 0
  38. + "Number of parent directories to add to a duplicate virtual buffer.
  39. +The default value is 0 which means no parent directory is added."
  40. + :version "24.1"
  41. + :type 'integer
  42. + :group 'ido)
  43. +
  44. (defcustom ido-use-faces t
  45. "Non-nil means use ido faces to highlighting first match, only match and
  46. subdirs in the alternatives."
  47. @@ -3408,6 +3415,21 @@ for first matching file."
  48. (run-hooks 'ido-make-buffer-list-hook)
  49. ido-temp-list))
  50.  
  51. +(defun ido-find-duplicate-basenames (files)
  52. + "Find all the duplicate base names in FILES."
  53. + (let ((names (mapcar 'file-name-nondirectory files))
  54. + dups head dup-p)
  55. + (setq names (sort names 'string<))
  56. + (while names
  57. + (setq head (pop names))
  58. + (while (string= head (car names))
  59. + (pop names)
  60. + (setq dup-p t))
  61. + (when dup-p
  62. + (push head dups)
  63. + (setq dup-p nil)))
  64. + dups))
  65. +
  66. (defun ido-add-virtual-buffers-to-list ()
  67. "Add recently visited files, and bookmark files, to the buffer list.
  68. This is to make them appear as if they were \"virtual buffers\"."
  69. @@ -3416,10 +3438,18 @@ This is to make them appear as if they were \"virtual buffers\"."
  70. ;; the file which the user might thought was still open.
  71. (unless recentf-mode (recentf-mode 1))
  72. (setq ido-virtual-buffers nil)
  73. - (let (name)
  74. + (let ((dups (unless (zerop ido-handle-duplicate-virtual-buffers)
  75. + (ido-find-duplicate-basenames recentf-list)))
  76. + name dir)
  77. (dolist (head recentf-list)
  78. (and (setq name (file-name-nondirectory head))
  79. (null (get-file-buffer head))
  80. + (if (not (member name dups))
  81. + t
  82. + (setq dir head)
  83. + (dotimes (__ (1+ ido-handle-duplicate-virtual-buffers))
  84. + (setq dir (directory-file-name (file-name-directory dir))))
  85. + (setq name (file-relative-name head dir)))
  86. (not (assoc name ido-virtual-buffers))
  87. (not (member name ido-temp-list))
  88. (not (ido-ignore-item-p name ido-ignore-buffers))
Add Comment
Please, Sign In to add comment