How do you turn on Pact linting on Emacs? - pact-lang

I want to be able to write Pact code on Emacs. Is Pact available on Emacs? If so, how can I enable it?

Pact is available on Melpa under the pact-mode and flycheck-pact packages. You can expose them in your init.el or .emacs by adding the following statements:
(require 'pact-mode)
(require 'flycheck-pact)
Or, if you'd like to hook flycheck so that it starts on startup, simply add a hook:
(require 'pact-mode)
(require 'flycheck-pact)
(add-hook 'pact-mode-hook 'flycheck-mode)

Related

How to Shadow an Entire Package in Common Lisp

Common Lisp provides the :shadow clause to disable inheritance of package names you don't want to use. But how to shadow an entire package of names?
Here's my basic setup:
#-cl-ppcre (ql:quickload :cl-ppcre)
#-iterate (progn (ql:quickload :iterate) (push :iterate *features*))
#-rutilsx (progn (ql:quickload :rutilsx) (push :rutilsx *features*))
(defpackage :concepts
(:use :cl :cl-ppcre :iterate :rutilsx)
(:shadow :iter) ;error
(:nicknames :con))
but this generates name conflicts.
The problem is that :rutilsx includes the :iter package, which I'd like to disable, so I can use :iterate instead. Thanks for any assistance.
Resolve the conflict in favour of iterate by doing a :shadowing-import-from of the relevant symbols from there, which should be a manageable number.
Another option is to :use the only the specific rutils packages that you need.
Finally, you could use package prefixes for most things (maybe with package-local-nicknames) and only explicitly import those symbols that would be unwieldy without package prefix. This also makes it easier to see where a symbol comes from.

Can the meson project version be assigned dynamically?

I am new to Meson so please forgive me if this is a stupid question.
Simple Version of the Question:
I want to be able to assign a dynamic version number to the meson project version at build time. Essentially meson.project_version()=my_dynamic_var or project( 'my_cool_project', 'c', version : my_dynamic_var') (which of course won't work).
I would rather not pre-process the file if I don't have to.
Some background if anybody cares:
My build system dynamically comes up with a version number for the project. In my case, it is using a bash script. I have no problem getting that version into my top level meson.build file using run_command and scraping stdout from there. I have read that using doing it this way is bad form so if there is another way to do this.. I am all ears.
I am also able to create and pass the correct -DPRODUCT_VERSION="<my_dynamic_var>" via add_global_arguments so I COULD just settle for that.. but I would like the meson project itself to carry the same version for the logs and so I can use meson.project_version() to get the version in subprojects for languages other than c/c++.
The short answer, as noted in comments to the question, appears to be no. There is no direct way to set the version dynamically in the project call.
However, there are some work arounds, and the first looks promising for the simple case:
(1) use meson rewriting capability
$ meson rewrite kwargs set project / version 1.0.0
Then obviously use an environment variable instead of 1.0.0.
(2) write a wrapper script which reads the version from the environment and substitutes it into your meson.build file in the project call.
(3) adopt conan.io and have your meson files generated.
(4) use build options. This option, while not as good as (1) might work for other work flows.
Here's how option (4) works.
create a meson_options.txt file in your meson root directory
add the following line:
option('version', type : 'string', value : '0.0.0', description : 'project version')
then create a meson.build file that reads this option.
project('my_proj', 'cpp')
version = get_option('version')
message(version)
conf_data = configuration_data()
conf_data.set('version', version)
When you go to generate your project, you have an extra step of setting options.
$ meson build && cd build
$ meson configure -Dversion=$BUILD_VERSION
Now the version is available as a build option, then we use a configuration_data object to make it available for substitution into header/source files (which you might want to get it into shared libraries or what not).
configure_file(
input : 'config.hpp.in',
output : 'config.hpp',
configuration : conf_data
)
And config.hpp.in looks something like this:
#pragma once
#include <string>
const static std::string VERSION = "#version#";
When we do the configure_file call, #version# will get substituted for the version string we set in the meson configure step.
So this way is pretty convoluted, but like I said, you may still end up doing some of it, e.g. to print copyright info and what not.
As of 0.60.3 you may directly assign version from run_command which means the following will work without any meson_options.txt.
project('randomName', 'cpp',
version : run_command('git', 'rev-parse', '--short', 'HEAD').stdout().strip(),
default_options : [])
In particular, it is also possible to assign the result of a bash script, simply invoke it instead of git.

Emacs - issues about hide-ifdef-mode

How to autoload hide-ifdef-mode?
Following implementations does not work for me:
;; auto hide-ifdef-mode from starting
(dolist (func '(hide-ifdef-mode hide-ifdef-mode-menu hide-ifdef-block
hide-ifdef-define hide-ifdef-undef
hide-ifdef-use-define-alist hide-ifdef-set-define-alist
hide-ifdef-toggle-read-only hide-ifdef-toggle-outside-read-only
hide-ifdef-shadowing))
(autoload func "hideif" "Hiding several ifdef blocks" t))
or just:
(autoload 'hide-ifdef-mode "hideif" "hideifdefmode" t)
A related issue - How to make that all actions with hide-ifdef-mode have been applied for all *.c and *.h files (buffers)?
Like, if I define some macro (C-c # d) or list of macro and apply it (C-c # h) this action would be performed for other files (and for new opened files too).
I think you're really looking for a way to enable hide-ifdef-mode automatically when you are in c-mode. In Emacs, this is done with hooks.
Try adding this to your configuration:
(add-hook 'c-mode-hook #'hide-ifdef-mode)
Note thate Emacs does have a feature called autoload, which does something different:
The autoload facility lets you register the existence of a function or macro, but put off loading the file that defines it. The first call to the function automatically loads the proper library, in order to install the real definition and other associated code, then runs the real definition as if it had been loaded all along. Autoloading can also be triggered by looking up the documentation of the function or macro (see Documentation Basics).

How to get ruby mkmf to recognize a patched in function?

I'm interested in using ruby-prof and specifically interested in the memory profiling aspect of it. I'm trying to use it for ruby 1.9.3-p484 specifically. I know it requires a patch, and have essentially applied this albeit modified for p484.
Ruby compiles/builds fine and my irb for the ruby environment has those functions defined on GC
irb(main):001:0> GC.malloc_allocations
=> 56769
irb(main):002:0> GC.malloc_allocated_size
=> 11939060
I then try to gem install ruby-prof (using the gem binary from my custom ruby) and it installs fine. However, the mkmf extconf it runs over refuses to recognize the patched in functions. Irb confirms this.
irb(main):004:0> have_func("rb_gc_malloc_allocations")
checking for rb_gc_malloc_allocations()... no
=> false
irb(main):005:0> have_func("rb_gc_malloc_allocated_size")
checking for rb_gc_malloc_allocated_size()... no
=> false
I know the documentation for have_func says it checks the "common" (not sure what that means) header files first or any other header files you tell it to check. ruby-prof by default just checks the common headers (in their extconf.rb).
Unfortunately, I'm not too hot with C. Am I missing something with the patch? Do I need to put something in the ruby headers too? Some flags I need to pass to the gem install command so ruby-prof's extconf.rb finds the right function? Any suggestions?
So, I've figured this out finally (with some help from coworkers of course). It turns out that the function did need to be exposed as available in the ruby headers. The patch I posted in the question needed to be tweaked a bit to match what ruby-prof was expecting (and to expose the function in the headers).
I've put it up here in the hopes that it'll help out some future knowledge seeker.

Emacs semantic+auto-complete-mode for C

I've been working on making auto-complete-mode work with Semantic nicely but know I'm completely stuck. I've succesfully had semantic autocomplete through semantic-ia-complete-symbol (though for some reason it can't complete malloc(), which is weird).
Some .emacs snippets:
(add-to-list 'ac-dictionary-directories "~/emacs-src/auto-complete-1.3.1/")
(ac-config-default)
(ac-set-trigger-key "TAB")
(add-to-list 'ac-sources 'ac-source-semantic)
(add-to-list 'ac-sources 'ac-source-gtags)
(add-hook 'c-mode-hook
(defun my-c-mode-hook ()
(auto-complete-mode)
(setq ac-sources '(ac-source-semantic))
(ac-complete-semantic)))
How do I make auto-complete-mode work together with Semantic?
If I understand you correctly, Semantic is working and you're only struggling with setting up auto-complete. For doing the latter, simply start with
(require 'auto-complete-config)
(setq-default ac-sources '(ac-source-semantic-raw))
Note that you have to use "setq-default" for setting ac-sources. You should then be able to do
M-x auto-complete-mode
in a C/C++ buffer and auto-complete should query Semantic for completions.
Try debugging the auto-completion failure by:
M-x semantic-analyze-debug-assist RET
and see what it says. Look at \include\stdlib.h to see what the parser thinks of the file. If while there you do:
M-x bovinate RET
then you can search to see if malloc is there. If not, there is probably a parsing bug, or some miscellaneous #define that isn't set up correctly. Using the above you can usually find at a header file to see where things start to break down.

Resources