Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dpu

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dpu

  • 0.6.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

dpu: determine permanent URI

License X11 Gem Version Build Status

dpu command shows us permanent source-code URI.

$ dpu array.c 4133 4136
https://github.com/ruby/ruby/blob/v3_2_2/array.c#L4133-L4136

Requirements

  • Ruby

Installation

$ gem install dpu

Usage

Get permanent source code URI:

$ dpu path_to_code

Get permanent source code URI with line range:

$ dpu path_to_code start_line_number end_line_number

Emacs integration

Write following code to your .emacs, and evaluate it.

.emacs sample
(define-key global-map (kbd "C-x L")
  (lambda ()
    (interactive)
    (save-window-excursion
      (let* ((start-line-number (line-number-at-pos (if (region-active-p) (region-beginning))))
             (end-line-number
              (if mark-active
                  (line-number-at-pos
                   (+ (region-end)
                      (if (= (line-beginning-position) (region-end)) -1 0)))
                ))
             (proc (apply
                    #'start-process
                    "dpu" "*Dpu Command Result*"
                    "dpu" buffer-file-name
                    (number-to-string start-line-number)
                    (if end-line-number
                        (list (number-to-string end-line-number)))
                    ))
             (kill-new-with-buffer-string
              (lambda (process signal)
                (when (memq (process-status process) '(exit signal))
                  (let* ((buf (process-buffer process)))
                    (with-current-buffer buf
                      (kill-new (s-chomp (buffer-string)))
                      (message "Copied: %s" (current-kill 0 t))
                      (kill-buffer buf)
                      )))))
             )
        (run-with-timer 10 nil (lambda (process) (kill-buffer (process-buffer process))) proc)
        (if (process-live-p proc)
            (set-process-sentinel proc kill-new-with-buffer-string))
        )
      )))

Then type C-x L to copy permanent URI. C-y to paste it.


Original asynchronous execution idea is made by @mk2 (#20). Thanks! :tada:

Textbringer integration

define_command(:copy_permanent_uri, doc: "Copy permanent URI") do
  require "dpu"
  b = Buffer.current
  uri = Dpu.determine_permanent_uri(Pathname(b.file_name), start_line_number: b.current_line)
  KILL_RING.push(uri)
  Clipboard.copy(uri) if CLIPBOARD_AVAILABLE
  message("Copied: #{uri}")
end

GLOBAL_MAP.define_key("\C-xL", :copy_permanent_uri)

Visual Studio Code integration

See Copy permanent URL extension on Visual Studio Marketplace.

Other editor integration

Write pull-request or issue, please!

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/nishidayuya/dpu .

FAQs

Package last updated on 11 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc