Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8190293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:34:28+00:00 2026-06-07T03:34:28+00:00

So at work, I’ve got to work from two different repositories. The files map

  • 0

So at work, I’ve got to work from two different repositories. The files map to essentially the same place, but one path has ‘data’ in it.

It’s relatively trivial to write a defun that determines if the file is in the data directory or not, and so which repository I actually want to check out from. But I can’t figure out a way to call my function before any p4 commands without explicitly rebinding the keys to do it, and even that is sort of a big hack. I’d really just like it to run every time I try to check out or revert a file and set the p4port as I want it to.

All the hooks in the p4 system seem to be called when I don’t want them to be. I tried calling my defun on the p4-mode-hook, but that hook only runs when the mode is set, and files that aren’t in the repository are rejected before I ever get my defun to do anything. :/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T03:34:30+00:00Added an answer on June 7, 2026 at 3:34 am

    There are a couple of approaches that you could use. First, you could consider adding the desired functions to pre-command-hook, with a predicate to check whether the current buffer is operating in p4-mode, i.e.:

    (add-hook
     'pre-command-hook
     (lambda ()
       (when (eq major-mode 'p4-mode)
         ;;; specify whatever functions you desire
         )))
    

    This will indiscriminately execute the functions that you include in the body of the above lambda before any command in a p4-mode buffer. If that’s overkill and you need to be more selective about when to execute said functions, you should probably individually advise each of the p4 commands that should first execute your functions before running, e.g.:

    (defadvice
      name-of-p4-function
      (before name-of-p4-function-advice activate)
      ;;; functions to be executed
      )
    
    (ad-activate 'name-of-p4-function)
    

    See the Advising functions section of the Emacs manual for additional details.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Work got in the way of learning Objective C but i'm back at it
At work I have two XP PCs. On one, I can click with the
Work on C# Desktop project,I have an account on paypal ,From my desktop application
Work on C#, in one of my application I need to get the SQL
Work on C# linq.I have a list to list .From this list I want
To work with databases or files as simple data persistance layer is easy to
My work is in the process of switching from SVN to Git and we
I work in a place where each of our internal applications runs on an
We work with some very large databases (300Gb - 1Tb). Tables can contain from
We work usually on more than one version of the application, where each version

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.